Jump to content

Basic structuring advice requested


Jimmy
 Share

Recommended Posts

Hi,

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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