Snake Mechanic Demo

Photon

  • Posts: 2691
Hey all. Thought I'd share what I've been working on lately...

http://www.stencyl.com/game/play/23835

It uses a fleshed-out version of my Basic Grid Movement behavior alongside the Tile API and my 2D List extension. It's not perfect, like when you spawn a piece while moving, but that's mostly because its a work in progress and the "use enter key to add piece" thing is temporary and won't be in the final game. And yes, I'm aware the screen size is messed up. I'm not quite sure what the deal is but I haven't done much research on it yet.

And NO. I am not making a generic snake clone. What is it for then, you ask? Let's just say the current idea involves acquiring explosive body pieces for later and forceful exhalation. ;)
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

colburt187

  • *
  • Posts: 2416
thats really cool, awesome watching them all moving in sync like that. Could also be a puzzle game in there, i finally got stuck when i went round the square roundabout thing and hit my own tail.

csharporbflat

  • Posts: 97
How did you get it to move like that , where each piece follows the precise path of the other piece in front of it

Photon

  • Posts: 2691
Its been awhile since I've touched this, but feel free to download the attached .stencyl file and it give it a go.

The grid-based movement follows the same methods used as seen on my blog's tutorial. As for setting paths, its basically a matter of each piece, barring the head, getting the location of the piece in front of it prior to any current movement (I think that's why you see "Old X" and "Old Y" values in there) and then moving into those positions.

Oh, you'll also need my 2D List Extension for it to work right and transfer some blocks appropriately.

« Last Edit: May 26, 2014, 09:48:10 am by Photon »
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

csharporbflat

  • Posts: 97
thanks for this.

Could I assume that since your actors are 16x16px and your tile set is 16x16px, If I wanted your code to work with say a tileset of 32x32. Then I assume I would just go through all of the blocks and change wherever it says a x16 to a x32, and it should work?

Photon

  • Posts: 2691
That sounds about right, within reason of course, granted that I don't know exactly what you are trying to do with the game. But in terms of basic movement, that sounds about right. :)

Been awhile so I'm not going to try and pinpoint everything, but notice that the system also uses a custom collision system. Nothing too heavy; it basically checks to see if a tile is at the position the head wants to move into. Traditional collisions don't work with the movement scheme I have going (set-x/y blocks.)
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

csharporbflat

  • Posts: 97
Yes you actually have those variables all over. I'm thinking about setting a global attribute for that variable so it could be changed on the fly if the variable changes. Also based on your collision system, I was wondering if the movement can continue in the direction of the arrow press until the parent actor collides with a tile, or another actor, or another direction key is pressed. Probably just needs to be tweaked a little. or I need to add a velocity and have an update condition that checks the 2d array map every n seconds where n is the speed divided by distance of tiles in width/height.  or maybe its the other way around, it would be distance/speed, because if the guy is traveling at a speed of 50, and the tile size is 24, that should take 2.1 seconds to get to the next tile, or maybe I don't have a good understanding of how velocity translates into pixels in stencly.

If you have any thoughts on this it would be appreciated, basically, lead actor, we will call that your dragon square for now. I would like 3 detections, if it hits a tile, something happens, if it hits another actor of type whatever, something happens, or if a user presses a different key it changes directions.

What I am working on is a combination of a train simulator and a tower defense game. I know it sounds crazy, but I think I have a good idea. Obviously your script comes in handy as train cars will need to attach to each other, and the dragon head gets replaced with a locomotive.

BenVader

  • Posts: 22
Its been awhile since I've touched this, but feel free to download the attached .stencyl file and it give it a go.

The grid-based movement follows the same methods used as seen on my blog's tutorial. As for setting paths, its basically a matter of each piece, barring the head, getting the location of the piece in front of it prior to any current movement (I think that's why you see "Old X" and "Old Y" values in there) and then moving into those positions.

Oh, you'll also need my 2D List Extension for it to work right and transfer some blocks appropriately.

Any chance of getting a link to this blog post? also do you do video guides?