Oh my god... sorry i meant compile in release mode (excuse the n00b).
Here's the code:
#include "DarkGDK.h"
int x=400;
int y=550;
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
void display(){
dbSetDisplayMode (800,600,32);
}
void background(){
dbLoadImage ("Apple_Black.jpg",2);
dbSprite (2,0,0,2);
dbSizeSprite (2,800,600);
}
void load_cakic(){
dbLoadImage("čakić.jpg",1);
dbSprite(1,200,0,1);
dbSizeSprite (1,400,600);
dbSetSpritePriority (1,1);
}
void load_player(){
dbLoadImage ("ship7.png",3);
}
void create_player(){
dbSprite (3,x,y,3);
dbSizeSprite (3,80,50);
dbOffsetSprite (3,40,25);
dbSetSpritePriority (3,100);
}
void move_player(){
if (dbKeyState(30)==1){ //levo
x=x-4;
}
if (dbKeyState(32)==1){ //desno
x=x+4;
}
}
void shoot(){
dbLoadImage ("bolt2.png",4);
bool static BulletOn;
bool static HoldKey;
if (dbKeyState(57)==1&&HoldKey==false&&BulletOn==false){
dbSprite (4,x,y-15,4);
dbSizeSprite (4,20,30);
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(){
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(){
dbLoadImage ("Bloodl1.png",5);
dbLoadImage ("Bloodl2.png",6);
dbLoadImage ("Bloodr1.png",7);
dbLoadImage ("Bloodr2.png",8);
dbLoadImage ("Bloodl3.png",9);
dbLoadImage ("Bloodl4.png",10);
dbLoadImage ("Bloodr3.png",11);
dbLoadImage ("Bloodr4.png",12);
dbLoadImage ("Bloodl5.png",13);
dbLoadImage ("Bloodl6.png",14);
dbLoadImage ("Bloodr5.png",15);
dbLoadImage ("Bloodr6.png",16);
}
void add_blood(){
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(){
dbLoadImage ("bolt.png",20);
}
void shoot_rayl(){
}
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
display();
load_cakic();
background();
load_player();
load_blood();
// our main loop
while ( LoopGDK ( ) )
{
create_player();
move_player();
shoot();
collision();
add_blood();
// update the screen
dbSync ( );
}
// return back to windows
return;
}
In the program, i load a big picture of a guy named čakić on to the middle of the screen, on the bottom i put the player ship from the tgc Dark Invaders tutorial and make i shoot lasers towards the top of the screen. If they hit the left ot the right eye of the čakić sprite then hitl (hit left) or hitr (hit right) increases. And as those increase i add blood efects by putting new sprites on the screen. Thats abou it for now. The ray function is empty cause i don't know how to make it yet (i'll ask in another thread). Trying to make the čakić sprite shoot lasers from it's eyes.
Thnk you!