IKKYU Posted February 23, 2015 Share Posted February 23, 2015 Hi Let me start by saying I'm a real beginner at programming, and im using Phaser to learn more javascript.Iv'e gone thru alot of awesome tutorials from Lessmilk and Codevinsky among some. All with some different approaches.I have also managed to create some really simple games with only 1 level in phaser. Now i feel im missing some crucial parts that i dont understand. Like how to create new levels without copy pasting all code back into each state. It feels like i'm creating one game for each level. (I guess im doing something really wrong hehe.) What i think alot of people like me starting out in programming with js + phaser want to know is:How do you separate game logic from levelspecific code? Also show how to separate code into different files and reuse them. (if possible) So my request is: Can someone make a tutorial for say a really simple platformer (or any other game) with 2 players (with different spritesheets for anims etc )and explain how to break out the code for movement etc so both players can use it.(in a separate file if possible). how to add stuff like coins to collect (also in a separate file if possible.) And also how to keep track of each players score. And lastly add 2 levels and how to load new tilemap. for each level. Preferably as simple as possible... I know its a big request and not an easy task. But its stuff like this i cant seem to find any tutorials on.Anyone want to help? Thanks. Link to comment Share on other sites More sharing options...
IKKYU Posted February 26, 2015 Author Share Posted February 26, 2015 Btw, is this some of the topics the upcoming phaser book regarding statemanager will handle? Link to comment Share on other sites More sharing options...
ZoomBox Posted February 26, 2015 Share Posted February 26, 2015 I'll not send you a tutorial but some advices:Consider having a file per class. For example: Player.js, Arrow.js, Ennemy.js…Then use states: A preloader state (the very first loading), a menu state, a GameLoad state… About levels it’s up to you to manage them. I’m personnaly working like this:A big Javascript object (or json) that contains all information that are not common between my levels (Ennemy positions, ground position, background color, background music name...).Then, once I choose a level in the menu, I start my GameLoad state which will know which level I choose and load only the necesarry ressources and it will, once finished, load my actual “Game” state which starts with a “populateLevel()” void which read the javascript big object and will place the ground ans ennemy and maybe start the right music… So basicaly (ie: tl;dr)A javascript Object/Array containing some informations which are unique to your levelAt the loading of the level, load only the ressources that will be usedOnce the game starts, populate your leven thanks to your JS big levels objects. Link to comment Share on other sites More sharing options...
IKKYU Posted February 27, 2015 Author Share Posted February 27, 2015 Well you explain pretty much what i was trying to ask, and you gave me some good new ideas, I grasp the concepts. But my problem is more on how to do that. As a beginner in programming / javascript without someone to explain i find it hard to learn how to do things like this.No books or tutorials iv'e find teach things like this. (closest i found was Rich typescript tutorial which was great and i learned alot from that. but i could not understand how to evolve it further.) That's why i asked if someone could make a tutorial explaining it. But maybe someone have an empty boilerplate project set up like this or similar way, that could teach the concepts with some comments? Thanks Link to comment Share on other sites More sharing options...
eguneys Posted February 27, 2015 Share Posted February 27, 2015 I've written a tutorial about how to manage many states for different levels here: http://www.sitepoint.com/javascript-game-programming-using-phaser/. The next thing you can do is to read source code for phaser projects. Also take a look at yeoman generators: http://yeoman.io/generators/ Link to comment Share on other sites More sharing options...
Recommended Posts