
A note hitting game for the mbed LPC 1768. User uses a joystick to hit notes as they come down the screen in 3 different lanes.
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
note_public.h@1:94b1ec213686, 2016-03-17 (annotated)
- Committer:
- jmpin
- Date:
- Thu Mar 17 21:12:59 2016 +0000
- Revision:
- 1:94b1ec213686
Game is pretty much finished, minus the sound coming from .wav files from the SD card
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmpin | 1:94b1ec213686 | 1 | #ifndef NOTE_PUBLIC_H |
jmpin | 1:94b1ec213686 | 2 | #define NOTE_PUBLIC_H |
jmpin | 1:94b1ec213686 | 3 | |
jmpin | 1:94b1ec213686 | 4 | //The note status |
jmpin | 1:94b1ec213686 | 5 | typedef enum { |
jmpin | 1:94b1ec213686 | 6 | NOTE_MISSED=3, //note has been missed |
jmpin | 1:94b1ec213686 | 7 | NOTE_PLAYED=2,//note has been played |
jmpin | 1:94b1ec213686 | 8 | NOTE_ACTIVE=1,//note is active |
jmpin | 1:94b1ec213686 | 9 | NOTE_DEACTIVE=0//note is no longer active |
jmpin | 1:94b1ec213686 | 10 | } NOTE_STATUS; |
jmpin | 1:94b1ec213686 | 11 | |
jmpin | 1:94b1ec213686 | 12 | // The structure to store the information of a note |
jmpin | 1:94b1ec213686 | 13 | typedef struct { |
jmpin | 1:94b1ec213686 | 14 | int x; // The x-coordinate of note's current position |
jmpin | 1:94b1ec213686 | 15 | int y; // The y-coordinate of note's current position |
jmpin | 1:94b1ec213686 | 16 | double source_x; // The x-coordinate of the note's origin |
jmpin | 1:94b1ec213686 | 17 | int tick; // The note's internal tick |
jmpin | 1:94b1ec213686 | 18 | int color; // The note's color |
jmpin | 1:94b1ec213686 | 19 | int lane; // Which lane is the note in |
jmpin | 1:94b1ec213686 | 20 | NOTE_STATUS status; // The note status, see NOTE_STATUS |
jmpin | 1:94b1ec213686 | 21 | } NOTE; |
jmpin | 1:94b1ec213686 | 22 | |
jmpin | 1:94b1ec213686 | 23 | #define MAX_NUM_NOTE 5 |
jmpin | 1:94b1ec213686 | 24 | |
jmpin | 1:94b1ec213686 | 25 | /** This function draws the notes onto the screen |
jmpin | 1:94b1ec213686 | 26 | Call note_generator() repeatedly in game-loop |
jmpin | 1:94b1ec213686 | 27 | */ |
jmpin | 1:94b1ec213686 | 28 | void note_generator(void); |
jmpin | 1:94b1ec213686 | 29 | |
jmpin | 1:94b1ec213686 | 30 | /** The function set the status of note to be NOTE_PLAYED |
jmpin | 1:94b1ec213686 | 31 | @param index The index in note_record. It must be smaller than MAX_NUM_NOTE. |
jmpin | 1:94b1ec213686 | 32 | */ |
jmpin | 1:94b1ec213686 | 33 | void note_set_played(int index); |
jmpin | 1:94b1ec213686 | 34 | |
jmpin | 1:94b1ec213686 | 35 | /** The function sets the status of note to be NOTE_MISSED |
jmpin | 1:94b1ec213686 | 36 | @param index The index in note_record. It must be smaller than MAX_NUM_NOTE. |
jmpin | 1:94b1ec213686 | 37 | */ |
jmpin | 1:94b1ec213686 | 38 | |
jmpin | 1:94b1ec213686 | 39 | void note_set_missed(int index); |
jmpin | 1:94b1ec213686 | 40 | |
jmpin | 1:94b1ec213686 | 41 | /** Get the information of a note |
jmpin | 1:94b1ec213686 | 42 | @param index The index in note_record. It must be smaller than MAX_NUM_NOTE. |
jmpin | 1:94b1ec213686 | 43 | @return The structure of note information |
jmpin | 1:94b1ec213686 | 44 | */ |
jmpin | 1:94b1ec213686 | 45 | |
jmpin | 1:94b1ec213686 | 46 | NOTE note_get_info(int index); |
jmpin | 1:94b1ec213686 | 47 | |
jmpin | 1:94b1ec213686 | 48 | /** Set the speed of notes, Speed has range of 1-8 with 1 being fastest and 8 being slowest |
jmpin | 1:94b1ec213686 | 49 | */ |
jmpin | 1:94b1ec213686 | 50 | void set_note_speed(int speed); |
jmpin | 1:94b1ec213686 | 51 | |
jmpin | 1:94b1ec213686 | 52 | /** Set the interval that the notes occur, interval has range of 1-100 with 1 being created in |
jmpin | 1:94b1ec213686 | 53 | very quick succession and 100 being created very slowly after one another |
jmpin | 1:94b1ec213686 | 54 | */ |
jmpin | 1:94b1ec213686 | 55 | void set_note_interval(int interval); |
jmpin | 1:94b1ec213686 | 56 | |
jmpin | 1:94b1ec213686 | 57 | /** The function set the color of note to be color |
jmpin | 1:94b1ec213686 | 58 | @param color The color in note_record. |
jmpin | 1:94b1ec213686 | 59 | */ |
jmpin | 1:94b1ec213686 | 60 | |
jmpin | 1:94b1ec213686 | 61 | void set_note_color(int index, int color); |
jmpin | 1:94b1ec213686 | 62 | |
jmpin | 1:94b1ec213686 | 63 | //The function updates the position of the notes on the board |
jmpin | 1:94b1ec213686 | 64 | void note_update_position(void); |
jmpin | 1:94b1ec213686 | 65 | |
jmpin | 1:94b1ec213686 | 66 | #endif //NOTE_PUBLIC_H |