SHMUP Snake Algorithm in GML (Game Maker 7)
SHMUP Snake Algorithm in GML (Game Maker 7)
A very rudimentary but versatile SHMUP snake algorithm in GML. Now you can create your own snake enemies like those found in so many SHMUPS.
In the room, the "head" of the snake is placed, with creation code to set the snake's length and the gap between each body segment.
The snake follows your mouse cursor.
This algorithm can be adapted for Gradius-style Option movement.
This algorithm is parameter-based, getting its information from creation code, to allow customization.
Examples:
Snakes can be of any length...
...and of any follow distance between segments.
R-Type Outslay examples (bodylength = 32, stepdelay = 12):
Download the GMK source for the algorithm here: http://www.sendspace.com/file/sa7m2m
In the room, the "head" of the snake is placed, with creation code to set the snake's length and the gap between each body segment.
The snake follows your mouse cursor.
This algorithm can be adapted for Gradius-style Option movement.
This algorithm is parameter-based, getting its information from creation code, to allow customization.
Examples:
Snakes can be of any length...
...and of any follow distance between segments.
R-Type Outslay examples (bodylength = 32, stepdelay = 12):
Download the GMK source for the algorithm here: http://www.sendspace.com/file/sa7m2m
The age of Alluro and JudgeSpear is over.
-
Pixel_Outlaw
- Posts: 2636
- Joined: Sun Mar 26, 2006 3:27 am
I don't have Game Maker but I assume you simply move then update all of the sections to the head's previous x and y position? That is how the Gradius options work. You might also look into Bezer curve paths, those were too used extensively and are still used.
Some of the best shmups don't actually end in a vowel.
No, this game is not Space Invaders.
No, this game is not Space Invaders.
-
worstplayer
- Posts: 861
- Joined: Sun Jun 17, 2007 6:48 pm
- Location: Slovakia
It works and looks nice. Btw the way it works is perfect opposite of my snake. In yours, head moves segments following it, in mine, every segment has "owner" variable and it simply moves towards owner's position (it basically updates backwards).
You don't need queues this way and you can have some nice sequential explosions (segment is destroyed after it loses owner).
But yours is better in that it can be also used for trains (it follows the path of head exactly).
You don't need queues this way and you can have some nice sequential explosions (segment is destroyed after it loses owner).
But yours is better in that it can be also used for trains (it follows the path of head exactly).
"A game isn't bad because you resent it. A game is bad because it's shitty."
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
Whoa! Looks awesome! This will require some studying for sure.
I've only done the much more lazy (but still effective) kind that uses a single preset movement pattern with a time-delay between the creation of each segment. The one time I tried something fancier, it failed miserably. Considering that was back in 2009, I might be able to pull something better off now.
(I did figure out how to do those cool delayed explosions regardless of how the segments move, though.)
I've only done the much more lazy (but still effective) kind that uses a single preset movement pattern with a time-delay between the creation of each segment. The one time I tried something fancier, it failed miserably. Considering that was back in 2009, I might be able to pull something better off now.
(I did figure out how to do those cool delayed explosions regardless of how the segments move, though.)
-
BPzeBanshee
- Posts: 4859
- Joined: Sun Feb 08, 2009 3:59 am
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
I tried finding this among all of my old archived crap that spans across two computers and various hard drives but couldn't find it. I think my old external hard drive may have it, I'll go and check.
EDIT: Found it and uploaded it:
http://www.mediafire.com/?3pahpgxsu6szamn
It also has a script in there for turning towards an object, I wonder how well it does compared to what S20-TBL provided me for GMOSSE's homing missile objects that can lock on to another enemy if it's already gone.
EDIT: Found it and uploaded it:
http://www.mediafire.com/?3pahpgxsu6szamn
It also has a script in there for turning towards an object, I wonder how well it does compared to what S20-TBL provided me for GMOSSE's homing missile objects that can lock on to another enemy if it's already gone.
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
Thanks, did my own version but this look much better!
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
Thanks much for bumping this as this is perfect for me. Thanks also, of course, to Alluro for making it and BPzeBanshee for reuploading.
IGMO - Poorly emulated, never beaten.
Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
Hi-score thread: http://shmups.system11.org/viewtopic.php?f=2&t=34327
-
- Posts: 6
- Joined: Tue Nov 30, 2010 3:41 am
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
I've been looking for this alg for a while... but I don't have Game Maker, so can anyone paste the code/alg here please?
-
BPzeBanshee
- Posts: 4859
- Joined: Sun Feb 08, 2009 3:59 am
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
If you don't have Game Maker, get it. It's worth your while.vonWolfehaus wrote:I've been looking for this alg for a while... but I don't have Game Maker, so can anyone paste the code/alg here please?
As for the code itself it's in various parts for events throughout a few objects and even some code that for some reason my copy of Game Maker won't let me access (probably outdated, 8.0 as opposed to 8.1). Not that easy to "paste the code/alg here" unless Alluro wants to do it.
There's also that other alternative that was coded in Java that lets you open Game Maker files but I forgot what it was called and couldn't find it via Google without a specific name. One of the forum members here has it in their signature.
-
- Posts: 6
- Joined: Tue Nov 30, 2010 3:41 am
Re: SHMUP Snake Algorithm in GML (Game Maker 7)
I need a bit more control so I use Flash I found the algorithm (written in C# so it's fairly clear what's happening), which I'll post here for anyone else interested:
This assumes we have an array of Vector2 "chain link" positions "Vector2[] p". Also assumed is that we want each "chain link" to be a distance of 5 away from it's adjacent "chain links." The part I was missing was normalizing the difference vector. For Flash this is a fairly expensive operation (square roots are done to normalize the vector), but it's worth it for, say, a boss. Can't use it for fodder paths, so I'll have to figure that out later
Code: Select all
p[0] += dt * velocity;
//if you want the rotation of the "head", do this
float headRotation = (float)Math.Atan2(velocity.Y, velocity.X);
for (int i = 1; i < p.Length; i++) {
Vector2 diff = p[i] - p[i - 1]; //vector pointing from p[i - 1] to p[i]
diff.Normalize();
p[i] = p[i - 1] + 5 * diff;
//if you want the rotation of this "chain link", do this
float rotation = (float)Math.Atan2(diff.Y, diff.X);
}