This is Pacman.h
-------------------------------------------------------------
#pragma once
int X = 320;
int Y = 240;
//Pacman implementation
#include "DarkGDK.h"
#include <time.h>
#include "Sprites.h"
#include "Input.h"
#include "Pacman.h"
//#define DELTA 100
enum Direction {Left, Right, Up, Down, Stop};
Direction MyDirection = Stop;
//Controls the movement of Pacman
void PacmanMove()
{
if ( CheckLeft() )
MyDirection = Left;
else if ( CheckRight() )
MyDirection = Right;
else if (CheckUp())
MyDirection = Up;
else if (CheckDown())
MyDirection = Down;
if ( MyDirection == Left )
{
//Delete Pacman_still sprite
dbDeleteSprite ( 2 );
//Show animated sprite
//dbSetSpriteImage ( 4, 4 );
//Controls the position of Pacman
//dbPlaySprite ( ID, start frame, end frame, delay );
dbSprite ( 4, X, Y, 4 );
dbShowSprite ( 4 );
dbPlaySprite ( 4, 1, 2, 200 );
//Decrement PacMan
X = X - 2;
if (dbSpriteVisible ( 3 ))
dbHideSprite ( 3 );
else if (dbSpriteVisible ( 5 ) )
dbHideSprite ( 5 );
else if (dbSpriteVisible ( 6 ) )
dbHideSprite (6);
}
else if ( MyDirection == Right )
{
//Delete Pacman_still sprite
dbDeleteSprite ( 2 );
//Show animated sprite
//dbSetSpriteImage ( 3, 3 );
//Controls the position of Pacman
dbSprite ( 3, X, Y, 3 );
dbShowSprite ( 3 );
dbPlaySprite ( 3, 1, 2, 200 );
//Increment PacMan
X = X + 2;
if (dbSpriteVisible ( 4 ))
dbHideSprite ( 4 );
else if (dbSpriteVisible ( 5 ) )
dbHideSprite ( 5 );
else if (dbSpriteVisible ( 6 ) )
dbHideSprite (6);
}
else if ( MyDirection == Up )
{
//Delete Pacman_still sprite
dbDeleteSprite ( 2 );
//Show animated sprite
//dbSetSpriteImage ( 5, 5 );
//Controls the position of Pacman
dbSprite ( 5, X, Y, 5 );
dbShowSprite ( 5 );
dbPlaySprite ( 5, 1, 2, 200 );
Y = Y - 2;
if (dbSpriteVisible ( 3 ))
dbHideSprite ( 3 );
else if (dbSpriteVisible ( 4 ) )
dbHideSprite ( 4 );
else if (dbSpriteVisible ( 6 ) )
dbHideSprite (6);
}
else if ( MyDirection == Down )
{
//Delete Pacman_still sprite
dbDeleteSprite ( 2 );
//Show animated sprite
//dbSetSpriteImage ( 6, 6 );
//Controls the position of Pacman
dbSprite ( 6, X, Y, 6 );
dbShowSprite ( 6 );
dbPlaySprite ( 6, 1, 2, 200 );
Y = Y + 2;
if (dbSpriteVisible ( 3 ))
dbHideSprite ( 3 );
else if (dbSpriteVisible ( 5 ) )
dbHideSprite ( 5 );
else if (dbSpriteVisible ( 4 ) )
dbHideSprite (4);
}
}