Hey I was wondering how I could add on to my function draw(); draw is used in my canvas engine to update everything within it. What I want to do is create a standalone engine that could say be left un-edited and yet update completely new things just linked to it. For example-
function draw(){
gameloop();
cameraWrapper();
context2D.clearRect(0,0,canvas.width, canvas.height);
}
Now say I create a new app and use this engine.. I want to be able to just create a standalone file linked to the engine say a player object.
player = new object();
function playerupdate(){
stuff;
stuff;
}
Now how could I say add the playerupdate() function into the engine.js’s draw() function without editing the engine.js file? would this be like a prototype? if so and even if its not and example would be greatly appreciated!
If you have any questions please ask,
thanks in advance!
I think inheritance is a bit too complex for this… you can achieve all of what you want with just hooks.
Try something like this: