Jump to content
  • Advertisement
Sign in to follow this  
Martin47

Arcade-Shooter game code design

This topic is 2151 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone. I have started to work on arcade-shooter game for android and i found that i have problem with code design. Take this example.There is 1 level with lot of different enemies. So i ve got interface, one general enemy and many enemies which extends general enemy. Should i define AI inside general enemy or make it as a new object? And what about level design how should i define when and how many enemies start to move or doing something...  So my question is: is there any official design pattern, framework etc. for arcade games? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Separating classes for AI (controllers that can "drive" any kind of enemy) and enemies (flying things that offer the AI a set of inputs and commands) should be the best choice in most cases: - Separation of concerns makes code easier to work with in general. - It allows you to consolidate enemy classes and adopt a data-driven design: defining an enemy type doesn't require a new class, you only need to specify a sprite and an AI module for use by a generic Enemy class. - In turn, using only one Enemy class avoids unnecessary polymorphism overhead. - It allows easy replacement of AI, even in live enemies, facilitating experiments, variations and complex behaviour without undue complication of the Enemy classes. - It helps with uniform treatment of player-controlled and AI-controlled ships, without unwanted duplications and asymmetries.

Share this post


Link to post
Share on other sites

You should isolate Enemy and AI separably. There might be cases where you have some sprites that does not move and some that do.

 

You could make AI an interface. Instead of calling it AI, you could call it Movable.

 

In Java, it would be like this:

 

public class Enemy implements Movable

{

 

}

 

public interface Movable

{

 

public void move(int x, int y)

{

 

}

 

}

 

You could make AI a separate object too. See which one of the two design fits better.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!