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
main.cpp@7:15543cb10a14, 2019-02-23 (annotated)
- Committer:
- el17cd
- Date:
- Sat Feb 23 17:45:43 2019 +0000
- Revision:
- 7:15543cb10a14
- Parent:
- 6:75031d14fc0d
- Child:
- 8:a667bc5050c1
Working rotation in y axis!!!!!
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17cd | 0:efb5eec6b8ea | 1 | /* |
| el17cd | 0:efb5eec6b8ea | 2 | ELEC2645 Embedded Systems Project |
| el17cd | 0:efb5eec6b8ea | 3 | School of Electronic & Electrical Engineering |
| el17cd | 0:efb5eec6b8ea | 4 | University of Leeds |
| el17cd | 0:efb5eec6b8ea | 5 | Name: Christopher Doel |
| el17cd | 0:efb5eec6b8ea | 6 | Username: el17cd |
| el17cd | 0:efb5eec6b8ea | 7 | Student ID Number: 201146223 |
| el17cd | 0:efb5eec6b8ea | 8 | Date: 22/02/19 |
| el17cd | 0:efb5eec6b8ea | 9 | */ |
| el17cd | 0:efb5eec6b8ea | 10 | |
| el17cd | 0:efb5eec6b8ea | 11 | #include "mbed.h" |
| el17cd | 1:044238f7bdda | 12 | #include <vector> |
| el17cd | 4:759a5c34e239 | 13 | #ifndef FACE_H |
| el17cd | 4:759a5c34e239 | 14 | #define FACE_H |
| el17cd | 3:2e31dfcb712a | 15 | #include "Face.h" |
| el17cd | 4:759a5c34e239 | 16 | #endif |
| el17cd | 4:759a5c34e239 | 17 | #include "Rasturizer.h" |
| el17cd | 4:759a5c34e239 | 18 | #include "Cube.h" |
| el17cd | 6:75031d14fc0d | 19 | #include "Gamepad.h" |
| el17cd | 3:2e31dfcb712a | 20 | |
| el17cd | 0:efb5eec6b8ea | 21 | |
| el17cd | 6:75031d14fc0d | 22 | Gamepad gamepad; |
| el17cd | 0:efb5eec6b8ea | 23 | int main() |
| el17cd | 0:efb5eec6b8ea | 24 | { |
| el17cd | 6:75031d14fc0d | 25 | |
| el17cd | 6:75031d14fc0d | 26 | gamepad.init(); |
| el17cd | 4:759a5c34e239 | 27 | Rasturizer renderer; |
| el17cd | 7:15543cb10a14 | 28 | Cube cube1(-30,0,100,3); |
| el17cd | 7:15543cb10a14 | 29 | Cube cube2(30,0,100,3); |
| el17cd | 7:15543cb10a14 | 30 | Cube cube3(-30,0,50,3); |
| el17cd | 7:15543cb10a14 | 31 | Cube cube4(30,0,50,3); |
| el17cd | 7:15543cb10a14 | 32 | |
| el17cd | 6:75031d14fc0d | 33 | |
| el17cd | 4:759a5c34e239 | 34 | int i = 0; |
| el17cd | 1:044238f7bdda | 35 | while(1) { |
| el17cd | 4:759a5c34e239 | 36 | renderer.clear(); |
| el17cd | 6:75031d14fc0d | 37 | //if (i == 6) |
| el17cd | 6:75031d14fc0d | 38 | // i = 0; |
| el17cd | 6:75031d14fc0d | 39 | for (int i = 0; i < 6; i++){ |
| el17cd | 6:75031d14fc0d | 40 | renderer.drawFace(cube1.getFace(i)); |
| el17cd | 6:75031d14fc0d | 41 | } |
| el17cd | 6:75031d14fc0d | 42 | for (int i = 0; i < 6; i++){ |
| el17cd | 6:75031d14fc0d | 43 | renderer.drawFace(cube2.getFace(i)); |
| el17cd | 6:75031d14fc0d | 44 | } |
| el17cd | 7:15543cb10a14 | 45 | for (int i = 0; i < 6; i++){ |
| el17cd | 7:15543cb10a14 | 46 | renderer.drawFace(cube3.getFace(i)); |
| el17cd | 7:15543cb10a14 | 47 | } |
| el17cd | 7:15543cb10a14 | 48 | for (int i = 0; i < 6; i++){ |
| el17cd | 7:15543cb10a14 | 49 | renderer.drawFace(cube4.getFace(i)); |
| el17cd | 7:15543cb10a14 | 50 | } |
| el17cd | 7:15543cb10a14 | 51 | |
| el17cd | 6:75031d14fc0d | 52 | |
| el17cd | 6:75031d14fc0d | 53 | Vector2D coord = gamepad.get_coord(); |
| el17cd | 7:15543cb10a14 | 54 | cube1.translate(-coord.x*3,0,-coord.y*3); |
| el17cd | 7:15543cb10a14 | 55 | cube2.translate(-coord.x*3,0,-coord.y*3); |
| el17cd | 7:15543cb10a14 | 56 | cube3.translate(-coord.x*3,0,-coord.y*3); |
| el17cd | 7:15543cb10a14 | 57 | cube4.translate(-coord.x*3,0,-coord.y*3); |
| el17cd | 7:15543cb10a14 | 58 | |
| el17cd | 6:75031d14fc0d | 59 | |
| el17cd | 7:15543cb10a14 | 60 | if(gamepad.check_event(Gamepad::B_PRESSED) == true){ |
| el17cd | 7:15543cb10a14 | 61 | cube1.rotateX(0.2); |
| el17cd | 7:15543cb10a14 | 62 | cube2.rotateX(0.2); |
| el17cd | 7:15543cb10a14 | 63 | cube3.rotateX(0.2); |
| el17cd | 7:15543cb10a14 | 64 | cube4.rotateX(0.2); |
| el17cd | 7:15543cb10a14 | 65 | } |
| el17cd | 7:15543cb10a14 | 66 | if( gamepad.check_event(Gamepad::X_PRESSED) == true){ |
| el17cd | 7:15543cb10a14 | 67 | cube1.rotateX(-0.2); |
| el17cd | 7:15543cb10a14 | 68 | cube2.rotateX(-0.2); |
| el17cd | 7:15543cb10a14 | 69 | cube3.rotateX(-0.2); |
| el17cd | 7:15543cb10a14 | 70 | cube4.rotateX(-0.2); |
| el17cd | 7:15543cb10a14 | 71 | } |
| el17cd | 6:75031d14fc0d | 72 | |
| el17cd | 4:759a5c34e239 | 73 | renderer.refresh(); // refresh the LCD so the pixels appear |
| el17cd | 6:75031d14fc0d | 74 | wait_ms(1000/15); // this gives a refresh rate of 10 frames per second |
| el17cd | 6:75031d14fc0d | 75 | //i++; |
| el17cd | 0:efb5eec6b8ea | 76 | } |
| el17cd | 0:efb5eec6b8ea | 77 | } |