espace

new structure for my future games

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() {
		
	},
}


 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.