Thursday, February 23, 2012

How do you add continually difficult levels to a java game?

I am creating a java game for a school project, but i was wondering how to add more levels to make the game more difficult. The game is kinda like pac man :)How do you add continually difficult levels to a java game?The best way to do this would be to create variables that affect the gameplay and adjust them based on player progress. This could include game speed, number of enemies, how much health the player has etc. There's not one universal way to do this.How do you add continually difficult levels to a java game?I would implement the strategy pattern to fix your problem (See source below) Basically you need to create an interface the represents a level and program against that interface.



Now create some concrete level classes that implement your interface.Here's an example



interface ILevel

{

void MakeGhosts();

void SetSpeed();

}



class EasyLevel : ILevel

{

public void MakeGhosts()

{

//your ghost logic here

}

public void SetSpeed()

{

//increase ghost speed, ect...

}

}



Basically you can create harder and hard levels that are all referenced the same way. Another thought is to use a LevelFactory that creates levels based on parameters you pass to the factory.

No comments:

Post a Comment