my problem is that i don't know how i can do so that if my player touch the box he die, can anyone please help.
#include "DarkGDK.h"
#include "Dinput.h"
#include <stdio.h>
struct BOX
{
bool active;
int x,y,speed;
}Box[1000];
int Timer=0;
int PlayerJumpSpeed = 3;
bool PlayGameMenu = false;
bool PlayerJumped = false;
bool GameIsDead = false;
bool PlayerIsFalling=true;
void GamePlayer(void)
{
int PlayerY=dbSpriteY(1);
if (PlayerIsFalling==true)
{
if(PlayerY < 400)
{
dbMoveSprite(1,-PlayerJumpSpeed);
PlayerIsFalling = true;
}else if (PlayerY >= 400) {PlayerJumped=false;}
}
if (dbSpaceKey()==true && PlayerY >= 360 && PlayerJumped==false)
{
PlayerJumped=true;
dbMoveSprite(1,120);
}
}
void GameDie(void)
{
dbText(100,200,"Hejs");
}
void GameHighScore(void)
{
}
void GameStart(void)
{
GamePlayer();
dbHideSprite(4);
dbHideSprite(5);
dbHideSprite(7);
for (int i=0;i<1000;i++)
{
Box[i].x-=Box[i].speed;
if (Box[i].active) dbPasteSprite(3,Box[i].x,Box[i].y);
if (Box[i].x<0) Box[i].active=false;
}
if (Timer<0)
{
int g;
for (g=0;g<1000;g++) if (!Box[g].active) break;
if (g<1000)
{
Box[g].active=true;
Box[g].x=800;
Box[g].y=400;
Box[g].speed=2;
Timer=dbRnd(30)+40;
}
}else Timer--;
}
void GameMenu(void)
{
if (PlayGameMenu == true)
{
GameStart();
}
if (PlayGameMenu != true)
{
dbBackdropOn();
dbColorBackdrop(dbRGB(0,90,101));
int MouseX, MouseY;
dbSprite(4,275,150,4);
dbSprite(5,260,250,5);
dbSprite(7,250,0,6);
MouseX = dbMouseX();
MouseY = dbMouseY();
if (dbMouseClick() == true)
{
if (MouseX >= 275 && MouseX <= 320 && MouseY >= 148 && MouseY <= 200)
{
dbShowSprite(1);
PlayGameMenu = true;
}else if (MouseX >= 260 && MouseX <= 335 && MouseY >= 248 && MouseY <= 300)
{
GameHighScore();
}
}
}
}
void Game(void)
{
GameMenu();
}
void DarkGDK ( void )
{
dbSyncRate(60);
dbSyncOn();
dbSetWindowSize(800,600);
dbSetWindowTitle("Jumper");
dbSetImageColorKey(255,0,255);
dbLoadImage("Player.bmp",1);
dbLoadImage("Box_down.bmp",2);
dbLoadImage("Line.bmp",3);
dbLoadImage("Play_button.bmp",4);
dbLoadImage("HighScore_button.bmp",5);
dbLoadImage("Front_logo.bmp",6);
dbSprite(3,400,400,2);
dbSprite(1,100,400,1);
dbHideSprite(3);
dbHideSprite(1);
while ( LoopGDK ( ) )
{
Game();
dbSync();
dbScreenFPS();
}
return;
}
Beginner In the Language.