Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a assignment for school i've to develop a game in Microsoft XNA 4. Let me first clear out that my intention of this post is NOT to give me codes. I want to figure out things by my self. The intention of this post is to help me and give me advice wich design patterns may be better to apply in wich situation.

This game should use the following design patterns:

  • strategy
  • factory
  • decorator
  • singleton
  • observer
  • template

The assignment is as follow:

In this game the player should avoid the attack from his enemies who want to attack his spaceship. The enemies have their own way of attack and movement.

When the game starts the player has one cannon who can shoot bullets each 0.2 seconds. The spaceship can move horizantally with the keyboard. With the spacebar the player kan shoots bullets.

There are 3 kind of enemies who have their own attack and the way they move.

  • Chure : Moves horizantally from left to right, each time when the chure hits the edge
    he moves down and again he move horizontally but this time in the opposite direction (thus from right to left). Each chure drops at any time (random) a bomb. Each level the speed of the drop will increase.

  • Thege: Moves from the corner of the stage diagonal to the player. When the Thege hits the player, the player loose one life and starts the level again. When the Thege don't hit the player and reach the bottom of the stage he will remove from the stage and won't come back again in that level.

  • Sinode : Moves from top to bottom of the stage, when the Sinode reach the bottom of the stage hi moves the opposite direction (from bottom to top). The Sinode stays on the stage as long as the player didn't shoot him. When the player shoots the Sinode he will be remove from the stage.

Each enemie can carry an upgrade wich will be released when he will be shot by the player. either the enemie has a upgrade or not has been choosen randomly. There are three kinds of upgrades. The player can use his spaceship but once expand with each type of upgrade. If the player already has a upgrade the upgrade will remove from the stage.

The three type of upgrades are:

  • Lasers (Specs aren't important)
  • Rockets (Specs aren't important)
  • Guided missile (Specs aren't important)

some conditions to the game: - The game consists of 3 levels - Each player starts with 3 life - The level will be ended when all of the enemies are destroyed or not visible on the stage.

Now i've some ideas wich design pattern will be good by wich scenario but i would be gratefull if u guys can help me out how i can implement the factory and the observer pattern in this case and maybe help me out and give advice how i can implement the rest of the patterns.

Thank u

share|improve this question

closed as not constructive by Byte56, Sean Middleditch, Josh Petrie, Anko, Trevor Powell Apr 9 '13 at 9:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Wow, this sounds awful. Let me know how it goes, and tell me how many people don't do the assignment out of how bullshit it is. On a different note, you should use the design patterns that are specified in your list. Those seem good. – Shotgun Ninja Mar 29 '13 at 15:58
Oh, also, you should really specify the actual question of "How might I implement a Factory and Observer pattern in the context of this assignment" at the VERY START of the post, instead of the VERY END. – Shotgun Ninja Mar 29 '13 at 16:02
@ShotgunNinja im totally agree with you that the assignment is full of crap because they obligate u to use design patterns here but in some cases it isn't efficient to use design patterns at all. The Question is how can i implement the list of patterns i just listed. And in specific the Observer and the factory because i don't know how to implement them in this case. – Navid Mar 29 '13 at 16:06

Here are just some examples of how I might apply the given design patterns. This is with very little understanding of the details of the assignment, and with very little reading of the above post.

  • Strategy - Enemy movement (ie. which type of enemy).
  • Factory - Creation of enemies.
  • Decorator - Applying upgrade functionality when upgrades are equipped.
  • Singleton - NEVER USE SINGLETONS! CONSCIENTIOUSLY OBJECT! Or, use a singleton scorekeeper.
  • Observer - Enemy death notifications (protip: have the scorekeeper listen to enemy death events!)
  • Template - Baseline enemy movement code.

    Now, also keep in mind that design patterns are rather specialized for their purposes, and should NOT be a one-size-fits-all solution.

    The most important part of design patterns is being able to figure out when and how to use them on your own.

    That being said, my typical response to questions such as these would be "Figure it out on your own" and "I'm not here to do your homework for you", but since you asked for advice on specifically that, I'm going to assume the purpose of the assignment is to get you to think critically about what the design patterns are, and when to apply them. If you have to ask here, then it's either a shortcoming on your part due to inadequate research, or on your professor's part due to inadequate education on those core design patterns. Take my suggestions with this warning: Design patterns should be used with care and understanding.

  • share|improve this answer
    tnx for the advice. And the reason why i ask this question here is because i want to know how u guys looking at it, because everybody has a other solution for a problem. It is not because i'm not fully understand principle of design patterns but it's because i want the vision of some users out here. – Navid Mar 29 '13 at 16:21
    Can you expand on the singleton comment? I'm finding the singleton pattern the most sound solution for a few problems. not as in 'a good solution', more like 'the best solution' – petervaz Mar 29 '13 at 17:38

    Not the answer you're looking for? Browse other questions tagged or ask your own question.