finished p2-2

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Committer:
levelsnake3
Date:
Mon Apr 26 00:30:47 2021 +0000
Revision:
2:7abebe259d59
Parent:
0:95264f964374
finalAdv;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DCchico 0:95264f964374 1 //=================================================================
DCchico 0:95264f964374 2 // The header file defining the fruit module
DCchico 0:95264f964374 3 //
DCchico 0:95264f964374 4 // Copyright 2020 Georgia Tech. All rights reserved.
DCchico 0:95264f964374 5 // The materials provided by the instructor in this course are for
DCchico 0:95264f964374 6 // the use of the students currently enrolled in the course.
DCchico 0:95264f964374 7 // Copyrighted course materials may not be further disseminated.
DCchico 0:95264f964374 8 // This file must not be made publicly available anywhere.
DCchico 0:95264f964374 9 //==================================================================
DCchico 0:95264f964374 10 /** @file fruit_public.h */
DCchico 0:95264f964374 11 #ifndef FRUIT_PUBLIC_H
DCchico 0:95264f964374 12 #define FRUIT_PUBLIC_H
DCchico 0:95264f964374 13
DCchico 0:95264f964374 14 #include "doubly_linked_list.h"
DCchico 0:95264f964374 15 #include "graphics.h"
DCchico 0:95264f964374 16
DCchico 0:95264f964374 17 typedef enum {
DCchico 0:95264f964374 18 FRUIT_SLICED=0,
DCchico 0:95264f964374 19 FRUIT_ACTIVE=1,
DCchico 0:95264f964374 20 } FRUIT_STATUS;
DCchico 0:95264f964374 21
DCchico 0:95264f964374 22 typedef void (*DrawFunc)(boundingBox b);
DCchico 0:95264f964374 23
DCchico 0:95264f964374 24 /// The structure to store the information of a fruit
DCchico 0:95264f964374 25 typedef struct {
DCchico 0:95264f964374 26 boundingBox box;
DCchico 0:95264f964374 27 double delta_x; // moving unit in x dir
DCchico 0:95264f964374 28 double delta_y; // moving unit in y dir
DCchico 0:95264f964374 29 double source; ///< The x or y-coordinate of the fruit's origin
DCchico 0:95264f964374 30 double target; ///< The x or y-coordinate of the fruit's target
DCchico 0:95264f964374 31 int direction; // 0: N->S, 1: E->W, 2: W->E
DCchico 0:95264f964374 32 int type; // Orange, Banana, etc
DCchico 0:95264f964374 33 int tick; ///< The fruit's internal tick
DCchico 0:95264f964374 34 FRUIT_STATUS status; ///< The fruit status, see FRUIT_STATUS
DCchico 0:95264f964374 35 DrawFunc draw;
DCchico 0:95264f964374 36 } FRUIT;
DCchico 0:95264f964374 37
DCchico 0:95264f964374 38 /** Call fruit_init() only once at the begining of your code */
DCchico 0:95264f964374 39 void fruit_init(void);
DCchico 0:95264f964374 40
DCchico 0:95264f964374 41 /** This function draw the fruits onto the screen
DCchico 0:95264f964374 42 Call fruit_generator() repeatedly in your game-loop. ex: main()
DCchico 0:95264f964374 43 */
levelsnake3 2:7abebe259d59 44 void difficultyMode(int n);
levelsnake3 2:7abebe259d59 45
DCchico 0:95264f964374 46 void fruit_generator(void);
DCchico 0:95264f964374 47
DCchico 0:95264f964374 48 /** This function will return a linked-list of all active fruit structures.
DCchico 0:95264f964374 49 This can be used to modify the active fruits. Marking fruits with status
DCchico 0:95264f964374 50 FRUIT_SLICED will cue their erasure from the screen and removal from the
DCchico 0:95264f964374 51 list at the next fruit_generator() call.
DCchico 0:95264f964374 52 */
DCchico 0:95264f964374 53 DLinkedList* get_fruit_list();
DCchico 0:95264f964374 54
DCchico 0:95264f964374 55 #endif //FRUIT_PUBLIC_H