| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import "./const.ecal" as const
- import "./helper.ecal" as hlp
- /*
- newGameWorld creates a new game world datastructure.
- */
- func newGameWorld(name) {
- let ret := hlp.copyMap(DefaultGameWorld)
- ret["key"] := name
- ret["kind"] := const.NodeKinds.ConfigurationObject
- return ret
- }
- DefaultGameWorld := {
- "backdrop" : null,
- "screenWidth" : 640,
- "screenHeight" : 480,
- "screenElementWidth" : 640,
- "screenElementHeight" : 480
- }
- /*
- newSpriteNode creates a new sprite node datastructure.
- */
- func newSpriteNode(id, x, y, dim=20, rot=0, speed=0) {
- let ret := hlp.copyMap(DefaultSpriteState)
- ret["key"] := id
- ret["kind"] := const.NodeKinds.GameWorldObject
- ret["id"] := id
- ret["x"] := x
- ret["y"] := y
- ret["dim"] := dim
- ret["rot"] := rot
- ret["speed"] := speed
- return ret
- }
- DefaultSpriteState := {
- /* A unique ID */
- "id" : "",
- /* Sprite x position */
- "x" : 20,
- /* Sprite y position */
- "y" : 20,
- /* Dimensions of the sprite (box) */
- "dim" : 20,
- /* Flag if the sprite is moving or static */
- "isMoving" : true,
- /*
- Flag if the sprite is kept in the display or if it should be
- destroyed once it is outside of the visible area
- */
- "displayLoop" : true,
- /* Turning direction (-1 for left, 1 for right, 0 no turning) */
- "dir" : 0,
- /* Angle of rotation */
- "rot" : 0,
- /* Rotation speed for each step (in radians) */
- "rotSpeed" : math.Pi / 180,
- /* Moving direction (1 forward, -1 backwards, 0 no movement) */
- "speed" : 0,
- /* Strafing direction of sprite (-1 left, 1 right, 0 no movement) */
- "strafe" : 0,
- /* Move speed for each step */
- "moveSpeed" : 0.21
- }
|