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.
Diff: Game/Game.cpp
- Revision:
- 8:21b6d4dbce44
- Parent:
- 7:68e06dda79f7
- Child:
- 9:96969b1c6bde
--- a/Game/Game.cpp Wed Apr 17 12:39:46 2019 +0000 +++ b/Game/Game.cpp Fri Apr 19 17:54:09 2019 +0000 @@ -3,20 +3,19 @@ -const int player_bitmap[6][6] = { - {1,1,1,1,0,0}, - {1,0,0,1,0,0}, - {1,1,1,1,0,0}, - {0,1,1,1,1,0}, - {0,1,1,1,0,1}, - {0,1,0,1,0,0} + +const int number_of_blocks = 4; +Block blocks [number_of_blocks] = { + { {5,30},{80,40} }, + { {5,5},{80,10} }, + { {10,24},{20,34} }, + { {40,24},{44,26} } }; -const int number_of_blocks = 1; -Block blocks [number_of_blocks] = { - { {5,30},{80,40} } - -}; +const int number_of_moving_blocks = 1; +MovingBlock moving_blocks [number_of_moving_blocks] = { + {2,30,30,1,1,0,0} + }; Game::Game() { @@ -28,9 +27,13 @@ void Game::init() { Vector2D pos = {32,10}; - _player.init(6,6,(int *)player_bitmap,pos); - //_player.flip(); - _level.init(blocks,1); + _player.init(6,6,pos); + + Vector2D goal = {70,19}; + _level.init(blocks,moving_blocks,number_of_blocks, + number_of_moving_blocks, + goal); + } Game::~Game() @@ -45,16 +48,16 @@ void Game::update(Gamepad &pad) { + _player.update(pad, blocks,number_of_blocks); } void Game::draw(N5110 &lcd) { - //_level.init(blocks,2); - + lcd.clear(); + _level.render(lcd); _player.render(lcd); - _level.render(lcd); lcd.refresh(); }