Ben Evans / Mbed 2 deprecated Defender_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

RandomMovement Class Reference

Random Movement class. More...

#include <RandomMovement.h>

Inherits Position.

Inherited by Alien, People, and Weapons.

Public Member Functions

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

Random Movement class.

Random Movement parent class

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

Definition at line 13 of file RandomMovement.h.


Member Function Documentation

int calc_sprite_movement ( Direction  d_ ) [protected]

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.

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 move_direction (  ) [protected]

Gets the movement direction of the sprite.

Definition at line 3 of file RandomMovement.cpp.

void set_random_move (  ) [protected]

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]

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.


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]

Random direction variable.

Definition at line 43 of file RandomMovement.h.

int random_move_counter_ [protected]

Sprite random move counter.

Definition at line 40 of file RandomMovement.h.