Yang Hongxiao 201199678
Dependencies: mbed
Obstacle.cpp@1:a6ead8050c23, 2020-05-14 (annotated)
- Committer:
- YHX
- Date:
- Thu May 14 17:00:34 2020 +0000
- Revision:
- 1:a6ead8050c23
Yang Hongxiao; el17hy; 201199678
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
YHX | 1:a6ead8050c23 | 1 | #include "Obstacle.h" |
YHX | 1:a6ead8050c23 | 2 | |
YHX | 1:a6ead8050c23 | 3 | |
YHX | 1:a6ead8050c23 | 4 | Obstacle::Obstacle(){ |
YHX | 1:a6ead8050c23 | 5 | |
YHX | 1:a6ead8050c23 | 6 | } |
YHX | 1:a6ead8050c23 | 7 | |
YHX | 1:a6ead8050c23 | 8 | Obstacle::~Obstacle(){ |
YHX | 1:a6ead8050c23 | 9 | |
YHX | 1:a6ead8050c23 | 10 | } |
YHX | 1:a6ead8050c23 | 11 | void Obstacle::init(){ |
YHX | 1:a6ead8050c23 | 12 | |
YHX | 1:a6ead8050c23 | 13 | _x=20; |
YHX | 1:a6ead8050c23 | 14 | _y=10; |
YHX | 1:a6ead8050c23 | 15 | } |
YHX | 1:a6ead8050c23 | 16 | |
YHX | 1:a6ead8050c23 | 17 | void Obstacle::draw(N5110 &lcd){ |
YHX | 1:a6ead8050c23 | 18 | |
YHX | 1:a6ead8050c23 | 19 | lcd.drawRect(_x,_y,20,2,FILL_BLACK); |
YHX | 1:a6ead8050c23 | 20 | |
YHX | 1:a6ead8050c23 | 21 | } |
YHX | 1:a6ead8050c23 | 22 | |
YHX | 1:a6ead8050c23 | 23 | void Obstacle::new_obstacle(){ |
YHX | 1:a6ead8050c23 | 24 | |
YHX | 1:a6ead8050c23 | 25 | srand(time(NULL)); |
YHX | 1:a6ead8050c23 | 26 | _x=rand()%(84-20); |
YHX | 1:a6ead8050c23 | 27 | _y=rand()%(47-10); |
YHX | 1:a6ead8050c23 | 28 | } |
YHX | 1:a6ead8050c23 | 29 | |
YHX | 1:a6ead8050c23 | 30 | Vector2D Obstacle::get_obstacle_pos() { |
YHX | 1:a6ead8050c23 | 31 | Vector2D p = {_x,_y}; |
YHX | 1:a6ead8050c23 | 32 | return p; |
YHX | 1:a6ead8050c23 | 33 | } |
YHX | 1:a6ead8050c23 | 34 |