shmups.system11.org

Shmups Forum
 
* FAQ    * Search
 * Register  * Login 
It is currently Thu Jan 17, 2019 12:56 pm View unanswered posts
View active topics



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Mon Dec 15, 2008 6:44 pm 



Joined: 26 Jan 2005
Posts: 778
Location: San Diego, CA, USA
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:

Image
Snakes can be of any length...

Image
...and of any follow distance between segments.

R-Type Outslay examples (bodylength = 32, stepdelay = 12):
ImageImage

Download the GMK source for the algorithm here: http://www.sendspace.com/file/sa7m2m
_________________
Thanks for the memories, shmups community!
2002-2014


Top
 Offline Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2008 7:13 pm 


User avatar

Joined: 26 Mar 2006
Posts: 2607
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.


Top
 Offline Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2008 9:49 am 


User avatar

Joined: 17 Jun 2007
Posts: 861
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).
_________________
"A game isn't bad because you resent it. A game is bad because it's shitty."


Top
 Offline Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2008 2:11 pm 



Joined: 16 Nov 2007
Posts: 655
Location: France
Nice.


Top
 Offline Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2008 9:50 pm 



Joined: 02 Dec 2008
Posts: 592
thanks much for sharing


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Wed Jun 08, 2011 9:03 am 



Joined: 08 Jun 2011
Posts: 6
Does anyone have this file?
_________________
http://www.apgames.se/


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Sat Jun 11, 2011 4:27 am 


User avatar

Joined: 11 Feb 2009
Posts: 918
Location: Southeast USA
Whoa! Looks awesome! :shock: 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.)
_________________
Fire Arrow Plus is out on Steam!
Itch.io page - Gamedev blog


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Sat Jun 11, 2011 4:58 am 


User avatar

Joined: 08 Feb 2009
Posts: 4828
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.
_________________
Projects: G.M.O.S.S.E / Warbird A13:02 / Zenohell / XII STAG Hi-Score Thread


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Sat Jun 11, 2011 7:05 pm 



Joined: 08 Jun 2011
Posts: 6
Thanks, did my own version but this look much better!
_________________
http://www.apgames.se/


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Wed Jun 15, 2011 1:29 am 


Banned User
User avatar

Joined: 07 Feb 2010
Posts: 2116
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: viewtopic.php?f=2&t=34327


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Thu Jul 07, 2011 10:27 pm 



Joined: 30 Nov 2010
Posts: 6
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?


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Fri Jul 08, 2011 5:00 am 


User avatar

Joined: 08 Feb 2009
Posts: 4828
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?

If you don't have Game Maker, get it. It's worth your while. ;)

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.
_________________
Projects: G.M.O.S.S.E / Warbird A13:02 / Zenohell / XII STAG Hi-Score Thread


Top
 Offline Profile  
 
 Post subject: Re: SHMUP Snake Algorithm in GML (Game Maker 7)
PostPosted: Fri Jul 08, 2011 7:14 am 



Joined: 30 Nov 2010
Posts: 6
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:

Code:
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);
}

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 :(


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Space Pilot 3K template by Jakob Persson
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group