![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Programming tutorials All Knowledge Info and links to posted here |
![]() |
|
creating a space shooter using OOD - need help defining my objects.
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
I need help with the object planning. I'll explain my game and how I started dividing it into objects. I am a bit new with this stuff, so my approach maybe totally wrong. hero - The hero is a spaceship that is controlled by keyboard. it can move left, right, and shoot. enemies - there are several types of enemies that have different behaviours: they look differently, they move differently, they shoot different projectiles. each stage contains several enemy waves, that are launched by timer events. when all timers events occur (all enemies have attacked), we advance to the next stage. what I've done so far is created a basic enemy class that has 3 methods: fly ,checks if out of bounds , shoot .I've created a few enemy classes that inherit from that basic class, and have different fly and shoot methods. the different projectiles should be implemented in a similar way. the hero ship is currently not inside a class. it's in the main loop: it listens to user input and moves or shoots accordingly. it also check collisions with the enemies my problem starts with the collision detection: which object should check it? the projectile? the ship? or maybe some collision manager? and if there was a collision, the main loop should be notified about it, and reload the stage. how does these object communicate? from what I understand they shouldn't know about each other at all. I'm very confused with this. I think I have to start from the beginning and plan it from scratch. Does someone has experience with a case like this? |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
I would setup a game loop where you process the game state. While game_not_over process pending enemy action - such as fire projectile, or next animation frame, or die process pending hero action - such as fire projectile, or next animation frame, or die draw game board (background, hero ship, enemy ships) Loop Inside of this loop, one of the things you can do is have the Projectile object ask the Game if it is overlapping the hero ship or one of the enemy ships? If so, then decrease health of said ship, or set the death boolean (the next time the Game State is updated, the ship will explode). What makes this work is the game loop is processed thousands of time per second...so it seems like a real time continuous flowing game. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|