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 4DGL-uLCD-SE MMA8452
main.cpp@3:0e14def93d4e, 2019-03-15 (annotated)
- Committer:
- Yehowshua Immanuel
- Date:
- Fri Mar 15 20:46:37 2019 -0400
- Revision:
- 3:0e14def93d4e
- Parent:
- 1:47394b602697
- Child:
- 4:fb7d49e660f2
draws dirt and grass
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Yehowshua | 0:2f4225a589d1 | 1 | #include "mbed.h" |
| Yehowshua | 0:2f4225a589d1 | 2 | #include "uLCD_4DGL.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 3 | #include "Sprites/main_character/main_character.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 4 | #include "hash_table/hash_table.h" |
| Yehowshua Immanuel |
3:0e14def93d4e | 5 | #include "worlds/worlds.h" |
| Yehowshua | 0:2f4225a589d1 | 6 | |
| Yehowshua | 0:2f4225a589d1 | 7 | uLCD_4DGL uLCD(p9, p10, p11); // serial tx, serial rx, reset pin; |
| Yehowshua Immanuel |
1:47394b602697 | 8 | Serial pc(USBTX, USBRX); |
| Yehowshua | 0:2f4225a589d1 | 9 | |
| Yehowshua | 0:2f4225a589d1 | 10 | |
| Yehowshua Immanuel |
1:47394b602697 | 11 | |
| Yehowshua Immanuel |
1:47394b602697 | 12 | //key function |
| Yehowshua Immanuel |
1:47394b602697 | 13 | unsigned int genKey(unsigned int key){ |
| Yehowshua Immanuel |
1:47394b602697 | 14 | return key%97; |
| Yehowshua Immanuel |
1:47394b602697 | 15 | } |
| Yehowshua | 0:2f4225a589d1 | 16 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 17 | DigitalOut myled(LED2); |
| Yehowshua Immanuel |
3:0e14def93d4e | 18 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 19 | void initWorlds(void){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 20 | initialize_sprites(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 21 | allocate_worlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 22 | populate_worlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 23 | } |
| Yehowshua | 0:2f4225a589d1 | 24 | |
| Yehowshua | 0:2f4225a589d1 | 25 | int main() { |
| Yehowshua | 0:2f4225a589d1 | 26 | //increase BAUD rate |
| Yehowshua | 0:2f4225a589d1 | 27 | uLCD.baudrate(3000000); |
| Yehowshua | 0:2f4225a589d1 | 28 | uLCD.background_color(WHITE); |
| Yehowshua Immanuel |
3:0e14def93d4e | 29 | initWorlds(); |
| Yehowshua Immanuel |
3:0e14def93d4e | 30 | sprite* ret_sprite; |
| Yehowshua | 0:2f4225a589d1 | 31 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 32 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 33 | for(int y = 0; y < 8; y+=1){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 34 | for(int x = 0; x < 8; x+=1){ |
| Yehowshua Immanuel |
3:0e14def93d4e | 35 | //uLCD.BLIT(j,i,16,16,main_character.render.activeSkin); |
| Yehowshua Immanuel |
3:0e14def93d4e | 36 | ret_sprite = (sprite*)fetchSprite(x,y); |
| Yehowshua Immanuel |
3:0e14def93d4e | 37 | if(ret_sprite == NULL) |
| Yehowshua Immanuel |
3:0e14def93d4e | 38 | continue; |
| Yehowshua Immanuel |
3:0e14def93d4e | 39 | uLCD.BLIT(x*16,y*16,16,16,(*ret_sprite).render.activeSkin); |
| Yehowshua Immanuel |
1:47394b602697 | 40 | |
| Yehowshua Immanuel |
3:0e14def93d4e | 41 | } |
| Yehowshua Immanuel |
3:0e14def93d4e | 42 | } |
| Yehowshua Immanuel |
1:47394b602697 | 43 | |
| Yehowshua | 0:2f4225a589d1 | 44 | main_character_constructor(); |
| Yehowshua | 0:2f4225a589d1 | 45 | //main_character_i(); |
| Yehowshua | 0:2f4225a589d1 | 46 | while(1) { |
| Yehowshua | 0:2f4225a589d1 | 47 | myled = 1; |
| Yehowshua | 0:2f4225a589d1 | 48 | wait(0.2); |
| Yehowshua | 0:2f4225a589d1 | 49 | myled = 0; |
| Yehowshua | 0:2f4225a589d1 | 50 | wait(0.2); |
| Yehowshua | 0:2f4225a589d1 | 51 | } |
| Yehowshua | 0:2f4225a589d1 | 52 | } |