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
- Committer:
- S_Tingle
- Date:
- 2019-05-08
- Revision:
- 17:ce6b54422113
- Parent:
- 16:37d98c281eb3
- Child:
- 18:ba4159ab4da7
File content as of revision 17:ce6b54422113:
#include "Coin.h" Coin::Coin(){ x_coin = 41; y_coin = 42; _spawn = true; } Coin::~Coin(){ } void Coin::init(int x,int y){ x_coin = x; y_coin = y; } int Coin::get_x_coin(){ return x_coin; } int Coin::get_y_coin(){ return y_coin; } int Coin::coins(){ return coin; } void Coin::drawSprite(N5110 &lcd){ lcd.drawSprite(x_coin,y_coin,2,2,(int *)coin_01); } bool Coin::collidePlayer(int x, int y, Gamepad &pad) { for (int ix = 0; ix < 7; ix++) { for (int iy = 0; iy < 7; iy++) { if ( x + ix == x_coin - 1 && y + iy == y_coin) { ++coin; pad.tone(650,0.25); return true; } } } return false; } void Coin::spawn(int x, int y, N5110 &lcd, Gamepad &pad) { drawSprite(lcd); if (collidePlayer(x,y,pad) == true) { char buffer[14]; sprintf(buffer,"%2d",coins()); printf(buffer,77,40); x_coin = 100; y_coin = 100; } else { } }