gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > enemy placement

#75746 - ion - Wed Mar 15, 2006 6:03 pm

Hi all,

I've just got a couple of questions. I'm writing a 2D side scroller ala R-Type. It's very basic. I'm just working on one level. I'm not sure where to start regarding enemy placement.

Q1. How would I place and move enemies in a wave formation like so many other shooting games.

Q2. How would time when the enemies appear on screen?

And finally:
Q3. What methods can I use to detect collision between
A) ship-enemy
B) enemy-bullet

Bear in mind that there will probably be at most 4 or 5 enemies on screen at the one time. I might code in bullets for them as well.

Thanks in advance.
ION

#75805 - tepples - Thu Mar 16, 2006 4:15 am

ion wrote:
Q1. How would I place and move enemies in a wave formation like so many other shooting games.

Study BulletML for a while and you may realize how to describe motions of enemies and their bullets.

Quote:
Q2. How would time when the enemies appear on screen?

For each enemy, store a starting position. When the right side of the playfield scroll position reaches the enemy's starting position, spawn the enemy.


Quote:
And finally:
Q3. What methods can I use to detect collision between
A) ship-enemy
B) enemy-bullet

Search for "bounding" on this forum for help.

Quote:
Bear in mind that there will probably be at most 4 or 5 enemies on screen at the one time. I might code in bullets for them as well.

Then you'll want to know the sorting method so that you don't make unnecessary comparisons.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#75813 - gauauu - Thu Mar 16, 2006 4:32 am

Although, depending on the number of bullets, with only 4 or 5 ships on screen, the comparisons will be pretty small, and sorting may not be an issue.

#75832 - ion - Thu Mar 16, 2006 11:10 am

BulletML? I'll have a look.

If I wanted set formation is there some way I could use SINE wave array of values to determin relative postions from a starting point..
e.g the cross represents the enemy moving a wave formation.
Code:

+      +
  +  +  +
    +     +


If I could how would I go about creating and using the array?

Regarding collision I was considering basic brute force bounding box checks for starters. If I've time I would like to implement something like
+ divide screen into four quadrants
+ each quadrant points to a link list that enemies are dynamically added
+ to check against certain enemies all I have to do is check which quadrant the ship is in then check against that list.
+ or is this overkill?

Thanks in advance,
ION

#75855 - tepples - Thu Mar 16, 2006 4:36 pm

ion wrote:
Regarding collision I was considering basic brute force bounding box checks for starters. If I've time I would like to implement something like
+ divide screen into four quadrants
+ each quadrant points to a link list that enemies are dynamically added
+ to check against certain enemies all I have to do is check which quadrant the ship is in then check against that list.
+ or is this overkill?

That's called the sector method.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.