Ok, here it is. I've attached the debug folder. The media is in the media folder. Note that this game was intended for a few friends of mine and for me to practice, so the gameplay makes little sense. I will also add the whole code so please see if you are able to compile it in release mode.
#include "DarkGDK.h"
static int x=400;
static int y=575;
int static hitl = 0;
int static hitr = 0;
bool static blownl=false;
bool static blownr=false;
//čakić sprite ID = 1
//background sprite ID = 2
//player sprite ID = 3
//bullet sprite ID = 4
//blood sprites ID = 5 - 16
//rayl sprite ID = 20
//rayr sprite ID = 21
//titlescreen ID = 30
//gameover label ID = 40
//gamewon label ID = 50
//sound ID's = 60 - 70
//instructions screen ID = 100
//story screen = 110
int lastl = dbTimer();
int lastr = dbTimer();
const int waitl = 3000;
static int waitr = 1500;
static bool shot = false;
static bool playerhit = false;
static int shotlcount = 0;
static int shotrcount = 0;
int spacepressed = 0;
static bool musicplaying = false;
static bool titleskipped = false;
//label sprites priority: IT'S OVER 9000!!!
//instructions sprite priority default=9000 >> 9002
void display(){
dbSetDisplayMode (800,600,32);
dbSetWindowOff();
}
void titlescreen(){
dbLoadImage("media\\titlescreen.png",30);
dbSprite(30,0,0,30);
dbSetSpritePriority(30,9001);
}
void instructions(){
dbLoadImage("media\\instructions.png",100);
dbSprite (100,0,0,100);
dbSetSpritePriority (100,9000);
}
void story(){
dbLoadImage("media\\story.png",110);
dbSprite(110,0,0,110);
dbSetSpritePriority(110,9000);
}
void load_sounds(){
dbLoadMusic ("media\\All Along The Watchtower.mp3",61);
dbLoadMusic ("media\\beat.mp3",62);
dbLoadMusic ("media\\shot.mp3",63);
dbLoadMusic ("media\\ray.mp3",64);
dbLoadMusic ("media\\applause3.mp3",65);
dbSetMusicVolume (63,75);
dbSetMusicVolume (64,50);
}
void background_music(){
dbLoopMusic (62);
}
void background(){
dbLoadImage ("media\\Apple_Black.jpg",2);
dbSprite (2,0,0,2);
dbSizeSprite (2,800,600);
}
void load_cakic(){ //this is the image of the guy that goes on the background
dbLoadImage("media\\čakić.jpg",1);
dbSprite(1,200,0,1);
dbSizeSprite (1,400,600);
dbSetSpritePriority (1,1);
}
void load_player(){
dbLoadImage ("media\\ship7.png",3);
dbSprite (3,x,y,3);
dbSizeSprite (3,80,50);
dbOffsetSprite (3,40,25);
dbSetSpritePriority (3,100);
}
void create_player(){ //this crates the small player ship at the bottom of the screen
if (playerhit == false){
dbSprite (3,x,y,3);
}
}
void move_player(){
if (dbKeyState(30)==1 || dbKeyState(203)==1){ //left
x=x-4;
}
if (dbKeyState(32)==1 || dbKeyState(205)==1){ //right
x=x+4;
}
}
void shoot(){ //this part lets the player shoot bolts
dbLoadImage ("media\\bolt.png",4);
bool static BulletOn;
bool static HoldKey;
if ((dbKeyState(57)==1 || dbKeyState(200)==1 || dbKeyState(17)==1) && HoldKey==false && BulletOn==false && spacepressed>=9 && playerhit==false){
dbStopMusic(63);
dbPlayMusic(63);
dbSprite (4,x,y-15,4);
dbSizeSprite (4,20,30);
dbRotateSprite (4,rand()%(8)-4);
HoldKey=true;
BulletOn=true;
}
if (dbKeyState(57)==false){
HoldKey=false;
if (dbSpriteY(4)<=0){
BulletOn=false;
}
}
dbMoveSprite (4,10);
dbOffsetSprite (4,10,15);
dbSetSpritePriority(4,99);
}
void collision(){ //this is where i make the bolts disappear if they hit the eye, as long as the eye is not blown up yet.
if (dbSpriteX(4)>=352-20 && dbSpriteX(4)<=352+20 && dbSpriteY(4)>=265-30 && dbSpriteY(4)<=265+10 && blownl==false){
dbDeleteSprite(4);
hitl++;
}
if (dbSpriteX(4)>=435-20 && dbSpriteX(4)<=435+20 && dbSpriteY(4)>=265-30 && dbSpriteY(4)<=265+10 && blownr==false){
dbDeleteSprite(4);
hitr++;
}
}
void load_blood(){ //blood effects
dbLoadImage ("media\\Bloodl1.png",5);
dbLoadImage ("media\\Bloodl2.png",6);
dbLoadImage ("media\\Bloodr1.png",7);
dbLoadImage ("media\\Bloodr2.png",8);
dbLoadImage ("media\\Bloodl3.png",9);
dbLoadImage ("media\\Bloodl4.png",10);
dbLoadImage ("media\\Bloodr3.png",11);
dbLoadImage ("media\\Bloodr4.png",12);
dbLoadImage ("media\\Bloodl5.png",13);
dbLoadImage ("media\\Bloodl6.png",14);
dbLoadImage ("media\\Bloodr5.png",15);
dbLoadImage ("media\\Bloodr6.png",16);
}
void add_blood(){ //adds blood effects depending on how many times you have hit the left ot the right eye.
if (hitl==3){
dbSprite (5,351,269,5);
dbOffsetSprite (5,16.5,8);
dbSetSpritePriority (5,5);
}
if (hitl==6){
dbSprite (6,351,269,6);
dbOffsetSprite (6,17,8.5);
dbSetSpritePriority (6,6);
dbDeleteSprite (5);
}
if (hitr==3){
dbSprite (7,436,268,7);
dbOffsetSprite (7,18,9);
dbSetSpritePriority (7,5);
}
if (hitr==6){
dbSprite (8,435.5,269,8);
dbOffsetSprite (8,18,9.5);
dbSetSpritePriority (8,6);
dbDeleteSprite(7);
}
if (hitl==9){
dbSprite (9,351,269,9);
dbOffsetSprite (9,17,8.5);
dbSetSpritePriority (9,6);
dbDeleteSprite(6);
}
if (hitl==12){
dbSprite (10,351,269,10);
dbOffsetSprite (10,17,8.5);
dbSetSpritePriority (10,6);
dbDeleteSprite(9);
}
if (hitr==9){
dbSprite (11,437,269,11);
dbOffsetSprite (11,19,9.5);
dbSetSpritePriority (11,6);
dbDeleteSprite(8);
}
if (hitr==12){
dbSprite (12,437,269,12);
dbOffsetSprite (12,19,9.5);
dbSetSpritePriority (12,6);
dbDeleteSprite(11);
}
if (hitl==15){
dbSprite (13,351,269.5,13);
dbOffsetSprite (13,17,8.5);
dbSetSpritePriority (13,6);
dbDeleteSprite(10);
}
if (hitl==20){
dbSprite (14,351,269,14);
dbOffsetSprite (14,26.5,20);
dbSetSpritePriority (14,6);
dbDeleteSprite(13);
blownl=true;
}
if (hitr==15){
dbSprite (15,437,269,15);
dbOffsetSprite (15,19,9.5);
dbSetSpritePriority (15,6);
dbDeleteSprite(12);
}
if (hitr==20){
dbSprite (16,437,269,16);
dbOffsetSprite (16,27,21.5);
dbSetSpritePriority (16,6);
dbDeleteSprite(12);
blownr=true;
}
}
void load_ray(){ //this is the laser that is supposed to shoot out of the guy's eyes
dbLoadImage ("media\\bolt2.png",20);
}
void make_rayl(){
dbSprite(20,352,265,20);
dbSizeSprite(20,24,24);
dbOffsetSprite(20,12,12);
dbRotateSprite(20,rand()%(60)+150);
dbSetSpritePriority(20,100);
}
void make_rayr(){
dbSprite(21,435,265,20);
dbSizeSprite(21,24,24);
dbOffsetSprite(21,12,12);
dbRotateSprite(21,rand()%(60)+150);
dbSetSpritePriority(21,100);
}
void time_rayl(){
int currentl = dbTimer();
if ((currentl - lastl) >= waitl && blownl == false){
dbStopMusic(64);
lastl = currentl;
shotlcount++;
dbPlayMusic(64);
make_rayl();
}
}
void time_rayr(){
int currentr = dbTimer();
if ((currentr - lastr) >= waitr && blownr == false){
dbStopMusic(64);
lastr = currentr;
shot = true;
shotrcount++;
dbPlayMusic(64);
make_rayr();
}
if (shotrcount == 2){
waitr = 3000;
}
}
void shoot_rays(){
dbMoveSprite (20,8);
dbMoveSprite (21,8);
}
void game_over(){
dbDeleteMusic (62);
dbPlayMusic (65);
dbLoadImage ("media\\youlose.png",40);
dbSprite (40,0,0,40);
dbSetSpritePriority (40,9001);
dbSetMusicVolume(64,0);
}
void load_win(){
dbLoadImage ("media\\youwin.png",50);
}
void game_won(){
if (blownl==true && blownr==true && musicplaying==false){
musicplaying = true;
dbDeleteMusic (62);
dbPlayMusic(61);
dbSprite (50,0,0,50);
dbSetSpritePriority (50,9001);
dbSetMusicVolume(63,0);
}
}
void collision2(){
if (dbSpriteX(20) <= x+35 && dbSpriteX(20) >= x-35 && dbSpriteY(20) <= y+20 && dbSpriteY(20) > y-20 && shotlcount >=2){
playerhit=true;
dbDeleteSprite(3);
game_over();
}
if (dbSpriteX(21) >= x-35 && dbSpriteX(21) <= x+35 && dbSpriteY(21) <= y+20 && dbSpriteY(21) >= y-20 && shotrcount >=2){
playerhit=true;
dbDeleteSprite(3);
game_over();
}
}
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbRandomize(dbTimer());
display();
dbHideMouse();
titlescreen();
instructions();
story();
load_cakic();
background();
load_player();
load_blood();
load_ray();
load_win();
load_sounds();
// our main loop
while ( LoopGDK ( ) )
{
if (dbKeyState(23) == 1) dbSetSpritePriority (100,9002);
if (dbKeyState(31) == 1) dbSetSpritePriority (110,9002);
if (dbKeyState(50) == 1){
dbSetSpritePriority (100,9000);
dbSetSpritePriority (110,9000);
}
if (dbKeyState(57) == 1 || titleskipped == true){
if (dbKeyState(57) ==1 || dbKeyState(200)==1 || dbKeyState(17)==1) spacepressed++;
titleskipped = true;
dbDeleteSprite(30);
dbDeleteSprite(100);
dbDeleteSprite(110);
background_music();
create_player();
move_player();
shoot();
collision();
add_blood();
time_rayl();
time_rayr();
shoot_rays();
collision2();
game_won();
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}
I just love the smell of code in the morning...