Create a terrain like the one in Tiny Wings with Flash and Box2D – adding more bumps

I want to show you an improved version of the Tiny Wings terrain you’ve already seen at Create a terrain like the one in Tiny Wings with Flash and Box2D – adding textures.

This time hills have more bumps and are more irregular, getting a little closer to the original look and feel.

I also placed a sphere you can drive with left and right arrow keys to move along the terrain, and my movieMonitor to show you the performance.

Move the ball with LEFT and RIGHT arrows.

This is the source code:

No need to download anything, simply copy and paste in any Tiny Wings source code you’ll find around the blog.

Net time, I’ll try to texture the hills with something decent.

  • The irregular hills are very cool, and look very nice.

    On a similar note:
    I was just playing one of those motorcycle games last night, where you try to keep it from flipping over and hitting the rider on the head as you try to get to the end of the level.

    Any idea how these games create their terrain? They’ve obviously been created by hand (vs programatically), but I’m not sure how they would draw it out, store the series of points, and create “solid” objects from it?

  • @Chris, yeah, I tried to make a similar game, but I don’t want a random generated terrain. As I’m not so familiar with box2D I gave up any attempts.. :/

  • Awesome effect, this tutorial series is really starting to come together!

  • Rick

    Is AS3 Box2D not ready for iOS? I took your above code and simply set right=true (so it would start to run) and commented out the performance meter.

    It was very choppy on my iPad2

  • Emanuele Feronato

    It’s not Box2D itself, probably it’s the debug draw and its transparences.

  • Julian

    @Rick of cause it is. Check out Haxe (haxe.org) to compile as3 into a native iOS app. It runs very smooth then on android, iOS and webos.

  • Scott

    @Chris Im not sure exactly how to make the bike part of it. But youtube AS3 sidescroller devnote has a good tut on this. So once you have this you would have to make the bike part. Which would not have be the same as the player. Each wheel would have to have controll.

  • it’s Awesome, thanks again Emanuele

  • Awesome, thanks Scott!

    It makes sense that a per-pixel test would probably be most straightforward, and actually work ;)

    I’ll have to test out if it is fast enough for what I need :D

  • Scott

    yeah if you figure out how to do the bike part, let me know please :) because thats the only part im confused on.

  • Law

    This is very cool. Thanks for your hard work

  • Scott

    Emanuel whats next for this series?

  • It’s better to use “isEdge” property of b2Body (or something), there are just 2 points, no polygons. It is much faster then. I used it here http://www.ivank.net/clients/moto/ (little demo of motorbike)

  • pWEN

    What version of Box2D is this? I don’t seem to have an .ApplyTorque() function.

  • Papa

    Unfortunately the boris version of box2d has a nasty b2vec2 memory leak. The levels can’t be gigantic because of that.

  • Jashen

    Hi, me too I find it unfortunate about the memory leak problem!
    Does anyone have a solution for that?

  • Cody

    How do you generate just the terrain constantly without the sphere? Constantly moving left

  • Pingback: Aymeric Lamboley » Create a game like Tiny Wings()

  • alex

    How did you move your Sphere sprite, I can only see the code below:
    if (left) {
    theSphere.ApplyTorque(-0.5);
    }
    if (right) {
    theSphere.ApplyTorque(0.5);
    }