01 Stage Method - JcerelusDev/CanvasGameJs GitHub Wiki

How to use canvasGameJs

you don't need the canvas (Element) in your html file.

<!DOCTYPE html>

<html >

<head >

<title > </title >

</head >

<body >

<script src="https://cdnjsdelivr.net/gh/JcerelusDev/canvas00/Js/canvas-game.min.js" > </script >

</body >

</html >

How to use Stage()

you need to declare a variable to hold the game object.

Example :

 const game = new Stage();

This allows you to initialize the main game object.

Important :

After you initialize the game object. You have to set those two important functions :

game.update = function(){
//learn that method later on
}


game.drawGame = function(){
//learn that method later on
}

// game.drawGame == game.render 

game.render = function(){
//learn that method later on
}


And also use the setAnimation method

https://github.com/JcerelusDev/canvas00/wiki/42-setAnimation

As follow :

const game = new Stage()
/* other lines of code 
--------------------
---------------------
----------------------

Then 
*/
game.update = function(){
//learn those method later on
}

game.drawGame = function(){
//learn those method later on
}

game.render = function(){
//learn those method later on
}

game.setAnimation(fps)

You can use either render or drawGame they are the same .