-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlappy.cpp
More file actions
50 lines (40 loc) · 949 Bytes
/
Flappy.cpp
File metadata and controls
50 lines (40 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Flappy.h"
const static unsigned char PROGMEM flappy_up[] = {
17,4,
B00000011, B11110000, B00000000,
B00001100, B01001000, B00000000,
B00010000, B10000100, B00000000,
B00100000, B10001010, B00000000
};
const static unsigned char PROGMEM flappy_mid[] = {
8,2,
B00000000,
B00001100
};
const static unsigned char PROGMEM flappy_down[] = {
8,2,
B00000000,
B00001100
};
Flappy::Flappy() : _state(0), _x(40), _y(40), _vx(0), _vy(0)
{
_numberOfLives = 3;
_currentSpriteIndex = 0;
_sprites[0] = flappy_up;
_sprites[1] = flappy_mid;
_sprites[2] = flappy_down;
_sprites[3] = flappy_mid;
};
void Flappy::paint(Gamebuino& gb) {
gb.display.drawBitmap(_x,_y,getSprite(),ROTCCW,NOFLIP);
};
void Flappy::update(uint32_t frameNumber) {
_currentSpriteIndex = frameNumber && 3;
_x += _vx;
_y += _vy;
};
void Flappy::init() {
};
uint8_t* Flappy::getSprite() {
return _sprites[_currentSpriteIndex];
}