espace Posted January 25, 2018 Share Posted January 25, 2018 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() { }, } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.