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 DarkGDK() { //Window title dbSetWindowTitle("Color The Box!"); //Introduction dbPrint(); dbPrint("Please enter a color to view the box."); dbPrint(); //Variables int Red, Green, Blue; DWORD black = dbRGB(0, 0, 0); //Statement/set color Red = atoi( dbInput() ); Green = atoi( dbInput() ); Blue = atoi( dbInput() ); DWORD usercolor = dbRGB(Red, Green, Blue); //Declare color dbInk(usercolor, black); //Draw the box dbBox(150, 100, 450, 500); //Wait for user to press a key dbWaitKey(); }
void DarkGDK ( void ) { dbSyncOn ( ); dbSyncRate ( 60 ); dbDisableEscapeKey(); SetCurrentDirectory("GameContents"); dbSetWindowTitle("Gaming Level"); int xCord = 0; int yCord = 0; int direction = 2; //up = 1, down = 2, left = 3, right = 4; int finished = 0; //Used to state whether the game has ended house.setWorld("stage1",xCord,yCord); dbColorBackdrop(dbRGB(0,0,0)); house.finishedPntr = &finished; while ( LoopGDK ( ) && !finished) { movePersonOrWorld(xCord, yCord, direction); //dbCenterText(510,80,dbStr(dbMouseX())); //dbCenterText(550,80,dbStr(dbMouseY())); // update the screen dbSync ( ); } return; }
void DarkGDK() { //Set variables int X; int Y; //Window title dbSetWindowTitle("Treasure Map"); //Set key color dbSetImageColorKey(0, 255, 0); //Load image dbLoadImage("treasure map.bmp", 1); //Display image dbPasteImage(1, 0, 0); //Enter X coordinate dbPrint("Please enter the X coordinate for treasure!"); X = atoi( dbInput() ); //Enter Y coordinate dbPrint("Please enter the Y coordinate for treasure!"); Y = atoi( dbInput() ); DWORD red = dbRGB(255, 0, 0); DWORD black = dbRGB(0, 0, 0); dbInk(red, black); //Draw the X dbLine(X-10, Y-10, X+10, Y+10); dbLine(X-10, Y+10, X+10, Y-10); //Wait for user to press a key dbWaitKey(); }
void world::endingScreen(void *classPointer) { //Like a large version of our printText function dbWait(500); char messageTotal[1000] = "Player..."; char messageTemp[100] = ""; int totalLength = strlen(messageTotal); int tempLength = 0; int iteration = 0; int numberCharsToEnd = 0; dbSetTextSize(52); for(tempLength; LoopGDK() && tempLength <= totalLength; tempLength++) { messageTemp[tempLength] = messageTotal[tempLength]; dbWait(200); dbText(200,80,messageTemp); dbSync(); } while(dbKeyState(57) != 1) { //Show the message, with the blinking period controlled by your computer time. Waiting for you to press space. if((dbTimer()/1000) % 2 == 1) { messageTemp[tempLength-2] = '\0'; } else { messageTemp[tempLength-2] = '.'; } dbCLS(); dbWait(40); dbText(200,80,messageTemp); dbSync(); } dbCLS(); strcpy(messageTotal,"Thank you very much for playing. This game has been coded in C++, one of my favorite languages, and it has been a blast to program. I hope you have enjoyed it as much as I have. I also wish to congratulate you on finding out the password. Either you're amazing at guessing, or you found the secret note... What an odd place to put it too..."); totalLength = strlen(messageTotal); for(int i = 0; i <= totalLength; i++) { //Loop through our main message if(((i+1)+numberCharsToEnd) % 26 == 0) { //So if the next character in the string is going to hit the edge (if it's divisible by 26 with no remainders) (Plus our difference which we'll talk about later. if(messageTotal[i+1] == ' ') { //first check if our next character is a space. If so, then just change it out for a \n messageTotal[i+1] = '\n'; } else { //I guess it wasn't. Now let's check to see if there's a space behind us, at most 26 characters away. Let's also make sure that we stop if we reach 0. (Then no spaces behind us) for(int j = i; j >= 0 && iteration < 26; j--) { if(messageTotal[j] == ' ') { //We found a character that's both a space and within our limits! Now we make it \n, tell the program that we found one by setting iteration to 0, //And add the difference between our previous end of line, to our numberCharsToEnd variable. messageTotal[j] = '\n'; iteration = 0; numberCharsToEnd = ((i+1)+numberCharsToEnd)-(j+1); //The j-1 makes it so our lines align properly. break; } iteration++; //we didn't find any spaces this round, so let's keep looking. Since I'm looking further, I increment my variable to say how far back I'm looking. (remember 26) } } if(iteration != 0) { //It looks like we didn't find any spaces. I guess we'll have to chop the word in half so it doesn't run off of the page (our only option) for(int j = totalLength; j >= i; j--) { //Move everything over to the right by 1. messageTotal[j+1] = messageTotal[j]; } totalLength++; //Remember: by moving everything over by 1, we made the string size 1 larger. messageTotal[i] = '\n'; //now insert our \n where we have our emprty space from moving everything over. (Technically our first duplicated space) iteration = 0; //Now, make sure to reset our iteration variable } } }//End for i for(int i = 500; i > -720 && LoopGDK(); i-=2) { //Move our text up the screen. dbCLS(); dbWait(40); dbText(0,i,messageTotal); dbSync(); } strcpy(messageTotal,"Thank you for playing"); for(int i = 0; i <= 255 && LoopGDK(); i+=5){ //Fade our message in dbInk(dbRGB(i,i,i),dbRGB(0,0,0)); dbCLS(); dbWait(40); dbCenterText(310,150,messageTotal); dbSync(); } for(int i = 255; i >= 0 && LoopGDK(); i-=5){ //Fade our message out dbInk(dbRGB(i,i,i),dbRGB(0,0,0)); dbCLS(); dbWait(40); dbCenterText(310,150,messageTotal); dbSync(); } *(static_cast<world*>(classPointer)->finishedPntr) = 1; //You WON!!! YAY! Now let's tell the main darkGDK function that you won. }
void world::passGuess(char triggerName[], void *classPointer) { int *currentXCord = static_cast<world*>(classPointer)->currentX; int *currentYCord = static_cast<world*>(classPointer)->currentY; int numbers = 0; char messageTotal[150] = "Well you seem to have the\nurge to leave. Why not stay\nfor a bit though? If you\ntruly want to go, then\nsimply guess the password:"******""; int spaceBar = 0; int correctPassword = 0; dbSyncOn ( ); dbSyncRate ( 60 ); dbLoadImage("textBackground.png",numberOfImages+1); dbLoadImage("passwordBackground.png",numberOfImages+2); while(LoopGDK() && numbers <= 6){ //Now we have to sustain our environment again. dbWait(10); //How quick the message is typed //dbCenterText(30,90,dbStr(dbMouseX())); //dbCenterText(30,120,dbStr(dbMouseY())); static_cast<world*>(classPointer)->updateWorld(*currentXCord,*currentYCord); //Let's send our xCord and yCord that we got to our class. dbPasteImage((numberOfImages+1),385,0); dbPasteImage((numberOfImages+2),405,200); if(messageCharLength < totalLength) { //Just like in our printText function messageTemp[messageCharLength] = messageTotal[messageCharLength]; messageTemp[messageCharLength+1] = '\0'; messageCharLength++; } if(dbMouseClick() == 1) { if((dbMouseX() >= 449) && (dbMouseX() <= 472) && (dbMouseY() >= 273) && (dbMouseY() <= 297)) { //If our mouse is over the 1 button strncat(passwordInput,"1",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 500) && (dbMouseX() <= 523) && (dbMouseY() >= 273) && (dbMouseY() <= 297)) { //If our mouse is over the 2 button strncat(passwordInput,"2",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 552) && (dbMouseX() <= 575) && (dbMouseY() >= 273) && (dbMouseY() <= 297)) { //If our mouse is over the 3 button strncat(passwordInput,"3",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 449) && (dbMouseX() <= 472) && (dbMouseY() >= 306) && (dbMouseY() <= 330)) { //If our mouse is over the 4 button strncat(passwordInput,"4",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 500) && (dbMouseX() <= 523) && (dbMouseY() >= 306) && (dbMouseY() <= 330)) { //If our mouse is over the 5 button strncat(passwordInput,"5",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 552) && (dbMouseX() <= 575) && (dbMouseY() >= 306) && (dbMouseY() <= 330)) { //If our mouse is over the 6 button strncat(passwordInput,"6",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 449) && (dbMouseX() <= 472) && (dbMouseY() >= 339) && (dbMouseY() <= 363)) { //If our mouse is over the 7 button strncat(passwordInput,"7",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 500) && (dbMouseX() <= 523) && (dbMouseY() >= 339) && (dbMouseY() <= 363)) { //If our mouse is over the 8 button strncat(passwordInput,"8",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 552) && (dbMouseX() <= 575) && (dbMouseY() >= 339) && (dbMouseY() <= 363)) { //If our mouse is over the 9 button strncat(passwordInput,"9",1); numbers++; dbPlaySound(12); } else if((dbMouseX() >= 500) && (dbMouseX() <= 523) && (dbMouseY() >= 372) && (dbMouseY() <= 396)) { //If our mouse is over the 0 button strncat(passwordInput,"0",1); numbers++; dbPlaySound(12); } dbWait(300); } if(numbers == 7) { //Now let's create a local instance of our world for the new mesage strcpy(messageTemp,""); if(strcmp(passwordInput,"1433434") == 0) {//Now let's check to see if they got the password correct strcpy(messageTotal,"Congratulations! That's\nthe right password!"); correctPassword++; dbInk(dbRGB(0,255,0),dbRGB(0,0,0)); dbPlaySound(14); } else { strcpy(messageTotal,"Sorry, but that's not the\npassword. Please try again."); dbInk(dbRGB(255,0,0),dbRGB(0,0,0)); dbPlaySound(13); } totalLength = strlen(messageTotal); messageCharLength = 0; while(LoopGDK() && spaceBar == 0) { dbWait(10); static_cast<world*>(classPointer)->updateWorld(*currentXCord,*currentYCord); //Let's send our xCord and yCord that we got to our class. dbPasteImage((numberOfImages+1),385,0); dbPasteImage((numberOfImages+2),405,200); if(messageCharLength < totalLength) { //Lets loop through our message again. messageTemp[messageCharLength] = messageTotal[messageCharLength]; messageTemp[messageCharLength+1] = '\0'; messageCharLength++; } if(dbKeyState(57) == 1) { spaceBar++; } dbSetTextSize(36); if(correctPassword == 1) { dbCenterText(512,12,"Correct"); dbCenterText(512,42,"Password!:"); } else { dbCenterText(512,12,"Incorrect"); dbCenterText(512,42,"Password:"******"Guess The"); dbCenterText(512,42,"Password:"); dbSetTextSize(12); dbText(395,85,messageTemp); dbSetTextSize(36); dbText(455,220,passwordInput); dbSync(); } } if(correctPassword == 1){ for(int i = 0; i <= 100; i++) { dbDeleteSprite(i); dbSync(); } endingScreen(classPointer); //Go to the ending screen, since you won! } dbWait(300); }
//************************************************ // 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(); }