Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Vixen
20
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 30th Apr 2005 02:17 Edited at: 30th Apr 2005 02:18
How would one create 'galaga-style' movement of enemies? You know, one enemy enters the screen at a certain point and there are a bunch of others following. They move in a certain motion and then go to a position on top of the screen.

I think this explains it better:


I've got the movement of your own ship at the bottom done and it's also already possible to shoot (no collision detection because there are no enemies yet)

Help is greatly appreciated!
Thanks

Trying to help where I can [Newbie status ]
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 30th Apr 2005 03:44
Something like this?


??

My Website:
zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 30th Apr 2005 04:57
One technique is to create defined path behaviors for the enemies when they appear on screen. This will give each of the enemies a signature movement pattern. A path would simply consist of a list of steps or mini way-point coordinates. The values would be relative positions and not absolute screen locations. When an enemy appears on the map it begins at waypoint zero (offset 0,0) and then moves to the next point (i.e. -1,-2) each enemy keeps track of the next step/way point that they need to reach. This allows one, two, twenty enemy units to use the same pattern with each one having their own index to the list.

In the case of Galaga style movement, you can have several paths defined: the first wave fly by, the walkingin formation pattern, the attack pattern, etc.

Sorry, no code off the top of my head, but hopefully that design idea will point you in the right direction.
--
TAZ

"Do you think it is wise to provoke him?" "It's what I do." -- Stargate SG-1
RiiDii
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 30th Apr 2005 05:39
In addition to Taz's suggestion, you could also use various trig functions to get different curving path movements across the screen. This would save on a lot of data points, but would require a lot of testing.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
BillR
22
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 30th Apr 2005 05:57
@Nicholas - nice piece of code.

Zircher, Riidii, Nicholas - good comments all.
Gives me an idea for enhancing a project I'm working on, thanks.
Vixen
20
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Netherlands
Posted: 2nd May 2005 01:57 Edited at: 2nd May 2005 02:31
Thanks for all the comments!

As far as the code goes, I don't want it to be like that. Every enemy is supposed to follow the exact path of the one infront of him. More the way Zircher describes.

It sounds very good but how do I code this? Should I make different functions for each of the possible movements (eg a wave from left to right, top to bottom, circular movement, attack..)

I have attached the code for you to see

-- Edit:
After reading the latest newsletter I figured I could use something like:

In which 'amount' is the amount of aliens in a row, and 'movement' is the movement method (eg 1=left to right, 2= circular etc)

Sounds good to me but could someone help me a little with the coding?

Trying to help where I can [Newbie status ]

Login to post a reply

Server time is: 2025-06-20 06:09:16
Your offset time is: 2025-06-20 06:09:16