Dmitrijs Griskovs / Mbed 2 deprecated el17dg

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Player Class Reference

Player Class Reference

Player Class. More...

#include <player.h>

Inherits GameObject.

Public Member Functions

 Player ()
 A constructor of the player's ship.
void updateAndDrawBlasts ()
 Draws the player's blasts on the screen.
void fireNewBlast ()
 Makes a blast active and gives it the start positions.
void updateAndDraw ()
 Updates and draws player's ship (including with force shield sprite) positon.
void draw ()
 Updates and draws player's ship and the force shield sprites.
void spawn (Point spawn_pos)
 Activates the object at the given postion.

Detailed Description

Player Class.

Manages player's ship.

Author:
Dmitrijs Griskovs
Date:
15/04/2019

Definition at line 10 of file player.h.


Constructor & Destructor Documentation

Player (  )

A constructor of the player's ship.

A constructor for the palyer's sprite body circle area and the blast circle area. It sets the circle radius for collsion callculations.

Definition at line 28 of file player.h.


Member Function Documentation

void draw (  )

Updates and draws player's ship and the force shield sprites.

Definition at line 105 of file player.h.

void fireNewBlast (  )

Makes a blast active and gives it the start positions.

This function searches the array for the inactive blasts, If a blast is not active, it will set it to active and will start drawing it accross the screen until it reaches the LCD border line.

Definition at line 64 of file player.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 updateAndDraw (  )

Updates and draws player's ship (including with force shield sprite) positon.

The function reads the analog input signal from joystick and moves the player's ship on the LCD accordingly.(move joystick, the ship moves up, move joystick right, the ship moves right). Also, this function checks whether the force shield was activated in game.cpp, if it was then the player's ship is replaced the exactky the same sip but with the added force shield.

Definition at line 88 of file player.h.

void updateAndDrawBlasts (  )

Draws the player's blasts on the screen.

This function Will draw every activated blast to the left with the blast_speed. It will deactivate blasts when they leave the screen, for future reuse. If the blast does miss the enemy and leaves the screen limits, the function will substract 10 points in game_score.

Definition at line 45 of file player.h.