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 wave_player 4DGL-uLCD-SE MMA8452
city_landscape_public.h@0:09aa1ecd6c39, 2020-06-24 (annotated)
- Committer:
- lwills
- Date:
- Wed Jun 24 21:09:03 2020 +0000
- Revision:
- 0:09aa1ecd6c39
- Child:
- 1:5724f2947554
Missile Command shell
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lwills | 0:09aa1ecd6c39 | 1 | // ================================================================= |
| lwills | 0:09aa1ecd6c39 | 2 | // The header file is for module "city landscape" |
| lwills | 0:09aa1ecd6c39 | 3 | // |
| lwills | 0:09aa1ecd6c39 | 4 | // Copyright 2020 Georgia Tech. All rights reserved. |
| lwills | 0:09aa1ecd6c39 | 5 | // The materials provided by the instructor in this course are for |
| lwills | 0:09aa1ecd6c39 | 6 | // the use of the students currently enrolled in the course. |
| lwills | 0:09aa1ecd6c39 | 7 | // Copyrighted course materials may not be further disseminated. |
| lwills | 0:09aa1ecd6c39 | 8 | // This file must not be made publicly available anywhere. |
| lwills | 0:09aa1ecd6c39 | 9 | //================================================================== |
| lwills | 0:09aa1ecd6c39 | 10 | /** @file city_landscape_public.h */ |
| lwills | 0:09aa1ecd6c39 | 11 | #ifndef CITY_LANDSCAPE_PUBLIC_H |
| lwills | 0:09aa1ecd6c39 | 12 | #define CITY_LANDSCAPE_PUBLIC_H |
| lwills | 0:09aa1ecd6c39 | 13 | |
| lwills | 0:09aa1ecd6c39 | 14 | /// The enum define the status of a city |
| lwills | 0:09aa1ecd6c39 | 15 | typedef enum { |
| lwills | 0:09aa1ecd6c39 | 16 | EXIST=1, ///< The city will be shown on screen |
| lwills | 0:09aa1ecd6c39 | 17 | DEMOLISHED=0 ///< The city won't be shown on screen |
| lwills | 0:09aa1ecd6c39 | 18 | } CITY_STATUS; |
| lwills | 0:09aa1ecd6c39 | 19 | |
| lwills | 0:09aa1ecd6c39 | 20 | /// The structure to store the information of a city |
| lwills | 0:09aa1ecd6c39 | 21 | typedef struct { |
| lwills | 0:09aa1ecd6c39 | 22 | int x; ///< Bottom-left corner of the city. x coordinate on the screen. |
| lwills | 0:09aa1ecd6c39 | 23 | int y; ///< Bottom-left corner of the city. y coordinate on the screen. |
| lwills | 0:09aa1ecd6c39 | 24 | int width; ///< The width of the city. The shape of the city is a rectangle. |
| lwills | 0:09aa1ecd6c39 | 25 | int height; ///< The height of the city |
| lwills | 0:09aa1ecd6c39 | 26 | CITY_STATUS status; ///< See enum CITY_STATUS |
| lwills | 0:09aa1ecd6c39 | 27 | } CITY; |
| lwills | 0:09aa1ecd6c39 | 28 | |
| lwills | 0:09aa1ecd6c39 | 29 | #define MAX_NUM_CITY 6 |
| lwills | 0:09aa1ecd6c39 | 30 | |
| lwills | 0:09aa1ecd6c39 | 31 | /** Call city_landscape_init() only once at the begining of your code |
| lwills | 0:09aa1ecd6c39 | 32 | @param num_city number of cities to be drawn. It must be less/equal to MAX_NUM_CITY. |
| lwills | 0:09aa1ecd6c39 | 33 | */ |
| lwills | 0:09aa1ecd6c39 | 34 | void city_landscape_init(int num_city); |
| lwills | 0:09aa1ecd6c39 | 35 | |
| lwills | 0:09aa1ecd6c39 | 36 | /** Get the information of city |
| lwills | 0:09aa1ecd6c39 | 37 | @param index The index in city_record. It must be smaller than MAX_NUM_CITY. |
| lwills | 0:09aa1ecd6c39 | 38 | @return The structure of city information |
| lwills | 0:09aa1ecd6c39 | 39 | */ |
| lwills | 0:09aa1ecd6c39 | 40 | CITY city_get_info(int index); |
| lwills | 0:09aa1ecd6c39 | 41 | |
| lwills | 0:09aa1ecd6c39 | 42 | /** Remove the city from record and screen |
| lwills | 0:09aa1ecd6c39 | 43 | @param index The index in city_record. It must be smaller than MAX_NUM_CITY. |
| lwills | 0:09aa1ecd6c39 | 44 | */ |
| lwills | 0:09aa1ecd6c39 | 45 | void city_demolish(int index); |
| lwills | 0:09aa1ecd6c39 | 46 | |
| lwills | 0:09aa1ecd6c39 | 47 | /** Draw all exist cities onto the screen |
| lwills | 0:09aa1ecd6c39 | 48 | @brief You might not need to use this function, but you could still use it if you want. |
| lwills | 0:09aa1ecd6c39 | 49 | */ |
| lwills | 0:09aa1ecd6c39 | 50 | void draw_cities(void); |
| lwills | 0:09aa1ecd6c39 | 51 | |
| lwills | 0:09aa1ecd6c39 | 52 | /** Draw the landscape |
| lwills | 0:09aa1ecd6c39 | 53 | @brief You might not need to use this function, but you could still use it if you want. |
| lwills | 0:09aa1ecd6c39 | 54 | */ |
| lwills | 0:09aa1ecd6c39 | 55 | void draw_landscape(void); |
| lwills | 0:09aa1ecd6c39 | 56 | |
| lwills | 0:09aa1ecd6c39 | 57 | |
| lwills | 0:09aa1ecd6c39 | 58 | #endif //CITY_LANDSCAPE_H |