void DarkGDK() { //Set variables int centerX = dbScreenWidth() / 2; int centerY = dbScreenHeight() / 2; int leftX = centerX - HALF; int topY = centerY - HALF; int rightX = centerX + HALF; int lowerY = centerY + HALF; //Set the window's title dbSetWindowTitle("Octagon Pattern"); //Set colors DWORD black = dbRGB(0, 0, 0); DWORD red = dbRGB(255, 0, 0); //Draw the Octagons using the variables dbInk(red, black); drawOctagon(leftX, topY); drawOctagon(leftX, lowerY); drawOctagon(rightX, topY); drawOctagon(rightX, lowerY); //Wait for the user to press a key dbWaitKey(); }
void BiPlaneGameUI::addPlayerSpeedo(void) { // Get the ID Handling singlton MyIdHandler* mih = &MyIdHandler::get(); // Grab some ID's for the speedo and needle (one for the image, one for the sprite) this->speedoImageId = mih->getImageId(); this->speedoSpriteId = mih->getSpriteId(); this->speedoNeedleImageId = mih->getImageId(); this->speedoNeedleSpriteId = mih->getSpriteId(); // Load the resources dbLoadImage("Media/speedo.png", this->speedoImageId, 1); dbLoadImage("Media/needle.png", this->speedoNeedleImageId, 1); // Define the speedo sprite dbSprite(this->speedoSpriteId, 0, 0, this->speedoImageId); dbHideSprite(this->speedoSpriteId); dbSetSpriteAlpha(this->speedoSpriteId, 33); // Define the needle sprite, offsetting it's center so it pivots nicely dbSprite(this->speedoNeedleSpriteId, 0, 0, this->speedoNeedleImageId); dbHideSprite(this->speedoNeedleSpriteId); dbOffsetSprite(this->speedoNeedleSpriteId, 43, 12); dbSetSpriteAlpha(this->speedoNeedleSpriteId, 33); // Define the position of the speedo... this->speedoX = dbScreenWidth() - dbSpriteWidth(this->speedoSpriteId) - 16; this->speedoY = dbScreenHeight() - dbSpriteHeight(this->speedoSpriteId) - 16; // ... an the needle this->needleX = this->speedoX + (dbSpriteWidth(this->speedoSpriteId) / 2); this->needleY = this->speedoY + (dbSpriteHeight(this->speedoSpriteId) / 2); }
void drawScanlines(int linesBetween ) { int screenHeight = dbScreenHeight(); int screenWidth = dbScreenWidth(); dbInk( RGB(0,0,0), RGB(0,0,0) ); int currentLine = 0; while( currentLine < screenHeight ) { currentLine += linesBetween; dbLine( 0, currentLine, screenWidth, currentLine ); } }
void DarkGDK ( void ) { dbSetWindowPosition ( dbScreenWidth()/3 , dbScreenHeight()/6); dbSyncOn ( ); dbSyncRate ( 60 ); dbSetWindowSize (800, 600); dbSetWindowTitle ( "Labyrinth V 1.0"); dbDisableEscapeKey ( ); dbRandomize ( dbTimer ( ) ); dbCLS(); //Play(); Menu(); //Mazemain(2); return; }
//************************************************ // DarkGDK function * //************************************************ void DarkGDK() { const int BOX_SIZE = dbScreenWidth() / 10; DWORD red = dbRGB(255, 0, 0); DWORD white = dbRGB(255,255,255); int left = 0, top=0, right = left + BOX_SIZE, bottom = top + BOX_SIZE; bool odd = true; for (int i = 0; i < dbScreenWidth(); i += BOX_SIZE) { for (int j = 0; j < dbScreenWidth(); j += BOX_SIZE) { if (odd) { dbInk(red, white); // set drawing color to red (2nd parm is ignored) dbBox(left, top, right, bottom); // draw box at indicated position left += BOX_SIZE; right += BOX_SIZE; dbInk(white, red); // set drawing color to white (2nd parm is ignored) dbBox(left, top, right, bottom); // draw box at indicated position left += BOX_SIZE; right += BOX_SIZE; } else { dbInk(white, red); // set drawing color to white (2nd parm is ignored) dbBox(left, top, right, bottom); // draw box at indicated position left += BOX_SIZE; right += BOX_SIZE; dbInk(red, white); // set drawing color to red (2nd parm is ignored) dbBox(left, top, right, bottom); // draw box at indicated position left += BOX_SIZE; right += BOX_SIZE; } } if (odd) { odd = false; } else { odd = true; } left = 0, top += BOX_SIZE, right = left + BOX_SIZE, bottom = top + BOX_SIZE; } // Wait for the user to press a key. dbWaitKey(); }
// the main entry point for the application is this function void DarkGDK ( void ){ // Seed the random number generator srand(time(NULL)); // Configure the engine to run as fast as possible (no frame rate cap) dbSyncOn(); dbSyncRate(0); // If fullscreen, configure to a, currently, hard coded setting if (FULLSCREEN) { dbSetWindowOff(); dbMaximizeWindow(); dbSetDisplayModeAntialias(1680, 1050, 32, 1, 0, 0); dbSetCameraAspect(0, 1680.0 / 1050.0); } // Otherwise, configure a windowed display else { dbSetDisplayModeAntialias(1280, 800, 32, 1, 0, 0); dbSetCameraAspect(0, 1280.0 / 800.0); int winPosX = (dbDesktopWidth() - dbScreenWidth()) / 2; int winPosY = (dbDesktopHeight() - dbScreenHeight()) / 2; dbSetWindowPosition(winPosX, winPosY); } // Hide the mouse pointer; CEGUI handles this dbHideMouse(); // This forces the timer to initialise MyTimer *timer = &MyTimer::get(); float t; // Create a new Game State - this is a general game controlling class BiPlaneGameState *gsGame = new BiPlaneGameState(); // We'll need a start-up menu StartMenuGameState *gsMenu = new StartMenuGameState(); // a Loop State holder bool loopState = TRUE; // This is for the Start Menu loop //while (LoopGDK()) { do { // Tick the timer & frame rate for this loop timer->tick(); t = timer->getT(); dbText(0, 0, dbStr((float)(1.0 / t))); loopState &= gsGame->update(t); loopState &= gsMenu->update(t); dbSync(); } while (loopState && LoopGDK()); switch (gsMenu->getState()) { // Start Server case 1 : break; // Start Client case 2 : break; // SOMETHING WENT WRONG!! default : exit(-5); } loopState = TRUE; // our main loop //while (LoopGDK()) { do { // Tick the timer & frame rate for this loop timer->tick(); t = timer->getT(); dbText(0, 0, dbStr((float)(1.0 / t))); // Issue an Update to the GameState system, passing the frameTime into it loopState &= gsGame->update(t); // Update the display dbSync(); } while (loopState && LoopGDK()); // Do a little house keeping delete gsGame; delete gsMenu; return; }