This is nowhere near a full version of the classic game. It will get you started along the way with some game play that can be refined and improved into something more like it.
Looking at the screenshot here, there is a frog and 2x two-lane roads with vehicles on them. The code here can track whether or not you make it across the road. The rest of the game play will be up to you.
Creating The World
I have used a 10x8 tile map here, using gallery tiles for most of the area. The brown tiles across the top are the landing zone.
The other blocks in this function are there to define the vehicles to be used in the game. The second array is the same as the first, just flipped horizontally. The cars are 16x8 pixels, the lorry is 32x8 pixels.
You can do this later but may wish to do it now to see how the frog looks against the tiles you have used. Mine is a bit dodgy but can still be seen. It is 8x8 pixels.
You can test the game at this point to see if things look alright.
The first function spawns a vehicle facing the direction of your choice and at the vertical position you choose. You need to see if this works for you and adjust the numbers. If your roads aren't in the same positions as mine, you will need to change the numbers. Click to make this image larger.
This second function uses the spawn function 4 times.
The frog will jump 8 pixels at a time in the direction that the player chooses.
Road Not Safety
The cars kill the frog on contact.
Frog Makes It
Test it all and make any adjustments or corrections that you need or want to.
Challenges & Extensions
- It would be nice to see an animation of some sort for the frog jump. Playing around with the way that the frog looks when you choose to move it would add some interest to the game.
- The vehicle spawning in this version of the game is about as simple as it can be made. A little more randomness in the frequency and speed of the vehicles might make for a more interesting game.
- A larger tile map with more road sections, some of different speeds and differing densities of traffic wold be a nice way to extend the game play a little more. Some roads could be quite easy to get across but have the odd car race across to catch you out.
- You could make it so that there are specific places to get to at the end of the level. When one is occupied by a frog, you would need to land in one of the others. The way the level is designed here, that would mean crossing the road at difficult parts to reach all of the endings.
- The classic game has a whole river/log zone that is a little more involved than this basic game.
- Rethink the entire idea with a new theme and some different graphics. This game is about dodging items that spawn from the sides and reaching the other side of the zone in which they spawn. A complete rethink could make for something quite interesting.