-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kostia Kotliarov
committed
Aug 30, 2017
1 parent
bfb5702
commit 2df0bd4
Showing
6 changed files
with
54 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
#include "pacman.h" | ||
|
||
void checkPosition(t_pacman *pacman) | ||
{ | ||
extern int map[H][W]; | ||
|
||
// check if ghost and pacman on same position on map | ||
if ((pacman->red.ghostPos.x == pacman->pac.x && pacman->red.ghostPos.y == pacman->pac.y) || | ||
(pacman->blue.ghostPos.x == pacman->pac.x && pacman->blue.ghostPos.y == pacman->pac.y) || | ||
(pacman->yellow.ghostPos.x == pacman->pac.x && pacman->yellow.ghostPos.y == pacman->pac.y) || | ||
(pacman->pink.ghostPos.x == pacman->pac.x && pacman->pink.ghostPos.y == pacman->pac.y) ) | ||
{ | ||
pacman->pacmanLives--; | ||
if (pacman->pacmanLives == 0) | ||
{ | ||
putTextMessage(pacman, "You lose"); | ||
SDL_Delay(1500); | ||
exit(0); | ||
} | ||
|
||
// put to map previous value | ||
map[pacman->red.ghostPos.y][pacman->red.ghostPos.x] = pacman->red.ghostMapPreviousValue; | ||
map[pacman->blue.ghostPos.y][pacman->blue.ghostPos.x] = pacman->blue.ghostMapPreviousValue; | ||
map[pacman->pink.ghostPos.y][pacman->pink.ghostPos.x] = pacman->pink.ghostMapPreviousValue; | ||
map[pacman->yellow.ghostPos.y][pacman->yellow.ghostPos.x] = pacman->yellow.ghostMapPreviousValue; | ||
|
||
map[pacman->pac.y][pacman->pac.x] = 0; | ||
setDefaultPosition(pacman); | ||
|
||
putTextMessage(pacman, "Get Ready!"); | ||
SDL_Delay(1500); | ||
sdlRenderClear(pacman); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-269 Bytes
(99%)
...codeproj/project.xcworkspace/xcuserdata/kostia.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters