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
rec/rect.cpp@9:d217a636c18d, 2018-04-19 (annotated)
- Committer:
- RickYu
- Date:
- Thu Apr 19 23:07:14 2018 +0000
- Revision:
- 9:d217a636c18d
- Parent:
- 7:1964f649676e
- Child:
- 10:ef01b3076040
fix the problem that boom monney will go outside the screen;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| RickYu | 2:421fb0670c5c | 1 | #include "rect.h" |
| RickYu | 2:421fb0670c5c | 2 | |
| RickYu | 2:421fb0670c5c | 3 | rect::rect() |
| RickYu | 2:421fb0670c5c | 4 | { |
| RickYu | 2:421fb0670c5c | 5 | |
| RickYu | 2:421fb0670c5c | 6 | } |
| RickYu | 2:421fb0670c5c | 7 | |
| RickYu | 2:421fb0670c5c | 8 | rect::~rect() |
| RickYu | 2:421fb0670c5c | 9 | { |
| RickYu | 2:421fb0670c5c | 10 | |
| RickYu | 2:421fb0670c5c | 11 | } |
| RickYu | 3:1a134243e2f0 | 12 | void rect::init(int x,int y) |
| RickYu | 2:421fb0670c5c | 13 | { |
| RickYu | 7:1964f649676e | 14 | //set the rect move speed |
| RickYu | 9:d217a636c18d | 15 | rect_speed = 1; // default speed |
| RickYu | 2:421fb0670c5c | 16 | } |
| RickYu | 2:421fb0670c5c | 17 | |
| RickYu | 2:421fb0670c5c | 18 | void rect::draw(N5110 &lcd) |
| RickYu | 2:421fb0670c5c | 19 | { |
| RickYu | 7:1964f649676e | 20 | //draw rect om the screen |
| RickYu | 6:46d0caedf217 | 21 | lcd.drawRect(rect_x,40,10,1,FILL_BLACK); |
| RickYu | 3:1a134243e2f0 | 22 | |
| RickYu | 2:421fb0670c5c | 23 | } |
| RickYu | 2:421fb0670c5c | 24 | |
| RickYu | 2:421fb0670c5c | 25 | void rect::update(Direction d,float mag) |
| RickYu | 2:421fb0670c5c | 26 | { |
| RickYu | 2:421fb0670c5c | 27 | |
| RickYu | 7:1964f649676e | 28 | rect_speed = int(mag*10.0f); // scale is arbitrary |
| RickYu | 2:421fb0670c5c | 29 | |
| RickYu | 7:1964f649676e | 30 | //control the movement of rect when joystick moves |
| RickYu | 7:1964f649676e | 31 | //movement of north and south are not allowed |
| RickYu | 3:1a134243e2f0 | 32 | if (d == W) { |
| RickYu | 2:421fb0670c5c | 33 | rect_x-=rect_speed; |
| RickYu | 2:421fb0670c5c | 34 | } else if (d == E) { |
| RickYu | 2:421fb0670c5c | 35 | rect_x+=rect_speed; |
| RickYu | 9:d217a636c18d | 36 | |
| RickYu | 2:421fb0670c5c | 37 | } |
| RickYu | 2:421fb0670c5c | 38 | } |
| RickYu | 2:421fb0670c5c | 39 | |
| RickYu | 2:421fb0670c5c | 40 | |
| RickYu | 2:421fb0670c5c | 41 | Vector2D rect::get_pos() { |
| RickYu | 6:46d0caedf217 | 42 | Vector2D p = {rect_x}; |
| RickYu | 2:421fb0670c5c | 43 | return p; |
| RickYu | 3:1a134243e2f0 | 44 | } |
| RickYu | 5:0a116644cce2 | 45 | |
| RickYu | 5:0a116644cce2 | 46 | void rect::set_pos(Vector2D p) |
| RickYu | 5:0a116644cce2 | 47 | { |
| RickYu | 5:0a116644cce2 | 48 | rect_x = p.x; |
| RickYu | 6:46d0caedf217 | 49 | //rect_y = p.y; |
| RickYu | 5:0a116644cce2 | 50 | } |
| RickYu | 5:0a116644cce2 | 51 | |
| RickYu | 5:0a116644cce2 | 52 | |
| RickYu | 5:0a116644cce2 | 53 |