Jump to content

new structure for my future games


espace
 Share

Recommended Posts

hi,

instead of using a lot of prototype in my futures games, i would use this structure example. using a lot of prototype is a little confusing for me especially if there are more than 2000 lines of codes. i found this structure more easier to understand...

especially use this formula : condition && action(); because almost all the time actions requires a condition to be launch.

have you comments about this ? recommendations ?

ps : sorry for my bad english :(

// -------------------------------------
// HAS
// -------------------------------------
var has_jump=false;
var has_land=false;
// -------------------------------------
// IS
// -------------------------------------
var is_on_life=false;
var is_game_start=false;

// -------------------------------------
// PLAYER
// -------------------------------------
var player={};

// -------------------------------------
// INTERFACE 
// -------------------------------------
var button={};
var background;
var score;
var text={};

// -------------------------------------
// EFFECTS => SOUNDS - ANIMATION -MOVEMENTS 
// -------------------------------------
var effect={};
//sounds

//animation
effect.score=function(){

var condition=true;
var action=function(){
};
condition && action();
};
//movement
effect.move_player=function(){

var condition=true;
var action=function(){
};
condition && action();
};

// -------------------------------------
// RESET - RESTART STATE
// -------------------------------------
var action={};
action.restart_game=function(){
var condition=true;
var action=function(){
};
condition && action();
};
}

// -------------------------------------
// UPDATE 
// -------------------------------------
var update_lower=function(){
//game.time.events.loop( time,this.function,this );
}

var on_touch=function(){
};

update_lower();
// -------------------------------------
// STATE
// -------------------------------------
var start_screen={
	preload: function() {
		
	},

	create: function() {
		
	},

	update: function() {
		
	},
}

var game={
	preload: function() {
		
	},

	create: function() {
		
	},

	update: function() {
		
	},
}


 

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...