Josh Davy / Mbed 2 deprecated Flip

Dependencies:   mbed el17jd

Committer:
joshdavy
Date:
Sat Apr 06 11:47:18 2019 +0000
Revision:
4:afbf3dd71403
Parent:
3:b34685dbdb8d
Child:
7:68e06dda79f7
Began implemting music playing class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joshdavy 1:37802772843e 1 #include "Sprite.h"
joshdavy 1:37802772843e 2
joshdavy 4:afbf3dd71403 3 Sprite::Sprite() {}
joshdavy 1:37802772843e 4
joshdavy 4:afbf3dd71403 5 Sprite::~Sprite() {}
joshdavy 1:37802772843e 6
joshdavy 1:37802772843e 7 void Sprite::init(int height,int width,int * bitmap,Vector2D pos)
joshdavy 1:37802772843e 8 {
joshdavy 1:37802772843e 9 _height = height;
joshdavy 1:37802772843e 10 _width = width;
joshdavy 1:37802772843e 11 _bitmap = bitmap;
joshdavy 1:37802772843e 12 _pos = pos;
joshdavy 1:37802772843e 13 }
joshdavy 1:37802772843e 14
joshdavy 3:b34685dbdb8d 15 void Sprite::update()
joshdavy 2:b62e8be35a5d 16 {
joshdavy 3:b34685dbdb8d 17 _pos.y += GRAVITY;
joshdavy 2:b62e8be35a5d 18 }
joshdavy 1:37802772843e 19
joshdavy 2:b62e8be35a5d 20 void Sprite::render(N5110 &lcd) {
joshdavy 2:b62e8be35a5d 21
joshdavy 1:37802772843e 22 lcd.drawSprite(_pos.x,_pos.y,_height,_width, _bitmap);
joshdavy 1:37802772843e 23 };
joshdavy 1:37802772843e 24
joshdavy 1:37802772843e 25 Vector2D Sprite::getPos() {
joshdavy 1:37802772843e 26 return _pos;
joshdavy 1:37802772843e 27 };
joshdavy 1:37802772843e 28
joshdavy 1:37802772843e 29 void Sprite::setPos(Vector2D pos) {
joshdavy 1:37802772843e 30 _pos = pos;
joshdavy 1:37802772843e 31 };
joshdavy 4:afbf3dd71403 32
joshdavy 4:afbf3dd71403 33 void Sprite::setBitmap(int * bitmap) {
joshdavy 4:afbf3dd71403 34 _bitmap = bitmap ;
joshdavy 4:afbf3dd71403 35 };
joshdavy 1:37802772843e 36
joshdavy 4:afbf3dd71403 37 void Sprite::flip() {
joshdavy 4:afbf3dd71403 38 //int newBitmap [_height][_width] ;
joshdavy 4:afbf3dd71403 39 // for (int i = 0;i < _height;i++) {
joshdavy 4:afbf3dd71403 40 // for (int j = 0;j < _width;j++) {
joshdavy 4:afbf3dd71403 41 // printf("HI");
joshdavy 4:afbf3dd71403 42 // printf("%i,%i\n",i,j);
joshdavy 4:afbf3dd71403 43 //
joshdavy 4:afbf3dd71403 44 // newBitmap[i][j] = 1;//*((_bitmap+i*_height)+j);
joshdavy 4:afbf3dd71403 45 // printf("%i\n",newBitmap[i][j]);
joshdavy 4:afbf3dd71403 46 // };
joshdavy 4:afbf3dd71403 47 // };
joshdavy 4:afbf3dd71403 48 //
joshdavy 4:afbf3dd71403 49 // _bitmap = (int *) newBitmap;
joshdavy 4:afbf3dd71403 50
joshdavy 4:afbf3dd71403 51
joshdavy 4:afbf3dd71403 52 const int play[6][6] = {
joshdavy 4:afbf3dd71403 53 {1,1,1,1,1,1},
joshdavy 4:afbf3dd71403 54 {1,0,0,0,0,1},
joshdavy 4:afbf3dd71403 55 {1,0,0,0,0,1},
joshdavy 4:afbf3dd71403 56 {1,0,0,0,0,1},
joshdavy 4:afbf3dd71403 57 {1,0,0,0,0,1},
joshdavy 4:afbf3dd71403 58 {1,1,1,1,1,1}
joshdavy 4:afbf3dd71403 59 };
joshdavy 4:afbf3dd71403 60
joshdavy 4:afbf3dd71403 61 setBitmap((int *) play);
joshdavy 4:afbf3dd71403 62
joshdavy 4:afbf3dd71403 63 };