MAIN CODE
#include "darkGDK.h"
#include "movement.h"
#include "mouse.h"
void DarkGDK()
{
dbSyncOn();
dbSyncRate(60);
dbDisableEscapeKey();
dbSetWindowTitle("Zombie Rampage 2D v1.0");
dbSetImageColorKey(95, 95, 95);
dbHideMouse();
//externals
movement movement;
mouse mouse;
//externals
dbLoadImage("player.bmp", 1);
dbLoadImage("enemy.bmp", 2);
dbLoadImage("pointer.bmp", 3);
dbLoadImage("doodad.bmp", 4);
dbLoadImage("ice_ball_skill.bmp", 5);
dbLoadImage("intro.bmp", 6);
dbLoadImage("loading0.bmp", 7);
dbSprite(1, 0, 0, 6);
int timer0 = 0, alpha = 100, phase = 0;
bool intro_done = false;
while(LoopGDK())
{
if(dbMouseClick() == 1 && intro_done == false && phase == 0)
{
dbSprite(2, 0, 0, 7);
dbSetSpritePriority(2, 1);
dbSetSpritePriority(1, 2);
intro_done = true;
}
if(intro_done == true && timer0 != 60 && phase == 0)
{
timer0++;
dbSetSpriteAlpha(1, alpha - 100/60 );
}
if(timer0 == 60 && intro_done == true && phase == 0)
{
dbDeleteSprite(2);
dbDeleteSprite(1);
dbDeleteImage(7);
dbDeleteImage(6);
phase = 1;
dbSprite(3, 320, 240, 1);
dbStretchSprite(3, 10, 10);
dbOffsetSprite(3, dbSpriteWidth(3)/2, dbSpriteHeight(3)/2);
}
//2nd loop
if(phase == 1)
{
movement.move();
mouse.pointer();
if(dbEscapeKey()==1)
{
break;
}
}
dbSync();
}
return;
}
MOVE CODE:
#include "movement.h"
#include "darkgdk.h"
#define ps 3
#define pss 2
movement::movement()
{
}
movement::~movement()
{
}
int movement::move()
{
if(dbSpriteExist(ps) == 1)
{
if(dbKeyState(17) == 1)
{
dbMoveSprite(ps, pss);
if(dbSpriteY(ps) <= 0)
{
dbRotateSprite(ps, 180);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
}
}
if(dbKeyState(30) == 1)
{
dbRotateSprite(ps, -90);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
if(dbSpriteX(ps) <= 0)
{
dbRotateSprite(ps, 90);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
}
}
if(dbKeyState(31) == 1)
{
dbRotateSprite(ps, 180);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
if(dbSpriteY(ps) >= 480)
{
dbMoveSprite(ps, pss);
}
}
if(dbKeyState(32) == 1)
{
dbRotateSprite(ps, 90);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
if(dbSpriteX(ps) >= 640)
{
dbRotateSprite(ps, -90);
dbMoveSprite(ps, pss);
dbRotateSprite(ps, 0);
}
}
}
return 0;
}
-Excellence deals with weak people-