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