Lukket

Building a Game

We look at a square, tiled section of the Antarctic world with a fixed side length of 41. In Antarctica, the tiles are represented by a two-dimensional array of animals, with a zero value for an empty field. The world is cyclic, i.e. if an animal runs out of the world to the left, it is placed on the field furthest to the right of the corresponding line (and vice versa). The same applies to the top and bottom.

The coordinate system of the world behaves in such a way that tiles with y-value 0 are at the top, and higher y-values at the bottom.

Animals are instances of a subclass of the abstract class Animal. They have an alive attribute that ensures that they are drawn. Dead animals are not drawn.

For each animal a method public boolean canEat(Animal animal) is already implemented in the template, which returns whether this animal can eat any other animal, according to the hierarchy shown above (arrows indicate that this species eats another animal, e.g. the whale eats penguins). However, this method still requires implementations of the following methods in each of Animal's subclasses:

protected abstract boolean eatenBy(Penguin penguin);

protected abstract boolean eatenBy(PlayerPenguin playerPenguin);

protected abstract boolean eatenBy(Whale whale);

protected abstract boolean eatenBy(LeopardSeal leopardSeal);

protected abstract boolean eatenBy(Fish fish);

Whereby these methods do NOT check whether the animals are on neighbouring fields, but only whether it comes according to the hierarchy to the food.

Movement of animals

Depending on the species, the animals have similar movement patterns. Basically, the animals have the following movement preferences:

Fish: 1. above, 2. right, 3. below, 4. left

All other species (Penguin, LeopardSeal, Whale): 1. left, 2. up, 3. right, 4. down

First the animals check the adjacent fields in the order indicated whether there is food there. If this is the case, they move to the first such field for which the move is allowed. If you cannot move to any field with food, move to the first allowed field (also in the order given).

Moves to a field with another animal that cannot be eaten by the moving animal are not allowed. Animals also never move to a field where a hunter borders in one of the four directions. If there is no allowed move for an animal, it does not move.

There is also a PlayerPenguin class, which is a subclass of Penguin, but controlled by the player.

Movements are made in turns, with the player always moving first and then in the following order:

Whale

LeopardSeal

penguin

fish

Animals of the same species are moved in the order of their occurrence in the respective array. Eaten animals lose their lives and disappear from the tile. Dead animals no longer move.

End of the game

The goal of the player is to move to the field of the other penguin. The player wins the moment he moves to the square where the other penguin is. The move of the other penguin or all other animals is then no longer performed.

The player loses if he moves to a field with a soul leopard or a whale. Furthermore, the player loses if the player penguin or the other penguin is eaten.

Implementation of the game process

Implement the method public void move() in the classes Animal and Fish.

Movements (example) No results

Implement the method public boolean move(int newX, int newY) in the PlayerPenguin class. Your method sets the player to the corresponding position. It also returns true if the game is over at the moment you win or lose. There is no need to check whether the player is teleporting, i.e. whether the new position is really only one step away.

More Information in the Files

Evner: Java

Se mere: track building game, website building game, building game flash game, flash machine building game, free car track building game, flash building game, online browser based civilization building game, building game server website, building game, car building game, free machine building game, building game anti cheat, building game websites, fix bug team building game, link building game site, track race building game

Om arbejdsgiveren:
( 2 bedømmelser ) Munich, Germany

Projekt ID: #22743852

4 freelancere byder i gennemsnit €67 på dette job

xeathprynx

Hello Sir/ Ma’am As a highly skilled full stack developer, I have rich experience in JAVA, C, C++, C# Python , Arduino, [login to view URL], Word press, and ANDROID. I am very confident with my skills and I'd like to he Flere

€8 EUR på 1 dag
(86 bedømmelser)
5.4
dasgopal061

Hain, You can send me your work to me. I am ready to do your work with low cost. I love to do your work very professionally and do't think about cost. Please feel free to contact with me. Thanks Gopal

€50 EUR in 7 dage
(0 bedømmelser)
0.0
nyxhrim

I can do it but for 100, if you are interested in, send me a private message and we can discuss the details

€111 EUR in 5 dage
(0 bedømmelser)
0.0
aawils03

I am experienced with developing 2 dimensional games in java. This project sounds like no difficulty.

€100 EUR in 7 dage
(0 bedømmelser)
0.0