Beispiel #1
0
void Player::Draw(sf::RenderWindow& window)
{

	// Call the object version of Draw first
	Object::Draw(window);

	sf::Text hpbar(std::to_string(hp), resources.GetFont());
	hpbar.setPosition(nextPosition.x-10, nextPosition.y-40);

	sf::Text ammobar(std::to_string(bullets), resources.GetFont());
	ammobar.setPosition(nextPosition.x-10, nextPosition.y+25);


	window.draw(hpbar);
	window.draw(ammobar);

	
}
Beispiel #2
0
char questions(int *x,int *bar)
{   
	static char questions[35][500]={"Constructors are inherited in derive classes in c++.True or False?",
	"You can\'t separate classes in different files in c++. True or False?",
	"A special function in a class that is called when a new object of the class is created.",
	"A constructor which creates an object by initializing it with an object of the same class, which has been created previously.",
	"Destructors deletes the object including the class. True or False?",
	"What can travel around the world while staying in a corner?",
	"What room can no one enter?",
    "In school, the pure ones always tell the truth and the corrupted always tell a lie. Which of them could make the following statement?\n\n\t\'I always tell the truth.'",
    "A function is said to be _________ if it is one-to-one.",
    "Data ______ is one of the important features of Object Oriented Programming which prevents the functions of a program to access directly the internal representation of a class type.",
    "What will be the output of the program?\n\n\tstatic char *s[] = {""black, white, pink, violet""};\n\tchar **ptr[] = {s+3, s+2, s+1, s}, ***p;\n\tp = ptr;\n\t++p;\n\tprintf(""%s"", **p+1);\n\treturn 0;",
    "Liz baked some cookies and left them by the window to cool off.\nWhen she went back the cookies were gone and saw Jim, Reese, Chuck, and Zoey pass by. One of them took the Liz's cookies. The theif told exactly one truth and one lie.\n\nJim said it was Reese not Chuck.\nReese said it was Chuck not Jim.\nChuck said it was Zoey not Jim.\nZoey said it was Chuck not Reese.\n\nWho stole Liz's cookies?",
    "What will be the content of 'file.c' after executing the following program?\n\n\tFILE *fp1, *fp2;\n\tfp1=fopen(""file.c"", ""w"");\n\tfp2=fopen(""file.c"", ""w"");\n\tfputc('A', fp1);\n\tfputc('B', fp2);\n\tfclose(fp1);\n\tfclose(fp2);\n\treturn 0;",
      "What day comes three days after the day which comes two days after the day which comes immediately after the day which comes two days after Monday?",
      "What will be the output of the program ?\n\n\tint k=1;\n\tprintf(""%d == 1 ""is"" ""%s"", k, k==1?""TRUE"":""FALSE"");\n\treturn 0;",
      "When will you have 2>5, 5>0, 0>2, 2=2, 5=5, 0=0?",
      "What is the output of the following program?\n\n#include<stdio.h>\n#define x 4+1\n\tint main()\n\t{\n\tint i;\n\ti = x*x*x;\n\tprintf(""%d"",i);\n\treturn 0;\n\t}",
      "A donkey is behind another donkey. I'm behind that second donkey. But there is a whole nation behind me. It is a murder you can describe in a word.",
      "What is the output of the following program?\n\n\tint a = 5;\n\tint b = ++a * a++;\n\tprintf(""%d "",b);\n\treturn 0;",
      "What is greater than God,\nmore evil than the devil,\nthe poor have it,\nthe rich need it,\nand if you eat it, you'll die?",
      "Who makes it, has no need of it.\nWho buys it, has no use for it.\nWho uses it can neither see nor feel it.\nWhat is it?",
      "What has an eye but can not see?",
      "Paul's height is six feet, he's an assistant at a butcher's shop, and wears size 9 shoes. What does he weigh?",
      "There was a green house. Inside the green house there was a white house. Inside the white house there was a red house. Inside the red house there were lots of babies. What is it?",
      "Which word in the dictionary is spelled incorrectly?","If you have me, you want to share me. If you share me, you haven't got me. What am I?",
      "What gets broken without being held?","Feed me and I live, yet give me a drink and I die.","Take off my skin - I won't cry, but you will! What am I?",
      "What invention lets you look right through a wall?","What can you catch but not throw?",
      "Tanya is older than Eric.\nCliff is older than Tanya.\nEric is older than Cliff.\nIf the first two statements are true, the third statement is",
      "All the trees in the park are flowering trees.\nSome of the trees in the park are dogwoods.\nAll dogwoods in the park are flowering trees.\nIf the first two statements are true, the third statement is",
      "Mara runs faster than Gail.\nLily runs faster than Mara.\nGail runs faster than Lily.\nIf the first two statements are true, the third statement is",
      "Apartments in the Riverdale Manor cost less than apartments in The Gaslight Commons.\nApartments in the Livingston Gate cost more than apartments in the The Gaslight Commons.\nOf the three apartment buildings, the Livingston Gate costs the most.\nIf the first two statements are true, the third statement is"};
        
      char answers[35][500]={"false","false","constructor","copy constructor","false","stamp","mushroom","both","injective","hiding","ink", "Reese", "B",
      "Tuesday", "1 == 1 is TRUE", "rock, paper, scissors", "13", "assassination", "42","nothing","coffin","needle","meet","watermelon","incorrectly",
      "secret","promise","fire","onion","window","cold","false","true","false","true"};

    //randomizing thy answers
    #define ARR_SIZE(questions) ( sizeof((questions)) / sizeof((questions[0])) )
    int index;
    index = rand() % ARR_SIZE(questions);
    time_t begin, end;
    char ans[1][500];
    printf("\n%s\n\n", questions[index]);
    
    time(&begin);
    while (1){
         time(&end);
         if (kbhit()){
                     gets(ans[0]);
                     if(strcmp(ans[0], answers[index])==0){
                                       printf("\nCorrect! You have 4 moves.\n\n");
                                       *x=1;
                                       break;
                      }
                     if(strcmp(ans[0], answers[index])!=0){
                          printf("\nWrong answer!\n\n");
                          *x=2;
                          *bar=*bar-5;
                          hpbar(bar);
                          break;
                     }
         }
         if (difftime(end, begin) >= 15){
            printf("\nTime's up, loser.\n\n");
            *x=2;
            *bar=*bar-5;
            hpbar(bar);
            break;
            }
      }
}