I am quite impressed by Stencyl 3.1 image API.
Some days ago I showed you how to create a destructible terrain with this API, now it’s time to see something new, what about a String Avoider game?
I am a big fan of string avoider game, since 2007 when I released the first String Avoider prototype made with AS2. Then I made it with AS3, Starling, Corona SDK and I also made a game out of this concept: Stringy.
Now, let’s make the same thing with Stencyl.
This is what we are going to create:
Move the mouse to make the string follow it, and don’t touch the maze.
Everything will be really simple, as the prototype requires only one scene and one behavior attached to it. The scene itself has two events, Created and Drawing.
Let’s have a look at them:
This is executed once the scene is crated, I am attaching the image and initizalize variables and stuff. The behavior is fully commented, refer to the original string avoider post for a more in-depth look at the logic behind it
This is executed at each frame, and it represents the core of the game. Here we just use some trigonometry to simulate a string movement and use the image API to check for collisions
And that’s it, I would like to port it on a mobile devices to test the performances, it’s just a matter of some trigonometry operations so I think the most CPU consuming task should be the string drawing, I will let you know, meanwhile download the project file.