Ben Evans University Second Year Project. Game Called Defender.
Weapons Class Reference
#include <Weapons.h>
Inherits RandomMovement.
Public Member Functions | |
| Weapons () | |
| Constructor. | |
| ~Weapons () | |
| Destructor. | |
| void | init (Vector2D sprite_pos, bool sprite_direction, bool bullet_type) |
| Initialises Weapons. | |
| void | draw_bullet (N5110 &lcd) |
| Draws the bullet and moves it in x direction each frame. | |
| void | draw_alien_bullet (N5110 &lcd, Direction d_) |
| Draws the aliens bullet and moves it in xy direction each frame. | |
| void | smart_bomb (N5110 &lcd) |
| Tuns lcd back light on and off. | |
| void | set_pos_one (Vector2D pos) |
| Sets the xy position of the bullet. | |
| int | get_bullet_delete_counter () |
| Gets the bullet distance counter. | |
| bool | get_direction () |
| Gets the bullet direction. | |
| void | set_direction (bool sprite_direction_) |
| Sets the bullets movement direction when it is fired. | |
| Vector2D | get_pos () |
| Gets the xy position of the 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. | |
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. | |
Detailed Description
Weapons class.
Draws and moves weapons
- Date:
- April 2020
Definition at line 15 of file Weapons.h.
Constructor & Destructor Documentation
| Weapons | ( | ) |
Constructor.
Definition at line 3 of file Weapons.cpp.
| ~Weapons | ( | ) |
Destructor.
Definition at line 7 of file Weapons.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.
| void draw_alien_bullet | ( | N5110 & | lcd, |
| Direction | d_ | ||
| ) |
Draws the aliens bullet and moves it in xy direction each frame.
- Parameters:
-
lcd N5110 object d_ : Direction object of joystick
Definition at line 74 of file Weapons.cpp.
| void draw_bullet | ( | N5110 & | lcd ) |
Draws the bullet and moves it in x direction each frame.
- Parameters:
-
lcd N5110 object
Definition at line 51 of file Weapons.cpp.
| int get_bullet_delete_counter | ( | ) |
Gets the bullet distance counter.
- Returns:
- bullet_distance_counter
Definition at line 95 of file Weapons.cpp.
| bool get_direction | ( | ) |
| 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 | ( | Vector2D | sprite_pos, |
| bool | sprite_direction, | ||
| bool | bullet_type | ||
| ) |
Initialises Weapons.
- Parameters:
-
sprite_pos vector 2D of sprite xy position sprite_direction sprite direction bool, true = E, false = W bullet_type true = spaceship, false = alien
Definition at line 11 of file Weapons.cpp.
| void move_direction | ( | ) | [protected, inherited] |
Gets the movement direction of the sprite.
Definition at line 3 of file RandomMovement.cpp.
| void set_direction | ( | bool | sprite_direction_ ) |
Sets the bullets movement direction when it is fired.
- Parameters:
-
spaceship_sprite_direction_ sprite direction bool, true = E, false = W
Definition at line 91 of file Weapons.cpp.
| void set_pos_one | ( | Vector2D | pos ) |
Sets the xy position of the bullet.
- Parameters:
-
pos vector 2D of bullet xy position
Definition at line 86 of file Weapons.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.
| void smart_bomb | ( | N5110 & | lcd ) |
Tuns lcd back light on and off.
- Parameters:
-
lcd N5110 object
Definition at line 23 of file Weapons.cpp.
Field Documentation
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.
Generated on Fri Aug 5 2022 06:55:08 by
1.7.2