The basics of the game world for me are the search for common grounds.
the world goes forward in time. so that all active elements (player, discarded items, enemies, npc), but all passive elements are not (block of stone, wood, home), so I would use 2 interfaces ActiveElement and PassiveElement. the active element may have a stepintime () function, which is called by the game world every time in itself in time. both elements can have a render () function that draws an element whenever the game world is drawn on canvas.
then all enemies should call them ai in order to determine their next time step, as well as to check for collisions with any other objects, and whatever that means (player bullet trees, etc.) is the same basically for every other element.
this is for me the most basic architecture in the game worlds.
then there is a performance problem when it would be better to put certain things in your own threads and let them work (enemy ai, who checks the position and status of his avatar in each cycle and makes an input that is read with each step on time), but I donβt have enough experience to develop. then you should go to the gamedev website (for example, as karim79 said).
implemented elements can have their own attributes, and then easily expand (health, statistics) and write to an interpreter who reads simpel scripts that communicate with the game world, adding opponents, etc.
ciao
youri source share