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: 4DGL-uLCD-SE mbed wave_player
Fork of PacMan_Skeleton_unlock by
ghost.h
00001 /* Gatech ECE2035 2015 SPRING PAC MAN 00002 * Copyright (c) 2015 Gatech ECE2035 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 /** @file ghost.h */ 00023 #ifndef GHOST_H 00024 #define GHOST_H 00025 00026 #include "mbed.h" 00027 //#include "uLCD_4DGL.h" 00028 #include "ghost.h " 00029 #include "map_public.h " 00030 #include "globals.h" 00031 #include "pacman.h " 00032 #include "doubly_linked_list.h " 00033 00034 extern uLCD_4DGL uLCD; 00035 00036 00037 /// The enum defines the motion of a ghost 00038 typedef enum { 00039 GHOST_UP=0, ///< move up 00040 GHOST_DOWN, ///< move down 00041 GHOST_LEFT, ///< move left 00042 GHOST_RIGHT, ///< move right 00043 GHOST_DIED 00044 } GHOST_MOTION; 00045 00046 00047 /// This struct contains the status of a ghost 00048 typedef struct 00049 { 00050 unsigned int x; ///< horizontal position in the grid 00051 unsigned int y; ///< vertical position in the grid 00052 unsigned int color; ///< color of the ghost 00053 GHOST_MOTION ghost_motion; ///< the motion of the ghost 00054 } GHOST; 00055 00056 //Initialize an empty doublely linked list 00057 void ghost_init(void); 00058 00059 /** Create a ghost with given position and color. Then add to the ghost doublely linked list 00060 @param blk_x The horizontal position in the grid. 00061 @param blk_y The vertical position in the grid. 00062 @param color Color of the ghost 00063 */ 00064 void ghost_create(unsigned int blk_x, unsigned int blk_y, unsigned int color); 00065 00066 /** Draw the ghost in the linked list on the screen 00067 */ 00068 void ghost_show(DLinkedList* list); 00069 00070 /** Move every ghost in the list randomly on the map for one step 00071 */ 00072 void ghost_random_walk(void); 00073 00074 /** Return the doubly linked list of ghost 00075 */ 00076 DLinkedList* get_ghost_list(void); 00077 00078 int ghost_collision(DLinkedList* list, int x, int y, int invuln); 00079 00080 00081 /** Extra Feature Function: 00082 Create a super ghost with given position and color. Then add to the super ghost doublely linked list 00083 A super ghost is itself a max-size-3 linked list. A super ghost is itself a linked list. The head always 00084 walk randomly while the other two node keep track of the two lastest history position. 00085 @param blk_x The horizontal position in the grid. 00086 @param blk_y The vertical position in the grid. 00087 @param color Color of the ghost 00088 */ 00089 void super_ghost_create(unsigned int blk_x, unsigned int blk_y, unsigned int color); 00090 00091 /** Extra Feature Function: 00092 Move the super ghost in the list randomly on the map for one step 00093 */ 00094 void super_ghost_random_walk(void); 00095 00096 /** Extra Feature Function: 00097 Return the doubly linked list of super ghost 00098 */ 00099 DLinkedList* get_super_ghost_list(void); 00100 #endif //GHOST_H
Generated on Thu Aug 4 2022 06:03:35 by
1.7.2
