Snake Engine kit! (previously: Snake Movement)

Sunflower

  • Posts: 591
Someone posted in "Ask a Question" forums that they need classic Snake movement, so here it is!

This kit contains:
 - four very simple animations for head and one for body
 - simple and, on the top of that, working tile-based snake movement
 - wrapping around the screen
- dying on contact with tail
 - growing after eating fruit

I hope you can understand the general idea behind this movement by looking at the behaviors: the one for head is responsible for changing animations and creating new body parts; another, which is for body, checks how much time body should be there before it disappears.

Also, pay attention to Tiled Collision System, because default collision detection isn't used here at all! [This screen] illustrates the general idea behind this system (shortly: comparing characters rather than coordinates). If you want to use functions contained in this behavior, you must attach it to the actor! In scene initialization behavior are blocks drawing collision map, move it from "when drawing" part to make it invisible!

If you want to use default collisions, remember to turn on collision detection for proper groups, because I turned them off (they're useless here, anyway)!

Unfortunately (or rather very fortunately for snake) I haven't managed to make dying at collision with body; apparently I'm not really experienced in collisions yet, after all. ^^'

Anyway, you can find it at Forge as: Snake Engine.
If you want to make your snake longer, increase the Length attribute.
If you want for snake to wait for pauses or something, check what you can do with Wait attribute.
If you want to make snake faster, decrease the StepTime game attribute (you can change it for adding bullet time or manipulate difficulty level).

« Last Edit: July 25, 2011, 11:04:38 am by Sunflower »

SWATLLAMA

  • Posts: 1059
Awesome, Sunflower. It's perfect for a worms-type game, though I think that the snake is too big. Besides that, it can be very useful to some.

*EDIT* Though of course, I could always draw up my own actor and use the behaviors.

« Last Edit: July 24, 2011, 01:22:53 pm by SWATLLAMA »
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Sunflower

  • Posts: 591
I've added Tiled Collision System, which is based on map of characters rather than set of actors. If you don't know what I mean, [this screen] shows example of such map (so collision is based on comparing characters rather than positions, which is probably more efficient and precise enough for tile-based games).
If you want to add your actors using this system, don't forget attach it as behavior!

And no, it's not the only change here. I've also added dying on contact with tail and growing after eating fruit. Because of that you cannot find it as "Snake Movement" anymore! Now it's Snake Engine, since it's closer to complete game system rather than movement itself.

If you have any problems with my system, please contact me through forums. Any suggestions will be appreciated as well. ^^

(By the way, I'm thinking about making Tiled Collision Pack. Do you think it's a good idea? If so, what functions would you like to be added?)

SWATLLAMA

  • Posts: 1059
What do you mean by tile collision pack? Tiles that a snake can collide into to die, because if so, then you'd be better off drawing them like you would draw a tile, but classifying them as actors.
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Sunflower

  • Posts: 591
Well, by "tiled" collision I rather mean that collision checks are done for fields in a grid rather than for collision boxes themselves. When you think about this system, you should completely stop thinking about "Actors", "Tiles" et al. If you look closer at that behavior, you may see that it's based on something which is called "Collision Map". Generally, it says which object stands on which tile.

If you look closer at those functions, you will see that characters are used as arguments there rather than actors. If you run the game, you will probably see those characters at proper fields (if I remember, I haven't moved debug drawing away from there, after all ^^').

SWATLLAMA

  • Posts: 1059
I just downloaded. overall, I like it. However, there are some things that it lacks. I think the snake moves too fast. I'll compensate by making the map bigger, but it would be better if I could adjust the speed of the snake. I want to be able to choose an area where my fruit will be, but still have it be random. Look at this screenshot too.
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Greg

  • *
  • Posts: 1260
I just downloaded. overall, I like it. However, there are some things that it lacks. I think the snake moves too fast. I'll compensate by making the map bigger, but it would be better if I could adjust the speed of the snake. I want to be able to choose an area where my fruit will be, but still have it be random. Look at this screenshot too.

It looks like Sunflower has a Game Attribute called "step time" that controls the speed of the snake.  Set it to something higher to make the snake move more slowly.

SWATLLAMA

  • Posts: 1059
Gah, I need to learn about the lists and attributes and stuff someday... Okay, so then I love the kit. :))))) but still, look at the screenshot. It just looks... weird.
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Sunflower

  • Posts: 591
If you mean these numbers and letters, go to "Init" scene behavior and move the whole block out of 'when drawing". Generally, it's supposed to be there when something looks suspiciously (like, fruit appears where the snake body is) to check if collision map is working properly (since it allows you to check collision map in real time).

If you mean graphics... well, it's just an example, after all. ;) I haven't said that I'm the best graphic artist in the world.

SWATLLAMA

  • Posts: 1059
:D no, it's not just graphics :).
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Rob

  • *
  • Posts: 1268
@Sunflower, I just happened to be developing a game that will need something like this. Basically, I've 4 different actors, A, B, C and D. They are currently not stitched together. A will have some kind of random movement while there are no behaviors for B C and D. I expect A will move randomly and drag along B follow by C and then by D. Would your kit be compatible with what I am after.? I can provide more details as needed. Thanks for any help.
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title

KungFuFurby

  • *
  • Posts: 487
This reminds me of Snake Quest, which had a level editor. Me being on a Mac, I've known the application myself. ^_^
Hi, all! I'm KungFuFurby, music composer. If you're looking for some music for your game, just PM me.
My Works List for Non-Stencyl Games
My Works List for Stencyl Games

Sunflower

  • Posts: 591
I'm currently working on a renewed version for 2.0, using better about everything. In fact, looking back on the old version I'm surprised that it worked like it should before! Oh well... >.<

But yes, the new version will contain completely different collision map system (most importantly, based on a Scene behavior rather than Actor one, and based on 2D Array rather than a text) and there'll be probably some other tweaks as well! Apart from that, there won't be really much more than a moving snake and fruits collecting. Unless someone wants me to add something, hm? O.o

In the meantime, could someone make a more polished graphics for that, please? What I'd like to have is:
 - body image
 - head image (the simplest way: body with eyes), 4-direction
 - fruit image
 - perhaps some background, if you want
I guess I won't need really much apart from that. ^^'
Of course, it's not like the release of the kit would largely depend on that. I just think it'd be nice to have it all more polished. :P

Xietao

  • Posts: 725
Simple way for background: Grass
Free Time:
Monday, Wednesday, Friday: 13h
Tuesday, Thursday, Saturday, Sunday: 7h
Loving Linux...

Alucards

  • Posts: 51
at the moment 2d array problem. When i uploaded and try launch it.