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
Coin/Coin.cpp@14:d0650d0de063, 2019-05-06 (annotated)
- Committer:
- S_Tingle
- Date:
- Mon May 06 14:13:09 2019 +0000
- Revision:
- 14:d0650d0de063
- Parent:
- 13:c3b550fc2445
- Child:
- 15:a080c64cf301
added start screen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
S_Tingle | 13:c3b550fc2445 | 1 | #include "Coin.h" |
S_Tingle | 13:c3b550fc2445 | 2 | |
S_Tingle | 13:c3b550fc2445 | 3 | Coin::Coin(){ |
S_Tingle | 14:d0650d0de063 | 4 | x_coin = 41; |
S_Tingle | 14:d0650d0de063 | 5 | y_coin = 42; |
S_Tingle | 13:c3b550fc2445 | 6 | } |
S_Tingle | 13:c3b550fc2445 | 7 | |
S_Tingle | 13:c3b550fc2445 | 8 | Coin::~Coin(){ |
S_Tingle | 13:c3b550fc2445 | 9 | |
S_Tingle | 13:c3b550fc2445 | 10 | } |
S_Tingle | 13:c3b550fc2445 | 11 | |
S_Tingle | 13:c3b550fc2445 | 12 | void Coin::init(int x,int y){ |
S_Tingle | 13:c3b550fc2445 | 13 | x_coin = x; |
S_Tingle | 13:c3b550fc2445 | 14 | y_coin = y; |
S_Tingle | 13:c3b550fc2445 | 15 | } |
S_Tingle | 13:c3b550fc2445 | 16 | |
S_Tingle | 14:d0650d0de063 | 17 | int Coin::get_x_coin(){ |
S_Tingle | 13:c3b550fc2445 | 18 | return x_coin; |
S_Tingle | 13:c3b550fc2445 | 19 | } |
S_Tingle | 13:c3b550fc2445 | 20 | |
S_Tingle | 14:d0650d0de063 | 21 | int Coin::get_y_coin(){ |
S_Tingle | 13:c3b550fc2445 | 22 | return y_coin; |
S_Tingle | 13:c3b550fc2445 | 23 | } |
S_Tingle | 13:c3b550fc2445 | 24 | |
S_Tingle | 13:c3b550fc2445 | 25 | void Coin::drawSprite(N5110 &lcd){ |
S_Tingle | 14:d0650d0de063 | 26 | lcd.drawSprite(x_coin,y_coin,2,2,(int *)coin_01); |
S_Tingle | 13:c3b550fc2445 | 27 | } |
S_Tingle | 13:c3b550fc2445 | 28 | |
S_Tingle | 14:d0650d0de063 | 29 | void Coin::collect(N5110 &lcd){ |
S_Tingle | 14:d0650d0de063 | 30 | |
S_Tingle | 14:d0650d0de063 | 31 | } |
S_Tingle | 13:c3b550fc2445 | 32 | |
S_Tingle | 14:d0650d0de063 | 33 | bool Coin::topLeftCollision(int x, int y, N5110 &lcd){ |
S_Tingle | 14:d0650d0de063 | 34 | for (int i = 0; i <= 1; i++){ |
S_Tingle | 14:d0650d0de063 | 35 | if (lcd.getPixel(x + i,y) == 1){ |
S_Tingle | 13:c3b550fc2445 | 36 | return true; |
S_Tingle | 13:c3b550fc2445 | 37 | } |
S_Tingle | 13:c3b550fc2445 | 38 | } |
S_Tingle | 13:c3b550fc2445 | 39 | return false; |
S_Tingle | 13:c3b550fc2445 | 40 | } |
S_Tingle | 13:c3b550fc2445 | 41 | |
S_Tingle | 14:d0650d0de063 | 42 | bool Coin::bottomRightCollision(int x, int y, N5110 &lcd){ |
S_Tingle | 14:d0650d0de063 | 43 | for (int i = 0; i <= 1; i++){ |
S_Tingle | 14:d0650d0de063 | 44 | if (lcd.getPixel(x + 1,y + i) == 1){ |
S_Tingle | 13:c3b550fc2445 | 45 | return true; |
S_Tingle | 13:c3b550fc2445 | 46 | } |
S_Tingle | 13:c3b550fc2445 | 47 | } |
S_Tingle | 13:c3b550fc2445 | 48 | return false; |
S_Tingle | 13:c3b550fc2445 | 49 | } |