Develop a Flash game like Wish Upon a Star

Yesterday I got a couple of badges playing at Wish Upon a Star, and I found the game simple and fun, as well as perfect for a brief tutorial for beginners.

Let’s see what I developed at the moment in this little prototype:

* player moves left and right with slippy controls (like in the original game until you buy grippy control)
* stars fall down at every second
* stars disappear when they leave the bottom of the state
* player can collect stars by touching their center
* stars explode with a particle effect (powered by Flint Particles) when collected

This is the main class:

This is Star class, only used to randomly place stars and assign them a random speed:

This is Player class,only used to place the player:

And this is StarExplosion class, used for the particle effect:

This is the result:

Move the player with LEFT and RIGHT arrow keys.

Download the source code. Next time, player jump and animation, and something more.

  • Another nice tutorial. Thanks Emanuele…

  • Did you know most of Wish Upon a Star is open source?

    Keep up the good work.

  • player_03

    I glanced at your player class and concluded you don’t have a good grasp of what classes should be used for. It ought to take input and handle movement, at the very least.

    It had been pointed out that you’re relying on the keyboard auto-repeat function. Sure enough, acceleration follows the “one press, pause, more presses” pattern, and if you press ANY other key while holding the movement key, you stop moving.
    From this, I deduced that either you didn’t know how to handle input, or you just didn’t care. Neither option helps your case, given your stated goal is to teach people.

    Then I moved to a different tab for a while, and when I came back, the game was absolutely full of stars and starting to lag. I looked back at your code, and sure enough, you’re using a Timer to place the stars.
    Don’t you know better? Or aren’t you aware that the framerate drops to 2 fps when the SWF is offscreen, but Timers keep going?

    I used to assume that you made good tutorials and wrote good code, based on the fact that lots of people link to you. Apparently those weren’t safe assumptions.

    Ok, maybe you were in a hurry when you made this, and you spent more time on other tutorials, but that doesn’t help.
    The errors you made here were really basic; if you’d been familiar with good coding style, you could have avoided all three without spending any more time on the project. Plus, the code structure would have been easier to understand, meaning this would have been a better tutorial overall.

    I was going to conclude by saying that CuriousGaming’s code would make a better tutorial, but I checked and that’s not true. Instead, I’ll just say that I’m not planning on referring anyone to your blog any time soon.

    (Ok, time to stop being a jerk.)

  • Pingback: Cool Stuff with the Flash Platform – 12/1/2011 | Hire Flash Developers()

  • yzxwml

    thank you

  • Richard Wentz

    Please disregard player_03’s non-constructive feedback. Clearly being a superior programmer, and having written so many tutorials player_03 no longer has need of the great work that you do, and how much help you have been to complete newbies who have ZERO working knowledge of programming but are taking baby steps by using your blog and the tutorials you write. Yes, it’s a run-on sentence, and yes, it’s sarcasm (in case player_03 couldn’t tell).

    You’re doing great work, keep it up, and thank you!

  • Richard Wentz

    btw, player_03, where is your tutorial blog? What are you contributing to others with less skill and expertise as you? Besides donor tissue, that is?

  • ..jayson

    ..,nice game..

    //”i’ve learn..//

    but where will i run the code?

  • player_03

    Just because my feedback wasn’t positive doesn’t mean it wasn’t constructive. Yes, I complained, but my complaints were entirely valid and fairly important. The issues I mentioned would either annoy players (key repeat, Timers) or would make it hard to expand on this tutorial (poor code structure, lack of explanation).
    I stand by everything I said above. Feel free to debate the points I made, but don’t brush them off.

    As for how I contribute: I am a regular on the Kongregate programming forums. When I have time, I respond to users of all skill levels, carefully explaining how to implement features or why code isn’t working. I try to avoid just giving them the solution, instead explaining the problem well enough that they can solve it themselves. (For the record: this does work.)

    My goal, of course, is to help people reach the point that they can program games on their own, without relying on me, or Emanuele, or anyone else. This is why I put such heavy emphasis on understanding what’s going on.

    Yes, people can copy the code from a tutorial like this, but that doesn’t mean they understand what’s going on. And as it happens, this is one of the more common reasons for someone to post on Kongregate asking for help: they don’t understand the code they’ve got, so they don’t know how to go about expanding on it.

    One last thing: note that I did not once attack your character in this post. I addressed your arguments, but I did not insinuate anything about your programming skill, intelligence, or usefulness to humanity. I would appreciate the same from you, even if you don’t like me or agree with me.