space invaders like game with angry rabbits and a police man
Rabbits in TierPark is a game based on the famous game of the late 80s space invaders, a classic game one of the first video games created and very popular.
The motivation to create a version of this game as a pet project, is to understand the basic concepts of programming in python, since I have no experience programming in python, and also apply the concepts seen in the course.
The game is inspired by the book "Curso Intensivo de PYTHON" by author Eric Matthes, which I recommend a lot to learn to program in Python!
The player control a gun that appear in the low part of the screen, the player can move the policeman to the rigth and to the left using the <> keys and shot using the barscpace. When the game begins, a familiy of rabbits come to tierpark from the top of the screen (Zombie rabbits that want to kill all the Berliners), the player shot the zombie rabbits, when the player kills all the rabbits, a new generation will come to the park that is faster, if a rabbit comes to the end of the park the player will lose and the game is over.
In this diagram you can see some action nodes. You have a start node and an end node. On the right there is a branching. Object nodes are not drawn. In this way, you could insert objects in various places, which are then available at that point. For example, a rabbit object that is killed by the police after a successful bullet shot. Or an object representing the entire game including rabbits and the police.
Sequence Diagram: In this diagram each box represent one stage of the game and describe it. Once the game start the player can have 3 states: 1: the police is killing rabbits, 2: The Rabbits kill the police and 3: The police has no more bullets and need to wait for a small period of time till some bullets are free again. The player win, wenn all the rabbits are killed and lose when the rabbits kill him.
The Structure diagram emphasize the objects present in the game.
The class Diagram: shows the relationship between the Classes in the game and how they are involved. The different Classes are connected in the run game file.
SonarQube performs an anaysis of the pet project; the quality measures and issues instances where coding rules were broken. to see the results please link on the Badget:
The pet project complexity was calculated based on the number of paths through the code. This calculation gave a value of 54, is a low number indicating the code is easy to read. No duplicated blocks, files or lines. Two issues where found for an unused local variable and the other one having two branches in the same if statment.
Overal Maintainability rating was A! (Remediation cost / Development cost : less than 0.05), no bugs rating A!. In General my code pass the SonarQube scanner no bugs and no vulnerabilities found!.
This code review tool analyze all relevant files in the current working directory in my repository. 20 files where evaluated, 7 Total issues, and a general technical debt rate B (5% to 10% ratio)
The clean code is based on the "Clean code cheat sheet" from this link. I use vim with this configuration.
Example 1: General and Understandability
Example 2: High Cohesion
Example 3: Class Design
Example 4: Naming
Example 5: Methods
A DSL example that does not contribute to my project: DSL
Functional programming is great but in the fact is very dificcult for me to implement it, becasue im new in Python and have been focusing in object orentiert languages so far. For my project I choosed a functional programming style where appropriate. For some parts of this specific software a more object-oriented approach was a good fit (rabbits, police, bullets, screen). The implementacion is found here.
(mostly) side effect free functions
- get_number_rabbits_x
- get_number_rows







