var anything = new Character({...})
From the backgrounds to collision blocks, NPCs and player characters, everything you see on the game screen is created using a character object. The Character object is defined in characters.js and contains data that is used by the game engine to decide the characters state or behaviour on screen.
'name':'mario'
Like mario, block or powerup, it's a character's name.
'visible':true
Wether the item should start visible in the scene or get in later.
'instance':0
Wether the item is a single object (0) or will be instances (1-above)
'x':50
The horizontal position, visible from 0 (left) to the value of the screen width (right).
'y':50
The vertical position, visible from 0 (top) to the value of the screen height (bottom).
'width':100
The horizontal span, drawn from the value of x (50) to to this value of the width (100).
'height':100
The vertical span, drawn from the value of y (50) to to this value of the height (100).
'direction':0
The clockwise angle around its imaginary z-axis, in degrees 0/360 (up) to 90 (right), to 180 (down), to 270 (left).
'speed':0
The starting and current speed, how much it changes its position by.
'angspeed':0
The starting and current angular speed, how much it changes its direction/angle by.
'maxspeed':10
The maximum speed allowed or possible.
'minspeed':0
The minimum speed allowed or possible.
'link':'https://link-to-image'
Link to the image that that visually represents this, could be a jpeg or png or animated gif.
'input':{...}
User inputs this character has actions for.
'custom':{...}
Custom variables for data like score, health etc..
var gameLoop = () => {...}
Every character is repeatedly drawn on the screen using the data you have set in it's object. The game is made by you changing or using that data. I have provided some functions that i think will help you save time (i guess that's what a game engine is).
anything.getvectorcomp(direction, magnitude)
...
anything.getvector(x1, y1, x2, y2)
...
anything.move(speed)
...
anything.moveTo(x, y, speed)
...
anything.rotate(angspeed)
...
anything.rotateTo(direction, angspeed)
...
anything.scale(xw, yh)
...
anything.scaleTo(width, height, speed)
...
anything.showimage(link, asset)
...
anything.animate(loop, linklist)
...
anything.playsound(loop, link)
...
anything.showtext(cursor, text, size, position)
...
The character remains the same as it is drawn repeatedly, unless something changes. Events are what check for this state of the character and allow you to pick specific characters according to their values. Games are a battlefield of events.//Events if(character.name == 'mario'){...}
//Time-Events
if (Game.time == 3){...}
//Key-Events
if (Game.key['KeyW'] == true){...}
//Mouse-Events
if (Game.mousePosition.y > 20){...}
//Collision-Events
for (box in Game.collisionGraph) {
var collider = Game.collisionGraph[box];
if (character.name == 'mario' && collider.n == 'powerup'){...}
}