-
Notifications
You must be signed in to change notification settings - Fork 0
Game
Braidon edited this page Sep 7, 2024
·
1 revision
- canvas : HTMLCanvasElement
- The current canvas of the Game.
- public, but shouldn't really be touched.
- audioElement: HTMLAudioElement
- The current audio element of the Game.
- public, but shouldn't really be touched.
- graphicsContext : Graphics
- The Graphics instance, handles drawing and stuff.
- audio : CattailAudio
- The CattailAudio instance, handles audio and stuff.
- entites : Array<GameObject>
- An array of GameObjects that represent all of the entites currently having their logic run.
- fps : number = 1000/60
- Practically useless, used to determine deltatime, but isn't deltatime supposed to remain constant regardless of FPS?
- currentLoop : number
- This isn't even used.
- backgroundImage: Sprite
- Represents the background image of the current canvas.
- deltaTime : number;
- It's delta-time, what else is there to say?
- NullDrawable : Drawable;
- If you want a purely logic GameObject, then assign this so it doesn't draw anything. Null won't work.
- context : CanvasRenderingContext2D
- It's the rendering context for the current canvas.
- constructor(size?: Vector2, backgroundColour?:Colour) : Game
- Creates a new Game instance.
- You can have multiple, but why?
- Params:
- setBackgroundImage(imageUrl: string) : void
- Sets the background image of the game, the background image is a sprite, but it is always drawn in the very back.
- Params:
- imageUrl : string: the url to the image to be set as background.
- addEntity(entity: GameObject) : void
- Adds the specified GameObject to the list of simulated entities.
- Params:
- entity: GameObject: The game object to be added to the entities list.
- run() : void
- Runs the game.
- In order:
- calculates deltaTime
- updates all entities
- clears the canvas
- draws the background
- draws from the drawlist
- requests the next animation frame