Monday, February 17, 2014

Game: Flappy Dragon

Okay, I know we have one platformer on standby while we started a new platformer -- but today we're going to work on a quick project anyway.  :)

In this project we will be creating a variation on the "Flappy Bird" theme.

Let's start with the MyWorld code which [of course] is a subclass of World:


import greenfoot.*;

public class MyWorld extends World
{
    String[] map = { "lllllllllllllllllllllllll",
                     "t                     s  ",
                     "                         ",
                     "         d               ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                       e ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "                         ",
                     "b                        ",
                     "lllllllllllllllllllllllll" };
                     
    public MyWorld()
    {    
        super(800, 608, 1, false); 
        prepare();
    }

    private void prepare()
    {

        for (int i=0; i<map.length; i++) for (int j=0; j<map[i].length(); j++)

            {
            int kind = "dlsebt".indexOf(""+map[i].charAt(j));
            if (kind < 0) continue;
            Actor actor = null;
            if (kind == 0) actor = new Dragon();
            if (kind == 1) actor = new Laser();
            if (kind == 2) actor = new Score();
            if (kind == 3) actor = new Entrance();
            if (kind == 4) actor = new BottomTower();
            if (kind == 5) actor = new TopTower();
            addObject(actor, 16+j*32, 16+i*32);
        }
    }
}

You'll notice that I utilized the same text-based map creator and that we'll be needing Dragon, a Laser, a Score, an Entrance, a BottomTower, and a TopTower.

Here are some images to get you started, but I would like you to come up with your own sprites after we have the basic game set up.  Then you can decide how you will make your game unique.

No comments:

Post a Comment