Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
GameObject/GameObject.cpp@4:1f7f32f3e017, 2017-04-24 (annotated)
- Committer:
- el15as
- Date:
- Mon Apr 24 22:32:40 2017 +0000
- Revision:
- 4:1f7f32f3e017
- Child:
- 12:0a5758356381
Cleaned up the code and moved some of the code into a separate classes called Level and Animation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el15as | 4:1f7f32f3e017 | 1 | #include "GameObject.h" |
el15as | 4:1f7f32f3e017 | 2 | |
el15as | 4:1f7f32f3e017 | 3 | GameObject::GameObject() |
el15as | 4:1f7f32f3e017 | 4 | { |
el15as | 4:1f7f32f3e017 | 5 | |
el15as | 4:1f7f32f3e017 | 6 | } |
el15as | 4:1f7f32f3e017 | 7 | |
el15as | 4:1f7f32f3e017 | 8 | GameObject::~GameObject() |
el15as | 4:1f7f32f3e017 | 9 | { |
el15as | 4:1f7f32f3e017 | 10 | |
el15as | 4:1f7f32f3e017 | 11 | } |
el15as | 4:1f7f32f3e017 | 12 | |
el15as | 4:1f7f32f3e017 | 13 | bool GameObject::containsPoint(int x, int y) |
el15as | 4:1f7f32f3e017 | 14 | { |
el15as | 4:1f7f32f3e017 | 15 | if (containsY(y) == true) { |
el15as | 4:1f7f32f3e017 | 16 | if (containsX(x) == true) { |
el15as | 4:1f7f32f3e017 | 17 | return true; |
el15as | 4:1f7f32f3e017 | 18 | } |
el15as | 4:1f7f32f3e017 | 19 | } |
el15as | 4:1f7f32f3e017 | 20 | return false; |
el15as | 4:1f7f32f3e017 | 21 | } |
el15as | 4:1f7f32f3e017 | 22 | |
el15as | 4:1f7f32f3e017 | 23 | bool GameObject::containsX(int _x) |
el15as | 4:1f7f32f3e017 | 24 | { |
el15as | 4:1f7f32f3e017 | 25 | for (int i = 0; i < width; i++) { |
el15as | 4:1f7f32f3e017 | 26 | if ((position.x + i) == _x) { |
el15as | 4:1f7f32f3e017 | 27 | return true; |
el15as | 4:1f7f32f3e017 | 28 | } |
el15as | 4:1f7f32f3e017 | 29 | } |
el15as | 4:1f7f32f3e017 | 30 | return false; |
el15as | 4:1f7f32f3e017 | 31 | } |
el15as | 4:1f7f32f3e017 | 32 | |
el15as | 4:1f7f32f3e017 | 33 | bool GameObject::containsY(int _y) |
el15as | 4:1f7f32f3e017 | 34 | { |
el15as | 4:1f7f32f3e017 | 35 | for (int i = 0; i < height; i++) { |
el15as | 4:1f7f32f3e017 | 36 | if ((position.y + i) == _y) { |
el15as | 4:1f7f32f3e017 | 37 | return true; |
el15as | 4:1f7f32f3e017 | 38 | } |
el15as | 4:1f7f32f3e017 | 39 | } |
el15as | 4:1f7f32f3e017 | 40 | return false; |
el15as | 4:1f7f32f3e017 | 41 | } |