Sign in to follow this  

Need ideas in designing classes

This topic is 4867 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 ppl, I am currently trying to built the game "chicken invaders". It is a simple game where the user has to fire bullets and kill many chickens which are coming down on him. The user moves sideways and the chickens release eggs which can kill the user. The user fires bullets . If chickens get hit, they die and a bone falls down which if taken gives the user some points. There is a special packet which falls randomly in each level. If the user can collect that, then each firing releases 2 bullets instead of one (This goes on increasing till 7 bullets per shot) I need some help with the class structure that it should have. Thanx people. Bye mishal

Share this post


Link to post
Share on other sites
You could try this:

GameArea class: The main class which contains the following other classes. It represents the entire game scene the user sees (and even things the user doesn't see, like physics calculations, score keeping, etc.)

Player class: This is kind of a given. I think you can hardly go wrong making one of these. The player could contain other encapsulated classes, such as life bars, ammo, etc. as needed.

Bullet class: Probably best if it was a member of the player class, or at least, that's how I would do it. It would contain (obviously) all the things needed for the bullet such as trajectory and speed.

Chicken class: To represent your chickens. This could contain such member data as animation frames, life, AI troutines, and whatever else you think is appropriate. The chicken class would also contain two other classes inside it:

Bone Class: To represent your bone object.
Egg Class: Similar (if not identical to) bullet class.

Score class: To keep track of the score.

Timer class: To use for all your timing needs.

That's all I can think of for now. Hope it helps to get you started.

Share this post


Link to post
Share on other sites
General tip when you have a fairly clear design idea (like what you posted).
Print it out. Circle all the nouns, these are the objects. Decide what class each object type should be. The verbs are the methods. Work out which classes have which methods. Group the objects together and look for commonality of functionality and group those together as a base class.

Share this post


Link to post
Share on other sites

This topic is 4867 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this