Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Swoosh - A simple asteroid dodging game

edited January 2012 in Code Sharing Posts: 5

Here's my first, simple game using the Tyrian sprites(and of course a bit of Bortels font code). Just dodge the asteroids and pick up gems.


Copy-paste-friendly, one-giant-page version here:

It still needs a lot of polish, but I've got a few questions and I could always use some feedback on the code. So, on to the most pressing question:

When I play sounds I seem to get som lag/frame-skipping. Is it fixable?


  • SimeonSimeon Admin Mod
    Posts: 5,716

    Wow @Drablos, that's a great looking project.

    I believe the sound lag issue is fixed in 1.3 (as long as you use a fixed random seed for your sounds). At the moment Codea generates the sound effect each time, in 1.3 it uses a cache for sounds that have been generated in the past.

  • edited January 2012 Posts: 5

    Thanks! Now that is exciting news. Then perhaps I'll be able to add the titular "swoosh" when passing close by asteroids as initially planned.

    Though in theory I thought calculating movement based on DeltaTime should result in pretty smooth animation regardless of the slight sound lag, but apparently not? Or maybe it's just too easily noticeable in this kind of game.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    Are you on iPad 1 or 2? The delay due to sound() is more noticeable on iPad 1 because of how expensive it is to compute the sound.

  • edited January 2012 Posts: 5

    On iPad 2 myself, but then again the sound lag on picking up gems is not all that bad, as I guess you kind of expect something to happen when you pick it up something.

    In 1.3, will we be able to "pre-cache" sounds without playing them? Say, to move the lag to the loading when framerate doesn't matter all that much. Started thinking about background music as well, but I guess at that point I should probably move on to Objective-C anyway. :)

  • Posts: 1,255

    That's great, @Drablos. I love the tilt control, and the thoughtful touches like the moment of safety when starting a new ship. Very nice.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    We'll see after 1.3. If you try it out and feel it's still necessary to pre-cache them, perhaps we can add it. Or we can add the ability to play them at 0 volume, essentially just caching them.

  • Posts: 384

    Hi @Drablos, I enjoyed your game and got 300 points! :)

    I have found with sounds that using DeltaTime will keep your object moving at the right speed, but it still will jerk across the screen during periods of high processing. This is because it has to skip some frames rather than play each one and slow down. So without using DeltaTime the object will be smoothly animated,but will sloooooow down during high processing.

    @Simeon, just on the forthcoming sound API, perhaps I didn't see it, but I can't find an explicit volume control for sfxr. I did simulate volume with some changing of enevlopes etc, but wondered if that was something extra you would need to add?

  • Posts: 622

    Very nice

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @Fred you're correct. I was actually thinking of adding a separate volume parameter to sound() in both modes that controls the OpenAL buffer gain.

  • Posts: 384

    @Simeon, a capital idea, I shall add it to the issue tracker.

  • When you die and at the ending when it says "game over; your score:..." How do you leave out of the game

  • Posts: 355

    he use displayMode(FULLSCREEN_NO_BUTTONS)

    if you use air code , u cant leve the game @Iruizlopez137

  • Posts: 1,976

    Triple-tap with three fingers to exit FULLSCREEN_NO_BUTTONS.

Sign In or Register to comment.