Hi ^^ I'm new in this forum. I know the basic on C++ and I and my friends we create a 2D game with the Dark GDK. This is my first code:
// Include la libreria Dark GDK
#include "DarkGDK.h"
#include "DarkSDKMusic.h"
#include "DarkSDKInput.h"
#include "xeeyadv.h"
/////////////////////////////
// DICHIARAZIONE VARIABILI //
/////////////////////////////
int score=0,rings=0,timem=0,times=0,timed=0;
// Inizializza il gioco
void DarkGDK ()
{
dbSyncOn (); //Questo si occuperà dell'aggiornamento dello schermo
dbSyncRate (60); //Setta il numero di FPS (MAX 60)
dbDisableEscapeKey (); //Disabilita il tasto ESC
dbRandomize (dbTimer()); //Inizializza il random
dbSetDisplayMode (640, 480, 32); //Risoluzione e profondita' della finestra
SetCurrentDirectory ( "data" ); //Imposta come directory principale la seguente cartella specificata
dbBackdropOn();
dbColorBackdrop(0);
dbHideMouse();
maintitle();
return;
}
void maintitle()
{
//Carica una sprite (Spritenumber, file, frame orizzontali, frame verticali, ID sprite)
dbCreateAnimatedSprite ( 0x001, "mainmenu\\layer1.png", 1, 1, 0x001);
dbCreateAnimatedSprite ( 0x002, "mainmenu\\layer2.png", 1, 1, 0x002);
dbTextureObject(0x102, 0x002);
dbSetObjectTransparency(0x102, 255);
dbLoadMusic ("musics\\title.mp3", 0xF01);
int posx=0, posy=0;
dbPlayMusic (0xF01);
while (LoopGDK ()) //Loop del gioco
{
dbPasteSprite (0x001, posx, posy); //Visualizza la sprite (ID sprite, X, Y)
dbPasteSprite (0x002, 0, 0); //Visualizza la sprite (ID sprite, X, Y)
posx--; posy--;
if (posx==-256)
{
posx=0; posy=0;
}
dbSync ();
}
}
void testtime()
{
//dbText (10,10, "Score %i\n",score);
//dbText (10,10, "Rings %i\n",rings);
//dbText (10,10, "Time %i:%i:%i",timem,times,timed);
timed++;
if (timed==99)
{
times++;
timed=0;
}
if (times==59)
{
timem++;
times=0;
}
}
The problem is that i don't know how do the fadein/fadeout, how to manage the keyboard (for example press enter for clean the first menu and go to second menu of the game) and manage the collision. I want create a platform game (for example Sonic or SuperMario). Thanks for the reply =) and excuse me for bad english