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.
Game/Game.cpp@6:2ca1516ec1e2, 2019-04-10 (annotated)
- Committer:
- joshdavy
- Date:
- Wed Apr 10 11:03:07 2019 +0000
- Revision:
- 6:2ca1516ec1e2
- Parent:
- 4:afbf3dd71403
- Child:
- 7:68e06dda79f7
Began implementing "levels" which store the blocks/enemies of each stage
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joshdavy | 1:37802772843e | 1 | #include "Game.h" |
joshdavy | 1:37802772843e | 2 | // Objects |
joshdavy | 1:37802772843e | 3 | |
joshdavy | 2:b62e8be35a5d | 4 | |
joshdavy | 2:b62e8be35a5d | 5 | |
joshdavy | 1:37802772843e | 6 | const int player_bitmap[6][6] = { |
joshdavy | 1:37802772843e | 7 | {1,1,1,1,0,0}, |
joshdavy | 1:37802772843e | 8 | {1,0,0,1,0,0}, |
joshdavy | 1:37802772843e | 9 | {1,1,1,1,0,0}, |
joshdavy | 1:37802772843e | 10 | {0,1,1,1,1,0}, |
joshdavy | 1:37802772843e | 11 | {0,1,1,1,0,1}, |
joshdavy | 1:37802772843e | 12 | {0,1,0,1,0,0} |
joshdavy | 1:37802772843e | 13 | }; |
joshdavy | 1:37802772843e | 14 | |
joshdavy | 1:37802772843e | 15 | |
joshdavy | 6:2ca1516ec1e2 | 16 | Vector2D blocks[2][2] = { |
joshdavy | 6:2ca1516ec1e2 | 17 | { {30,6},{35,10} }, |
joshdavy | 6:2ca1516ec1e2 | 18 | { {5,10},{2,6} } |
joshdavy | 6:2ca1516ec1e2 | 19 | }; |
joshdavy | 6:2ca1516ec1e2 | 20 | |
joshdavy | 1:37802772843e | 21 | Game::Game() |
joshdavy | 1:37802772843e | 22 | { |
joshdavy | 1:37802772843e | 23 | |
joshdavy | 1:37802772843e | 24 | Vector2D pos = {20,20}; |
joshdavy | 1:37802772843e | 25 | _player.init(6,6,(int *)player_bitmap,pos); |
joshdavy | 6:2ca1516ec1e2 | 26 | //_player.flip(); |
joshdavy | 6:2ca1516ec1e2 | 27 | |
joshdavy | 6:2ca1516ec1e2 | 28 | _level.init(blocks,2); |
joshdavy | 1:37802772843e | 29 | |
joshdavy | 1:37802772843e | 30 | |
joshdavy | 1:37802772843e | 31 | } |
joshdavy | 1:37802772843e | 32 | |
joshdavy | 1:37802772843e | 33 | Game::~Game() |
joshdavy | 1:37802772843e | 34 | { |
joshdavy | 1:37802772843e | 35 | |
joshdavy | 1:37802772843e | 36 | } |
joshdavy | 1:37802772843e | 37 | |
joshdavy | 1:37802772843e | 38 | void Game::read_input(Gamepad &pad) |
joshdavy | 1:37802772843e | 39 | { |
joshdavy | 1:37802772843e | 40 | |
joshdavy | 1:37802772843e | 41 | } |
joshdavy | 1:37802772843e | 42 | |
joshdavy | 1:37802772843e | 43 | void Game::update(Gamepad &pad) |
joshdavy | 1:37802772843e | 44 | { |
joshdavy | 3:b34685dbdb8d | 45 | _player.update(pad); |
joshdavy | 1:37802772843e | 46 | } |
joshdavy | 1:37802772843e | 47 | |
joshdavy | 2:b62e8be35a5d | 48 | void Game::draw(N5110 &lcd) |
joshdavy | 1:37802772843e | 49 | { |
joshdavy | 2:b62e8be35a5d | 50 | |
joshdavy | 2:b62e8be35a5d | 51 | lcd.clear(); |
joshdavy | 1:37802772843e | 52 | _player.render(lcd); |
joshdavy | 6:2ca1516ec1e2 | 53 | _level.render(lcd); |
joshdavy | 2:b62e8be35a5d | 54 | lcd.refresh(); |
joshdavy | 2:b62e8be35a5d | 55 | |
joshdavy | 1:37802772843e | 56 | } |
joshdavy | 1:37802772843e | 57 |