Dmitrijs Griskovs / Mbed 2 deprecated el17dg

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Enemy Class Reference

Enemy Class Reference

Enemy Class. More...

#include <enemies.h>

Inherits GameObject.

Public Member Functions

 Enemy ()
void spawn ()
 Enemy spawn function.
void die ()
 enemy death sound and status reset.
void updateAndDraw ()
 Draws and updates enemy sprites on the screen and substracts the score if the ship leaves the screen limits.
void spawn (Point spawn_pos)
 Activates the object at the given postion.

Data Fields

bool dead
 sets if to true when enemy is hit to draw explossion.
int dead_counter
 For drawing small explosion animatioin.
int blast_countdown
 A variable for delaying the enemy shots.
int enemy_speed
 How fast should an enemy move.

Detailed Description

Enemy Class.

A class to describe the states of an enemy ship.

Author:
Dmitrijs Griskovs
Date:
15/04/2019

Definition at line 10 of file enemies.h.


Constructor & Destructor Documentation

Enemy (  )

A bool that changes states between whehter to go up or down in y-direction.

Definition at line 12 of file enemies.h.


Member Function Documentation

void die (  )

enemy death sound and status reset.

Marks enemy as dead, so it can display explosion anation.

Definition at line 33 of file enemies.h.

void spawn ( Point  spawn_pos ) [inherited]

Activates the object at the given postion.

Parameters:
spawn_possets position of x and y into pos (Point).

Definition at line 19 of file gameobject.h.

void spawn (  )

Enemy spawn function.

This function spawns an enemy on the right side of the screen and at random position in the y-direction.

Definition at line 22 of file enemies.h.

void updateAndDraw (  )

Draws and updates enemy sprites on the screen and substracts the score if the ship leaves the screen limits.

The function draws this enemy ship on the screen, and changes their x and y positions each time the function is called. If ship is dead then it draws enemy explosion animation and then disables it. Disables the ship when it leaves the screen limits and substracts the in game score by -50.

Definition at line 49 of file enemies.h.


Field Documentation

A variable for delaying the enemy shots.

Definition at line 84 of file enemies.h.

bool dead

sets if to true when enemy is hit to draw explossion.

Definition at line 74 of file enemies.h.

For drawing small explosion animatioin.

Definition at line 79 of file enemies.h.

How fast should an enemy move.

Definition at line 89 of file enemies.h.