Completed Unnecessary hard game

*** UPDATE 24 April 2020: Due to this actually being quite popular, I am going to be updating this to be a full game with more levels and penalties for using cheats. I hope to launch the new one within a few days ****

The numbers game I made is now completed. It now has 4 levels (Easy, Medium, Hard & Ultra) also it now has cheats also so you can speed through the program because you can, That’s pretty much the last update on this game for a while now as I can pretty much check this off as completed.

I hope you have fun with it and remeber you are not a number god unless you complete it without cheats 😀

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>


#define FONTGREEN "\x1b[32m"
#define FONTRESET "\x1b[0m"
#define FONTRED "\x1b[31m"



int main(void) {

    start:


    srand(time(NULL));

    int r = rand() % 1000 + 1;
    int complete = 0;
    int try;
    int countdown = 0;
    int cheat = 123456789;
    int restart = 987654321;
    int ecomplete = 0;
    int easy = rand() % 10 + 1;
    int mcomplete = 0;
    int medium = rand() % 100 + 1;
    int hcomplete = 0;
    int hard = rand () % 1000 + 1;
    int ucomplete = 0;
    int ultra = rand () & 10000000 + 1;



system ("clear");

printf("Lets play a game - I have generated a number and all you have to do is guess it!\nPick a number between 1 and 10: ");




    do {
        scanf("%d", &try);
        if (try == easy) {
            countdown++;

            printf(FONTGREEN "How did you get that and in %d tries! I'm impressed\n", countdown);

            printf("Easy level complete.\n\n*****Are you ready*****\nMedium level starts in 10 seconds\n" FONTRESET );

            ecomplete = 1;
            countdown = 0;
            sleep (10);
            goto medium;

        }

        if (try < easy) {
            countdown++;
            printf(FONTRED "Try number %d, too low,\nPlease try again: " FONTRESET, countdown);
        }

        if (try > easy) {
            countdown++;
            printf(FONTRED "Try number %d was too high\nplease try again: " FONTRESET, countdown);
        }

        if (try == cheat){

            printf("\nThe number I am looking for is: %d\n Although you are a cheater, just saying\n now enter it and press enter: " , easy);

        }

        if (try == restart){
            printf("\n Restarting game\n");
            sleep (5);
            goto start;
        }



 }while (ecomplete == 0);



    medium:

 system ("clear");

printf("Pick any number from 1 to 100: ");




    do {
        scanf("%d", &try);
        if (try == medium) {
            countdown++;

            printf(FONTGREEN "How did you get that and in %d tries! I'm impressed\n", countdown);

            printf("Medium level complete.\n\n*****Are you ready*****\nHard level starts in 10 seconds\n" FONTRESET );

            mcomplete = 1;
            sleep (10);
            countdown = 0;
            goto hard;

        }

        if (try < medium) {
            countdown++;
            printf(FONTRED "Try number %d, too low,\nPlease try again: " FONTRESET, countdown);
        }

        if (try > medium) {
            countdown++;
            printf(FONTRED "Try number %d was too high\nplease try again: " FONTRESET, countdown);
        }

        if (try == cheat){

            printf("\nThe number I am looking for is: %d\n Although you are a cheater, just saying\n now enter it and press enter: " , medium);

        }

        if (try == restart){
            printf("\n Restarting game\n");
            sleep (5);
            goto start;
        }



 }while (mcomplete == 0);

 hard:

 system ("clear");

printf("Pick any number between 1 to 1000: ");




    do {
        scanf("%d", &try);
        if (try == hard) {
            countdown++;

            printf(FONTGREEN "How did you get that and in %d tries! I'm impressed\n", countdown);

            printf("hard level complete.\n\n*****Are you ready*****\nUltra god level starts in 10 seconds\n" FONTRESET );

            hcomplete = 1;
            sleep (10);
            countdown = 0;
            goto ultra;

        }

        if (try < hard) {
            countdown++;
            printf(FONTRED "Try number %d, too low,\nPlease try again: " FONTRESET, countdown);
        }

        if (try > hard) {
            countdown++;
            printf(FONTRED "Try number %d was too high\nplease try again: " FONTRESET, countdown);
        }

        if (try == cheat){

            printf("\nThe number I am looking for is: %d\n Although you are a cheater, just saying\n now enter it and press enter: " , hard);

        }

        if (try == restart){
            printf("\n Restarting game\n");
            sleep (5);
            goto start;
        }



 }while (hcomplete == 0);


 ultra:

 system ("clear");

printf("Pick a number between 1 and 10000000: ");




    do {
        scanf("%d", &try);
        if (try == ultra) {
            countdown++;

            printf(FONTGREEN "How did you get that and in %d tries! I'm impressed\n", countdown);

            printf("Thats the game complete - You are now a number god\n" FONTRESET );
            printf(FONTRED"Restarting the game\n" FONTRESET );
           sleep (10);
            ucomplete = 1;
            countdown = 0;
            goto start;

        }

        if (try < ultra) {
            countdown++;
            printf(FONTRED "Try number %d, too low,\nPlease try again: " FONTRESET, countdown);
        }

        if (try > ultra) {
            countdown++;
            printf(FONTRED "Try number %d was too high\nplease try again: " FONTRESET, countdown);
        }

        if (try == cheat){

            printf("\nThe number I am looking for is: %d\n Although you are a cheater, just saying\n now enter it and press enter: " , ultra);

        }

        if (try == restart){
            printf("\n Restarting game\n");
            sleep (5);
            goto start;
        }



 }while (ucomplete == 0);




 return 0;


}

Previous version

Related Post

Leave a Reply

Your email address will not be published.