Over the weekend I found a tutorial for creating an endless, Doodle Jump-like game that someone had made based on another Flash game called Winter Bells. Given that we’re trying to make Christmas-themed games for submission at the end of the month and I’ve completed my contribution to the class effort, I thought it was a good idea to follow the steps and see if this could be a basis for another game submission.
The one thing I found just reading through the steps was that it introduced a lot of new code and was explained relatively well. I actually find it slightly difficult to track down decent tutorials for making Flash games. Of course, there are a lot of them out there, but most of them seem to over-complicate what I thought was meant to be a “quick and simple” scripting language. I presumed that was why a lot of web-based game makers used Flash and why we were making our games in it – I even like using Animate just for its vector drawing and animation capabilities.
Perhaps it’s a way for game designers to “show off” their scripting skills. I found this a lot in forums for ActionScript, too; it seemed like a lot of attitude and snobbery was thrown about by the so-called “helpful replies” in most FAQ threads I read. It’s such a shame, because I really would like to access information about Flash/AS3 more easily online through forums and tutorials.
In any case, I actually found the explanations clear enough in this tutorial. The person who wrote it must have presumed an intermediate knowledge of ActionScript (which I don’t really have yet) so there were a few things I had to go off and look up myself before returning to the instructions.
Once again, while I post about this tutorial I’m not going to copy and paste the entirety of the code so I can explain each part of it – that’s what the tutorial is there for. Instead, I’ll go into the few things I did learn along the way that I think will come in extremely useful for future projects.
Creating External ActionScripts
I hadn’t really realised that you could create external scripts rather than having them all in one scene – I suppose this is similar to what Unity does when you create a script in your project. You can still access the script in your project folder, without even opening the program. Two external scripts were created during this project and I had some issues with loading them in the beginning. I was reminded to save them in the same folder the game file was in (which I accidentally didn’t do at first).
I can see the uses behind having your scripts stored externally, especially once you start coding multi-levelled, more in-depth games; the scripts and layers could get out of hand fairly quickly. This tutorial was a gentle introduction to that concept, keeping the “bell” and “bird” elements separated from the bulk of the game script. In a previous tutorial I did (the Flappy Bird one), they decided to attach the scripts the layers the items sat on. So, the wings and their script were together, the bird and its script were paired, the overall actions were on their own layer with a script, etc. However, I now think it would have been interesting to see this external script-storage method used in a game like that.
Simulating Gravity and Random Generation
I know there are ways you can call on gravity in Flash – I did it in other tutorials and I’m fairly sure it was used in our Halloween platformer’s code. However, it seems like this programmer/designer decided to simulate gravity in a different way with the bird, bells, and player. Having the bells fall down and randomly appear on the screen still seems quite complex to me and I have been told there are likely easier ways to achieve the same results, so perhaps there is still some learning to be done on this. However, now knowing how to do this, there are other uses for the same sort of script already going through my head:
- You could create a Frogger or Crossy Road sort of game, where the player can either use the objects to cross dangerous terrain or have to avoid being hit by the moving objects to reach a goal.
- Platforming or side-scrolling games with a constant scrolling screen, such as Banana Kong (an app I was recently shown) where the player has to keep moving, but avoid generated obstacles along the way.
- Of course, the obvious sort of games like Doodle Jump where reaching the highest upper level is the goal of the game, and platform jumping (like bell hopping in this tutorial) is how you do it.
Scoring and Game Over
I’ve managed to work with and inspect some scripts with scoring systems, but I’d yet to actually create anything that has a points system. I don’t know if I’m especially keen on the point generation in this tutorial – it seems like the points can get over-inflated very quickly, but I guess players love seen a very high score! It was interesting to learn about the way scoring was implemented in this game: if a player jumps on a bell, their score rises exponentially. If they run into the bird object, their score is doubled.
Much like in C#, you need to create variables in ActionScript to hold the player’s score and keep track of what numbers are being added to it:
At the end, when the player finally loses, a game over screen is called on. In this tutorial, this is actually done without needing to change frames. Instead, it uses a game over mechanic and a movieclips that pops up with the player’s final score, as well as a play again button. Adding these to the test I did was really good, since I think it’s the cleanest way to have a game stop and restart.
Randomly Generated Snow Background
I’ve kept this separate from the above mention of random generation because I think it deserves a section of its own. While I know there are plenty of tutorials out there for randomly generating shapes in Flash (I believe Ant mentioned he had one for snow, too), I like the way it’s implemented in this tutorial. Using squares between the sizes of 1px and 3px, as well as setting the alpha and shade, the game simulates a snow-fall backdrop. I just love the way it looks, even though it’s very simple. I’m sure there are many ways to utilise this same sort of script for different settings in the game ideas I mentioned above.
Final Opinion and Next Steps
This tutorial wasn’t without its faults. There were a few parts of the code that were broken, even in the previews on the tutorial’s page, and I did have to ask Ant for help fixing a very critical bug: if the main character jumped high enough and then fell, he would fall eternally and the game over screen would not pop up. The solution was simple (changing a y value in the code to a negative rather than a positive), but it was still frustrating. It did hit home the fact that tracing to output can help you debug your code and ActionScript can be messy with its maths/numbers.
However, the whole script was very well annotated and the general concept of a game can be seen clearly. What it needs next is some life injected into it and a few alterations. My next plans are as follows:
- Change the scoring system that’s used in the tutorial to something a little less exponential. For example, each square hit could be worth 20 points, rather than 20 points for the first, 40 points for the second, 80 points for the third, etc.
- Obviously toy with some graphics and design – I’m working on this with someone else for a second entry in the Christmas game project, who is far better at graphics than I am. We have the idea that Santa has fallen from his sleigh on a particularly blustery Christmas Eve. He will have to use the falling presents to get back up to his sleigh so he can continue his hard work. Every so often, one of his reindeer will fly by to help give him a boost (and extra points if Santa accepts the help).
- I would like to add some sound to the game. Some background music and sound effects as Santa jumps would be a start. Many Christmas songs are actually free to use now, so I’ll be looking into using something jolly and appropriate for the season.
Other ideas will likely crop up during the development process, but I think this tutorial has stirred a lot of inspiration already and I’m looking forward to continuing with the project!