Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Alien Class Reference

Alien class. More...

#include <Alien.h>

Inherits RandomMovement, and CheckCollision.

Public Member Functions

 Alien ()
 Constructor.
 ~Alien ()
 Destructor.
void init (Gamepad &pad, int position_x_start, int position_y_start)
 Initialises Alien.
void draw_alien (N5110 &lcd, Vector2D spaceship_pos, Direction d_, int map_length_, int position_x_map_, bool alien_collision)
 Draws the alien.
int get_alien_fire_counter ()
 Gets the counter for alien time to fire.
void set_alien_x_pos (int position_x)
 Sets the position_x_ of alien.
void set_collision_people_element (int people_element)
 Sets the collision_people_element number.
int get_collision_people_element ()
 Gets the collision_people_element number.
void set_track_flag (bool track_flag)
 Sets alien track_flag.
bool get_track_flag ()
 Gets alien track_flag.
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

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.
int sprite_x_length
 Length of sprite in x direction.
int sprite_y_length
 Length of sprite in y direction.

Detailed Description

Alien class.

Draws and moves aliens

Author:
Benjamin Evans, University of Leeds
Date:
May 2020

Definition at line 15 of file Alien.h.


Constructor & Destructor Documentation

Alien (  )

Constructor.

Definition at line 16 of file Alien.cpp.

~Alien (  )

Destructor.

Definition at line 20 of file Alien.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_collision ( Weapons  bullet ) [inherited]

Checks if bullet collides with a sprite.

Parameters:
bulletWeapons object

Definition at line 3 of file CheckCollision.cpp.

void draw_alien ( N5110 lcd,
Vector2D  spaceship_pos,
Direction  d_,
int  map_length_,
int  position_x_map_,
bool  alien_collision 
)

Draws the alien.

Parameters:
lcdN5110 object
spaceship_posxy spaceship position
d_Direction of joystick
map_length_length of map
position_x_map_x position of map
alien_collisionbool if a collision happened

Definition at line 39 of file Alien.cpp.

int get_alien_fire_counter (  )

Gets the counter for alien time to fire.

Returns:
alien_fire_counter_

Definition at line 136 of file Alien.cpp.

int get_collision_people_element (  )

Gets the collision_people_element number.

Returns:
collision_people_element

Definition at line 148 of file Alien.cpp.

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_track_flag (  )

Gets alien track_flag.

Returns:
track_flag_

Definition at line 156 of file Alien.cpp.

void init ( Gamepad pad,
int  position_x_start,
int  position_y_start 
)

Initialises Alien.

Parameters:
position_x_startRandom x start pos of alien
position_y_startRandom y start pos of alien
padGamepad object

Definition at line 24 of file Alien.cpp.

void move_direction (  ) [protected, inherited]

Gets the movement direction of the sprite.

Definition at line 3 of file RandomMovement.cpp.

void set_alien_x_pos ( int  position_x )

Sets the position_x_ of alien.

Parameters:
position_x

Definition at line 140 of file Alien.cpp.

void set_collision_people_element ( int  people_element )

Sets the collision_people_element number.

Parameters:
people_element

Definition at line 144 of file Alien.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_changenumber to change sprite x position by
y_changenumber to change sprite y position by

Definition at line 15 of file RandomMovement.cpp.

void set_track_flag ( bool  track_flag )

Sets alien track_flag.

Parameters:
track_flag_

Definition at line 152 of file Alien.cpp.


Field Documentation

bool direction_ [protected, inherited]

Movement direction.

Note:
true = East, false = West

Definition at line 35 of file Position.h.

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 27 of file CheckCollision.h.

int sprite_y_length [protected, inherited]

Length of sprite in y direction.

Definition at line 30 of file CheckCollision.h.