Educational project to teach basic Object Orientation in Python Language.
Python version used: 3.4
Take a look at videos. Even in portuguese, is possible to see the graphics ;): Python Birds
Install Python 3.
Download the version containing only the project structure
Tests are under "testes" package and define the classes behavior. Run all tests by executing:
python testloader.py
Detailed explanation about classes and methods are found on Simplified Game
Start development with actors.py, following respective tests under actor_tests.py. Next go to phase.py with its respective tests fase_teste.py.
You can run the game any time by executing:
python graphics_tk.py
Use "arrow down" or up to move the angle arrow. Use "space" or "enter" to launch a bird.
The module containing all project's actors.
Module containing the class representing a Phase. Also contains the class Point to represent a Cartesian Point (x, y) plus a character representing the image to be shown.
Logic to play the game with graphics on TKInter.
- Actors are points on Cartesian Plan.
- Bird's speed is slow, so at each step the point move to a neighbor point.
- Actors collision occurs considering the point as a center of a square with side equals to 2 times on "interval".
The detailed specification of game can be found next.
Base class for all game's actors.
Receives game's time (float) as a parameter and returns a tuple with 2 elements: horizontal position(x) as the first element and vertical position (y) as second.
An actors has its status Active or Destroyed.
Executes clash logic between two actors. It must occur only with both actor active if they are neighbors. Each actor must keep clash time to calculate it's position accordingly. Interval is a parameters to indicate a square with side 2 times "interval" that represents each point. Its default value is 1.
It must return 'A' when actor is active and '+' otherwise. The return value depend on game's time.
Class representing a obstacle which can be destroyed by birds. Inherits from Actor. its representing character when active is "O".
Class representing pigs. Inherits from Actor. Its character is "@" when Active and " " (empty string) other else.
Base class for all birds. Each concrete type has a specific launch velocity (v). The player choose the birds launch angle (teta) in grads. The launch follow kinematic equation given gravity (G) of 10 m/s^2.
Receives the launch angle and time. These values must be stored to further kinematic calculations. Remember that time for equation is delta_t = T_end - T_start
Every bird clashing with ground (y<=0) must be destroyed.
Must return True bird was already launched and False other else.
Either if bird is not yet launched or if game's time is less the launch time, it must hold on initial position.
If it was launched and has active status, its position must be calculated based on kinematic equation. delta_t is going to be game's time minus launch's time.
Other else it must return the clash position.
Formula X=X0+v*cos(teta)*delta_t.
Fórmula Y=Y0+vsen(teta)delta_t-(Gdelta_t^2)/2.
Bird class representing red birds. Its velocity is 20 m/s. Its active character is "R". Its destroyed character is "r"
Bird class representing yellow birds. Its velocity is 30 m/s. Its active character is "Y". Its destroyed character is "y"
Responsible to hold actors and transform them into cartesian points on screen.
Adds obstacles to phase.
Adds pigs to phase.
Adds birds to phase.
Returns game's status. There are 3 possible values:
- VICTORY indicating player's victory. It happens when all pigs are dead.
- ON_GOING indication the game's is still running.
- DEFEAT indicating player's lose. It happens when there is one pig active at least but there is no active bird.
Receive launch angle and time as parameters. Must delegate launch to the first bird not launched on list.
Execute game's logic on each step. Returns the points to be show at screen. It must:
- Calculate each bird position;
- Verify if bird clashed against an obstacle, pig or ground;
- Transforms each actor in a point using _to_point method.
Powered by Python Pro