Prints objects on to a Nokia N5110 LCD display and makes them 'fall' down the display.
Dependents: Game_Controller_Project
Objects.cpp@1:a05d10d3d33f, 2017-03-17 (annotated)
- Committer:
- Nathanj94
- Date:
- Fri Mar 17 15:34:43 2017 +0000
- Revision:
- 1:a05d10d3d33f
- Parent:
- 0:a1d36c50a0b7
- Child:
- 2:3f42da6a4c89
Objects.h developed; Objects.cpp developed; Basic functions completed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nathanj94 | 1:a05d10d3d33f | 1 | #include "Objects.h" |
Nathanj94 | 1:a05d10d3d33f | 2 | |
Nathanj94 | 1:a05d10d3d33f | 3 | Objects::Objects() |
Nathanj94 | 1:a05d10d3d33f | 4 | { |
Nathanj94 | 1:a05d10d3d33f | 5 | |
Nathanj94 | 1:a05d10d3d33f | 6 | } |
Nathanj94 | 1:a05d10d3d33f | 7 | |
Nathanj94 | 1:a05d10d3d33f | 8 | Objects::~Objects() |
Nathanj94 | 1:a05d10d3d33f | 9 | { |
Nathanj94 | 1:a05d10d3d33f | 10 | |
Nathanj94 | 1:a05d10d3d33f | 11 | } |
Nathanj94 | 1:a05d10d3d33f | 12 | |
Nathanj94 | 1:a05d10d3d33f | 13 | void Objects::Objects_init(int speed) |
Nathanj94 | 1:a05d10d3d33f | 14 | { |
Nathanj94 | 1:a05d10d3d33f | 15 | Objects_speed = speed; |
Nathanj94 | 1:a05d10d3d33f | 16 | Objects_y = 0; |
Nathanj94 | 1:a05d10d3d33f | 17 | |
Nathanj94 | 1:a05d10d3d33f | 18 | Objects_ep = rand() % 7; |
Nathanj94 | 1:a05d10d3d33f | 19 | if(Objects_ep == 0) { |
Nathanj94 | 1:a05d10d3d33f | 20 | Objects_x = 3; |
Nathanj94 | 1:a05d10d3d33f | 21 | } else if (Objects_ep == 1) { |
Nathanj94 | 1:a05d10d3d33f | 22 | Objects_x = 15; |
Nathanj94 | 1:a05d10d3d33f | 23 | } else if (Objects_ep == 2) { |
Nathanj94 | 1:a05d10d3d33f | 24 | Objects_x = 27; |
Nathanj94 | 1:a05d10d3d33f | 25 | } else if (Objects_ep == 3) { |
Nathanj94 | 1:a05d10d3d33f | 26 | Objects_x = 39; |
Nathanj94 | 1:a05d10d3d33f | 27 | } else if (Objects_ep == 4) { |
Nathanj94 | 1:a05d10d3d33f | 28 | Objects_x = 51; |
Nathanj94 | 1:a05d10d3d33f | 29 | } else if (Objects_ep == 5) { |
Nathanj94 | 1:a05d10d3d33f | 30 | Objects_x = 63; |
Nathanj94 | 1:a05d10d3d33f | 31 | } else { |
Nathanj94 | 1:a05d10d3d33f | 32 | Objects_x = 75; |
Nathanj94 | 1:a05d10d3d33f | 33 | } |
Nathanj94 | 1:a05d10d3d33f | 34 | } |
Nathanj94 | 1:a05d10d3d33f | 35 | |
Nathanj94 | 1:a05d10d3d33f | 36 | void Objects::Objects_draw(N5110 &lcd) |
Nathanj94 | 1:a05d10d3d33f | 37 | { |
Nathanj94 | 1:a05d10d3d33f | 38 | lcd.drawLine(Objects_x + 1, Objects_y, Objects_x + 4, Objects_y, 1); |
Nathanj94 | 1:a05d10d3d33f | 39 | lcd.drawLine(Objects_x, Objects_y + 1, Objects_x, Objects_y + 4, 1); |
Nathanj94 | 1:a05d10d3d33f | 40 | lcd.drawLine(Objects_x + 1, Objects_y + 5, Objects_x +4, Objects_y + 5, 1); |
Nathanj94 | 1:a05d10d3d33f | 41 | lcd.drawLine(Objects_x + 5, Objects_y + 1, Objects_x + 5, Objects_y + 4, 1); |
Nathanj94 | 1:a05d10d3d33f | 42 | } |
Nathanj94 | 1:a05d10d3d33f | 43 | |
Nathanj94 | 1:a05d10d3d33f | 44 | void Objects::Objects_move() |
Nathanj94 | 1:a05d10d3d33f | 45 | { |
Nathanj94 | 1:a05d10d3d33f | 46 | Objects_y += Objects_speed; |
Nathanj94 | 1:a05d10d3d33f | 47 | } |
Nathanj94 | 1:a05d10d3d33f | 48 | |
Nathanj94 | 1:a05d10d3d33f | 49 | int Objects::get_Objects_pos() |
Nathanj94 | 1:a05d10d3d33f | 50 | { |
Nathanj94 | 1:a05d10d3d33f | 51 | return Objects_y; |
Nathanj94 | 1:a05d10d3d33f | 52 | } |