Jump to content

Basic structuring advice requested


Recommended Posts


I'm trying to get used to how Phaser really works and I've know got a small question. 


I've structured my game state as following:

var myGame = myGame || {};myGame.Game = function(){};myGame.Game.prototype = {    create: function() {    },    update: function() {    }}; 

I removed the actual code that's inside as I don't think I need to show it. Now I'm at the state where I want to create a AI sprite object. There will be a lot of these "AI bots" and I'll put them in a group.


Though the AI entity/object are going to have quite many variables as well as functions assigned to it. Imagine something like the "EnemyTank" in the tanks example found here: http://examples.phaser.io/_site/view_full.html?d=games&f=tanks.js&t=tanks


Now my question is how you would go ahead and create this AI object? Is it a wise decision to structure and place it as in the Tanks example or would you personally prefer to write an other way? I'm mainly just looking for some advice of what's the best practice really. Because often when working on projects I start out thinking that I don't need to worry much about how I structure my code but as the projects grow you always regret that you didn't put more effort into structuring your code properly. 

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...