Jack Veech's Donkey Kong Project

How to play

How Did I do it?

To start, I used a program called Greenfoot. In Greenfoot, I used the Java programming language to create my game. I personally found it very helpful to always have the option to test my current code with a window in which I can view my game - it meant I could always test and refine.


The game had many beta versions, and took around 3 weeks to make. I learned everything I did and got as far as I did with my project thanks to Mr. Swaine, BCSP leader and extraordinary Computer Science teacher at BSS. 

What took a lot of time was creating the falling code. For example, when the barrels roll along their designated path, that is part of the falling code. Essentially, the barrels are always trying to fall; however they were coded to detect the brick under them and not fall (which would be straight through the brick).

Sprites

Mario, the barrels, donkey kong, and a lot of the elements in my game came from sprites!

There are many sprites websites out there on the interwebs, including sprite sheets! I used multiple sprite websites to create my game. For example, I took Mario from one website (especially with the animations), and then took donkey kong from another. It's all about finding the best stuff!

Enemies

The main enemy in the game is the barrel. The barrels spawn near Donkey Kong at a random rate and when touching the player make you lose a life. The barrels move at around 4px/second and change direction when they touch a wall. 

The barrels also have their own falling code for when they fall from each "floor."

A less common enemy in the game is the fireball. The fireball spawns twice in level two and twice in level three. These enemies result in instant death and restart of the game. The fireballs are the harshest enemies in the game. They move left and right and move relatively slowly (around a rate of 2px/second).

Code Example

public void checkKeys() 


    {

        //Simple controls

        if(getX() >= 20)

        {

//Checks if the user wants to move right

            if (Greenfoot.isKeyDown("left")) 

            {

                setLocation(getX() - 2, getY());

//Since Mario has different animations for if he has the hammer or not, it's important to make sure Mario doesn't have the hammer

                if (gotHammer == false)

                {

                    setImage("SmallMarioLeft.png");

                }

            }

            else 

//If Mario is moving up the ladder we set the location to be moving up. 

            if (Greenfoot.isKeyDown("up") && isLadder() == true)

            {

                setLocation(getX(), getY() - 2);

            }

//This is the same thing except for down.

            else if (Greenfoot.isKeyDown("down") && isLadder() == true)

            {

                setLocation(getX(), getY() + 2);

            }

            //This bit of code is for jumping

            if (Greenfoot.isKeyDown("space") && onGround() == true && r.millisElapsed() > 500)

            {

                jump();

                r.mark();

            }


        }

//Code for moving right.

        if (Greenfoot.isKeyDown("right")) 

        {

            setLocation(getX() + 2, getY());

            if (gotHammer == false)

                {

                    setImage("SmallMario.png");

                }

        }

    }

What Skills I Learned