Heppell08 Posted January 30, 2014 Share Posted January 30, 2014 I thought about this and wondered if global variables were able to be placed in an if() so that they would be loaded if a specified game selection was made. My other though was basically creating each game numerous times but with the difficulty varying per each created game. I'm totally not sure how to go about difficulty selection but any ideas on this would be well worth the knowledge. Thanks Link to comment Share on other sites More sharing options...
grimor Posted January 30, 2014 Share Posted January 30, 2014 Maybe creating class Difficulty containing some global variables defining enemy HP, speed, things like that, and then use them in Enemy class or something That's my idea for that For example you can create object when user change difficulty in game var hard = new Difficulty('hard');game.difficulty = hard;then in Enemy Class for examplefunction Enemy() { this.health = game.difficulty.hp; this.speed = game.difficulty.speed;}etc.You can also make something like this for pathfinding, where game.difficulty.pathfindingMethod is method with pathfinding algoritihm.function Enemy() { this.pathfind = game.difficulty.pathfindingMethod}That's my loose ideas for that Link to comment Share on other sites More sharing options...
Heppell08 Posted January 30, 2014 Author Share Posted January 30, 2014 I actually think your idea will work! I'll have a look at doing it like that now! Link to comment Share on other sites More sharing options...
Heppell08 Posted February 4, 2014 Author Share Posted February 4, 2014 Is there a way to go across states with changing the difficulty? I want to make the game difficulty from the main menu with a button press. I've tried putting var difficulty = 1; Then in main menu i have a button function that changes the state to the game. I tried to put: this.game.difficulty = 10; But all i get is an undefined error and the difficulty stays at 1. Any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts