ELEC2645 (2016/17) / Mbed 2 deprecated 2645_Project_el15as

Dependencies:   mbed

Committer:
el15as
Date:
Wed May 03 19:57:08 2017 +0000
Revision:
12:0a5758356381
Parent:
4:1f7f32f3e017
Documentation for GameObject class done

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15as 4:1f7f32f3e017 1 #include "GameObject.h"
el15as 4:1f7f32f3e017 2
el15as 12:0a5758356381 3 // Constructor
el15as 4:1f7f32f3e017 4 GameObject::GameObject()
el15as 4:1f7f32f3e017 5 {
el15as 4:1f7f32f3e017 6
el15as 4:1f7f32f3e017 7 }
el15as 4:1f7f32f3e017 8
el15as 12:0a5758356381 9 // Destructor
el15as 4:1f7f32f3e017 10 GameObject::~GameObject()
el15as 4:1f7f32f3e017 11 {
el15as 4:1f7f32f3e017 12
el15as 4:1f7f32f3e017 13 }
el15as 4:1f7f32f3e017 14
el15as 12:0a5758356381 15 // Check whether the object contains the given point
el15as 4:1f7f32f3e017 16 bool GameObject::containsPoint(int x, int y)
el15as 4:1f7f32f3e017 17 {
el15as 12:0a5758356381 18 // If it doesn't contain y - no point checking x
el15as 4:1f7f32f3e017 19 if (containsY(y) == true) {
el15as 4:1f7f32f3e017 20 if (containsX(x) == true) {
el15as 4:1f7f32f3e017 21 return true;
el15as 4:1f7f32f3e017 22 }
el15as 4:1f7f32f3e017 23 }
el15as 4:1f7f32f3e017 24 return false;
el15as 4:1f7f32f3e017 25 }
el15as 4:1f7f32f3e017 26
el15as 12:0a5758356381 27 // Check whether the object contains the given x-coordinate
el15as 12:0a5758356381 28 // by comparing with every x-value the object occupies
el15as 4:1f7f32f3e017 29 bool GameObject::containsX(int _x)
el15as 4:1f7f32f3e017 30 {
el15as 4:1f7f32f3e017 31 for (int i = 0; i < width; i++) {
el15as 4:1f7f32f3e017 32 if ((position.x + i) == _x) {
el15as 4:1f7f32f3e017 33 return true;
el15as 4:1f7f32f3e017 34 }
el15as 4:1f7f32f3e017 35 }
el15as 4:1f7f32f3e017 36 return false;
el15as 4:1f7f32f3e017 37 }
el15as 4:1f7f32f3e017 38
el15as 12:0a5758356381 39 // Check whether the object contains the given y-coordinate
el15as 12:0a5758356381 40 // by comparing with every y-value the object occupies
el15as 4:1f7f32f3e017 41 bool GameObject::containsY(int _y)
el15as 4:1f7f32f3e017 42 {
el15as 4:1f7f32f3e017 43 for (int i = 0; i < height; i++) {
el15as 4:1f7f32f3e017 44 if ((position.y + i) == _y) {
el15as 4:1f7f32f3e017 45 return true;
el15as 4:1f7f32f3e017 46 }
el15as 4:1f7f32f3e017 47 }
el15as 4:1f7f32f3e017 48 return false;
el15as 4:1f7f32f3e017 49 }