Ben Evans University Second Year Project. Game Called Defender.
Spaceship Class Reference
#include <Spaceship.h>
Inherits CheckAlienCollision, and CheckCollision.
Public Member Functions | |
| Spaceship () | |
| Constructor. | |
| ~Spaceship () | |
| Destructor. | |
| void | init () |
| Initalises Spaceship. | |
| void | draw (N5110 &lcd) |
| Draws Spaceship. | |
| void | movement (Direction d_) |
| Move Spaceship around the screen depedning on joystick input. | |
| bool | get_spaceship_sprite_direction () |
| Gets sprtie directon if spaceship. | |
| bool | check_alien_collision (Alien alien) |
| Checks if alien collides with a sprite. | |
| Vector2D | get_pos () |
| Gets the xy position of the sprite. | |
| bool | check_collision (Weapons bullet) |
| Checks if bullet collides with a sprite. | |
Protected Member Functions | |
| 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 | 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. | |
| 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. | |
Detailed Description
Spaceship class.
Draws and moves spaceship
- Date:
- April 2020
Definition at line 14 of file Spaceship.h.
Constructor & Destructor Documentation
| Spaceship | ( | ) |
Constructor.
Definition at line 28 of file Spaceship.cpp.
| ~Spaceship | ( | ) |
Destructor.
Definition at line 32 of file Spaceship.cpp.
Member Function Documentation
| 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.
| bool check_collision | ( | Weapons | bullet ) | [inherited] |
Checks if bullet collides with a sprite.
- Parameters:
-
bullet Weapons object
Definition at line 3 of file CheckCollision.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 | ( | N5110 & | lcd ) |
| Vector2D get_pos | ( | ) | [inherited] |
Gets the xy position of the sprite.
- Returns:
- position_x_
- position_x_
Definition at line 3 of file Position.cpp.
| bool get_spaceship_sprite_direction | ( | ) |
Gets sprtie directon if spaceship.
- Returns:
- spaceship_sprite_direction_
true = east, false = west
Definition at line 110 of file Spaceship.cpp.
| void init | ( | ) |
Initalises Spaceship.
Definition at line 36 of file Spaceship.cpp.
| void movement | ( | Direction | d_ ) |
Move Spaceship around the screen depedning on joystick input.
- Parameters:
-
d_ Direction of joystick
Definition at line 81 of file Spaceship.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 sprite_x_length [protected, inherited] |
Length of sprite in x direction.
Definition at line 27 of file CheckCollision.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.
int sprite_y_length [protected, inherited] |
Length of sprite in y direction.
Definition at line 30 of file CheckCollision.h.
Generated on Fri Aug 5 2022 06:55:08 by
1.7.2