-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting Node into Entity/Node. (#73)
* Splitting Node into Entity/Node.
- Loading branch information
1 parent
aac2d48
commit bef84d0
Showing
23 changed files
with
170 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import | ||
hashes, | ||
sequtils | ||
|
||
import | ||
node, | ||
gamestate, | ||
../render/render, | ||
../render/shader, | ||
../math/vector2 | ||
|
||
export | ||
node, | ||
hashes, | ||
sequtils, | ||
render | ||
|
||
type | ||
Entity* = ref object of Node | ||
shader*: Shader | ||
location: Vector | ||
# Rotation in degrees (clockwise). | ||
rotation*: float | ||
|
||
method setLocation*(this: Entity, x, y: float) {.base.} | ||
method hash*(this: Entity): Hash {.base.} | ||
|
||
proc initEntity*(entity: Entity, flags: NodeFlags = UPDATE_AND_RENDER) = | ||
entity.flags = flags | ||
|
||
proc newEntity*(flags: NodeFlags = UPDATE_AND_RENDER): Entity = | ||
result = Entity() | ||
initEntity(result, flags) | ||
|
||
method getLocation*(this: Entity): Vector {.base.} = | ||
this.location | ||
|
||
method x*(this: Entity): float {.base.} = | ||
this.location.x | ||
|
||
method y*(this: Entity): float {.base.} = | ||
this.location.y | ||
|
||
method `x=`*(this: Entity, x: float) {.base.} = | ||
this.setLocation(x, this.y) | ||
|
||
method `y=`*(this: Entity, y: float) {.base.} = | ||
this.setLocation(this.x, y) | ||
|
||
method setLocation*(this: Entity, x, y: float) {.base.} = | ||
this.location.x = x | ||
this.location.y = y | ||
|
||
method setLocation*(this: Entity, v: Vector) {.base.} = | ||
this.setLocation(v.x, v.y) | ||
|
||
method move*(this: Entity, dx, dy: float) {.base.} = | ||
this.setLocation(this.x + dx, this.y + dy) | ||
|
||
method move*(this: Entity, v: Vector) {.base.} = | ||
this.setLocation(this.x + v.x, this.y + v.y) | ||
|
||
method hash*(this: Entity): Hash {.base.} = | ||
return hash(this[].unsafeAddr) | ||
|
||
Entity.renderAsChildOf(Node): | ||
if this.shader != nil: | ||
this.shader.render(gamestate.runTime, gamestate.resolution) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.