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
pacman.h@0:be33a1fad8c0, 2017-02-24 (annotated)
- Committer:
- conantina
- Date:
- Fri Feb 24 17:33:27 2017 +0000
- Revision:
- 0:be33a1fad8c0
- Child:
- 1:fbda247b843b
PacMan_Skeleton for student
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| conantina | 0:be33a1fad8c0 | 1 | /* Gatech ECE2035 2015 SPRING PAC MAN |
| conantina | 0:be33a1fad8c0 | 2 | * Copyright (c) 2015 Gatech ECE2035 |
| conantina | 0:be33a1fad8c0 | 3 | * |
| conantina | 0:be33a1fad8c0 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| conantina | 0:be33a1fad8c0 | 5 | * of this software and associated documentation files (the "Software"), to deal |
| conantina | 0:be33a1fad8c0 | 6 | * in the Software without restriction, including without limitation the rights |
| conantina | 0:be33a1fad8c0 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| conantina | 0:be33a1fad8c0 | 8 | * copies of the Software, and to permit persons to whom the Software is |
| conantina | 0:be33a1fad8c0 | 9 | * furnished to do so, subject to the following conditions: |
| conantina | 0:be33a1fad8c0 | 10 | * |
| conantina | 0:be33a1fad8c0 | 11 | * The above copyright notice and this permission notice shall be included in |
| conantina | 0:be33a1fad8c0 | 12 | * all copies or substantial portions of the Software. |
| conantina | 0:be33a1fad8c0 | 13 | * |
| conantina | 0:be33a1fad8c0 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| conantina | 0:be33a1fad8c0 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| conantina | 0:be33a1fad8c0 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| conantina | 0:be33a1fad8c0 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| conantina | 0:be33a1fad8c0 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| conantina | 0:be33a1fad8c0 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| conantina | 0:be33a1fad8c0 | 20 | * SOFTWARE. |
| conantina | 0:be33a1fad8c0 | 21 | */ |
| conantina | 0:be33a1fad8c0 | 22 | /** @file pacman.h */ |
| conantina | 0:be33a1fad8c0 | 23 | #ifndef PACMAN_H |
| conantina | 0:be33a1fad8c0 | 24 | #define PACMAN_H |
| conantina | 0:be33a1fad8c0 | 25 | |
| conantina | 0:be33a1fad8c0 | 26 | #define PACMAN_COLOR 0xFFFFFF |
| conantina | 0:be33a1fad8c0 | 27 | |
| conantina | 0:be33a1fad8c0 | 28 | /// The enum defines the status of a pacman |
| conantina | 0:be33a1fad8c0 | 29 | typedef enum { |
| conantina | 0:be33a1fad8c0 | 30 | PACMAN_WAIT_COMMAND=0, |
| conantina | 0:be33a1fad8c0 | 31 | PACMAN_RUNNING |
| conantina | 0:be33a1fad8c0 | 32 | } PACMAN_STATUS; |
| conantina | 0:be33a1fad8c0 | 33 | |
| conantina | 0:be33a1fad8c0 | 34 | /// The enum defines the motion of a pacman |
| conantina | 0:be33a1fad8c0 | 35 | typedef enum { |
| conantina | 0:be33a1fad8c0 | 36 | PACMAN_NO_UPDATE=0, |
| conantina | 0:be33a1fad8c0 | 37 | PACMAN_HEADING_UP, |
| conantina | 0:be33a1fad8c0 | 38 | PACMAN_HEADING_DOWN, |
| conantina | 0:be33a1fad8c0 | 39 | PACMAN_HEADING_RIGHT, |
| conantina | 0:be33a1fad8c0 | 40 | PACMAN_HEADING_LEFT |
| conantina | 0:be33a1fad8c0 | 41 | } PACMAN_MOTION; |
| conantina | 0:be33a1fad8c0 | 42 | |
| conantina | 0:be33a1fad8c0 | 43 | /// This struct contains the status of a pacman |
| conantina | 0:be33a1fad8c0 | 44 | typedef struct { |
| conantina | 0:be33a1fad8c0 | 45 | int grid_x; ///< The position of pacman on the grid |
| conantina | 0:be33a1fad8c0 | 46 | int grid_y; ///< The position of pacman on the grid |
| conantina | 0:be33a1fad8c0 | 47 | PACMAN_MOTION motion; |
| conantina | 0:be33a1fad8c0 | 48 | PACMAN_STATUS status; ///< See enum CITY_STATUS |
| conantina | 0:be33a1fad8c0 | 49 | } PLAYER; |
| conantina | 0:be33a1fad8c0 | 50 | |
| conantina | 0:be33a1fad8c0 | 51 | /** Initialize a pacman with given position. The default mostion is PACMAN_HEADING_RIGHT |
| conantina | 0:be33a1fad8c0 | 52 | and status is PACMAN_WAIT_COMMAND. |
| conantina | 0:be33a1fad8c0 | 53 | @param blk_x The horizontal position in the grid. |
| conantina | 0:be33a1fad8c0 | 54 | @param blk_y The vertical position in the grid. |
| conantina | 0:be33a1fad8c0 | 55 | */ |
| conantina | 0:be33a1fad8c0 | 56 | void pacman_init(int grid_x, int grid_y); |
| conantina | 0:be33a1fad8c0 | 57 | |
| conantina | 0:be33a1fad8c0 | 58 | /** Draw the pacman on the screen with different mouse direction base on current motion |
| conantina | 0:be33a1fad8c0 | 59 | */ |
| conantina | 0:be33a1fad8c0 | 60 | void pacman_draw(void); |
| conantina | 0:be33a1fad8c0 | 61 | |
| conantina | 0:be33a1fad8c0 | 62 | // Clear the pacman in map |
| conantina | 0:be33a1fad8c0 | 63 | void pacman_clear(void); |
| conantina | 0:be33a1fad8c0 | 64 | |
| conantina | 0:be33a1fad8c0 | 65 | /** Set the pacman's motion according to the input mostion |
| conantina | 0:be33a1fad8c0 | 66 | @param motion The desired pacman motion. |
| conantina | 0:be33a1fad8c0 | 67 | */ |
| conantina | 0:be33a1fad8c0 | 68 | void pacman_set_action(PACMAN_MOTION motion); |
| conantina | 0:be33a1fad8c0 | 69 | |
| conantina | 0:be33a1fad8c0 | 70 | // Update the pacman's position in map |
| conantina | 0:be33a1fad8c0 | 71 | void pacman_update_position(void); |
| conantina | 0:be33a1fad8c0 | 72 | |
| conantina | 0:be33a1fad8c0 | 73 | |
| conantina | 0:be33a1fad8c0 | 74 | #endif |
