Ben Evans University Second Year Project. Game Called Defender.
People Class Reference
#include <People.h>
Inherits RandomMovement, and CheckAlienCollision.
Public Member Functions | |
| People () | |
| Constructor. | |
| ~People () | |
| Destructor. | |
| void | init (Gamepad &pad, int position_x_start) |
| Initalises Alien. | |
| void | draw_people (N5110 &lcd, Direction d_, int map_length_, int position_x_map_) |
| Draws the people. | |
| bool | get_alien_collision_flag () |
| Gets alien collision flag. | |
| Vector2D | get_pos () |
| Gets the xy position of the sprite. | |
| bool | check_alien_collision (Alien alien) |
| Checks if alien collides with a sprite. | |
Protected Member Functions | |
| void | set_sprite_direction (int x_change, int y_change) |
| Changes the x and y positions of the sprite object depending on the movement direction. | |
| void | set_random_move () |
| Generates the random move direction and length for the sprite. | |
| void | move_direction () |
| Gets the movement direction of the sprite. | |
| int | calc_sprite_movement (Direction d_) |
| Calculates the sprite movement depending on spaceship positions and joystick input. | |
| bool | check_top_right (Alien alien, Vector2D alien_pos) |
| Checks if alien collides with top right of sprite and return flag. | |
| bool | check_top_left (Alien alien, Vector2D alien_pos) |
| Checks if alien collides with top left of sprite and return flag. | |
| bool | check_bottom_right (Alien alien, Vector2D alien_pos) |
| Checks if alien collides with bottom right sprite and return flag. | |
| bool | check_bottom_left (Alien alien, Vector2D alien_pos) |
| Checks if alien collides with bottom left sprite and return flag. | |
Protected Attributes | |
| int | random_move_counter_ |
| Sprite random move counter. | |
| int | random_direction_ |
| Random direction variable. | |
| int | position_x_ |
| X position on lcd. | |
| int | position_y_ |
| Y position on lcd. | |
| bool | direction_ |
| Movement direction. | |
| int | sprite_x_length |
| Length of sprite in x direction. | |
| int | sprite_y_length |
| Length of sprite in y direction. | |
| bool | alien_collision_flag |
| Flag if there is is a alien collision. | |
| bool | alien_track |
| Flag if the alien that colided is tracking. | |
Detailed Description
People class.
Draws people and moves them if collected by aliens
- Date:
- May 2020
Definition at line 14 of file People.h.
Constructor & Destructor Documentation
| People | ( | ) |
Constructor.
Definition at line 16 of file People.cpp.
| ~People | ( | ) |
Destructor.
Definition at line 20 of file People.cpp.
Member Function Documentation
| int calc_sprite_movement | ( | Direction | d_ ) | [protected, inherited] |
Calculates the sprite movement depending on spaceship positions and joystick input.
- Parameters:
-
d_ : Direction object of joystick
- Returns:
- integer
move alien value for alien draw function
Definition at line 31 of file RandomMovement.cpp.
| bool check_alien_collision | ( | Alien | alien ) | [inherited] |
Checks if alien collides with a sprite.
- Parameters:
-
alien Alien object
Definition at line 3 of file CheckAlienCollision.cpp.
Checks if alien collides with bottom left sprite and return flag.
- Parameters:
-
alien Alien object alien_pos vector2D of alien xy position
- Returns:
- check_collision
check collision flag
Definition at line 51 of file CheckAlienCollision.cpp.
Checks if alien collides with bottom right sprite and return flag.
- Parameters:
-
alien Alien object alien_pos vector2D of alien xy position
- Returns:
- check_collision
check collision flag
Definition at line 66 of file CheckAlienCollision.cpp.
Checks if alien collides with top left of sprite and return flag.
- Parameters:
-
alien Alien object alien_pos vector2D of alien xy position
- Returns:
- check_collision
check collision flag
Definition at line 21 of file CheckAlienCollision.cpp.
Checks if alien collides with top right of sprite and return flag.
- Parameters:
-
alien Alien object alien_pos vector2D of alien xy position
- Returns:
- check_collision
check collision flag
Definition at line 36 of file CheckAlienCollision.cpp.
| void draw_people | ( | N5110 & | lcd, |
| Direction | d_, | ||
| int | map_length_, | ||
| int | position_x_map_ | ||
| ) |
Draws the people.
- Parameters:
-
lcd N5110 object d_ joystick direction map_length length of the map position_x_map_ x posisition that map starts
Definition at line 35 of file People.cpp.
| bool get_alien_collision_flag | ( | ) |
| Vector2D get_pos | ( | ) | [inherited] |
Gets the xy position of the sprite.
- Returns:
- position_x_
- position_x_
Definition at line 3 of file Position.cpp.
| void init | ( | Gamepad & | pad, |
| int | position_x_start | ||
| ) |
Initalises Alien.
- Parameters:
-
position_x_start Random x start pos of people pad Gamepad object
Definition at line 24 of file People.cpp.
| void move_direction | ( | ) | [protected, inherited] |
Gets the movement direction of the sprite.
Definition at line 3 of file RandomMovement.cpp.
| void set_random_move | ( | ) | [protected, inherited] |
Generates the random move direction and length for the sprite.
Definition at line 20 of file RandomMovement.cpp.
| void set_sprite_direction | ( | int | x_change, |
| int | y_change | ||
| ) | [protected, inherited] |
Changes the x and y positions of the sprite object depending on the movement direction.
- Parameters:
-
x_change number to change sprite x position by y_change number to change sprite y position by
Definition at line 15 of file RandomMovement.cpp.
Field Documentation
bool alien_collision_flag [protected, inherited] |
Flag if there is is a alien collision.
Definition at line 63 of file CheckAlienCollision.h.
bool alien_track [protected, inherited] |
Flag if the alien that colided is tracking.
Definition at line 66 of file CheckAlienCollision.h.
bool direction_ [protected, inherited] |
int position_x_ [protected, inherited] |
X position on lcd.
Definition at line 27 of file Position.h.
int position_y_ [protected, inherited] |
Y position on lcd.
Definition at line 30 of file Position.h.
int random_direction_ [protected, inherited] |
Random direction variable.
Definition at line 43 of file RandomMovement.h.
int random_move_counter_ [protected, inherited] |
Sprite random move counter.
Definition at line 40 of file RandomMovement.h.
int sprite_x_length [protected, inherited] |
Length of sprite in x direction.
Definition at line 57 of file CheckAlienCollision.h.
int sprite_y_length [protected, inherited] |
Length of sprite in y direction.
Definition at line 60 of file CheckAlienCollision.h.
Generated on Fri Aug 5 2022 06:55:08 by
1.7.2