Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "gfx.h"
- #include <time.h>
- #include <unistd.h>
- void ready_up ();
- void frame ();
- int main (void)
- {
- int ysize = 768;
- int xsize = 1366;
- int a = 1;
- int x1 = 100;
- int x2 = 100;
- int width = 250;
- int height = 250;
- int loop1;
- int score = 0;
- char c,x;
- char *intro = "Wanna play a game?";
- char *start = "Press y to start";
- char *red = "Red";
- char *green = "Green";
- char *purple = "Purple";
- char *wrong = "wrong answer";
- char *correct = "Correct answer";
- char *memorise = "Please memorise the sequence";
- char *ready = "If ready press Y";
- char *bye = "Bye bye and thank you";
- char *score0 = "Your score is zero";
- char *score1 = "Your score is one";
- char *score2 = "Your score is two";
- char *score3 = "Your score is three";
- srand(time(NULL));
- gfx_open (xsize, ysize, "Final Project");
- gfx_color (255,255,255);
- gfx_text (intro,500,50);
- gfx_color (255,255,255);
- gfx_text (start,500,75);
- while (a = 1)
- {
- x=gfx_wait();
- if (x == 'y') {
- //red
- ready_up ();
- x=gfx_wait();
- if (x == 'y')
- {
- gfx_clear();
- gfx_color (255,255,255);
- gfx_text (red,500,50);
- frame ();
- x=gfx_wait();
- if ((gfx_xpos()>100 && gfx_xpos()<350) && (gfx_ypos()>100 && gfx_ypos()<350))
- {
- score = score + 1;
- gfx_color (255,0,0);
- gfx_fillrectangle (100,100,250,250);
- x=gfx_wait();
- gfx_clear();
- gfx_color (255,255,255);
- gfx_text (correct,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);
- x=gfx_wait ();
- //break;
- }
- else
- {
- gfx_clear ();
- gfx_text (wrong,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);
- x=gfx_wait ();
- //break;
- }
- //green
- ready_up ();
- x=gfx_wait();
- if (x == 'y') gfx_clear();
- gfx_color (255,255,255);
- gfx_text (green,500,50);
- frame ();
- x=gfx_wait();
- if ((gfx_xpos()>850 && gfx_xpos()<1100) && (gfx_ypos()>350 && gfx_ypos()<600))
- {
- score = score + 1;
- gfx_color (134,255,67);
- gfx_fillrectangle (850,350,250,250);
- x=gfx_wait();
- gfx_clear();
- gfx_color (255,255,255);
- gfx_text (correct,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);;
- x=gfx_wait ();
- }
- else
- {
- gfx_clear ();
- gfx_text (wrong,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);
- x=gfx_wait ();
- //break;
- }
- //purple
- ready_up ();
- x=gfx_wait();
- if (x == 'y') gfx_clear();
- gfx_color (255,255,255);
- gfx_text (purple,500,50);
- frame ();
- x=gfx_wait();
- if ((gfx_xpos()>600 && gfx_xpos()<850) && (gfx_ypos()>100 && gfx_ypos()<350))
- {
- score = score + 1;
- gfx_color (134,56,125);
- gfx_fillrectangle (600,100,250,250);
- x=gfx_wait();
- gfx_clear();
- gfx_color (255,255,255);
- gfx_text (correct,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);
- x=gfx_wait ();
- //break;
- }
- else
- {
- gfx_clear ();
- gfx_text (wrong,500,50);
- if (score == 0)
- gfx_text (score0,500,75);
- if (score==1)
- gfx_text (score1,500,75);
- if (score==2)
- gfx_text (score2,500,75);
- if (score==3)
- gfx_text (score3,500,75);
- x=gfx_wait ();
- //break;
- }
- //level1.1
- //level1.2
- //level1.3
- } //if x == 'y'
- else
- {
- gfx_clear ();
- gfx_color(255,255,255);
- gfx_text(bye,600,300);
- if (score == 0)
- gfx_text (score0,550,250);
- if (score==1)
- gfx_text (score1,550,250);
- if (score==2)
- gfx_text (score2,550,250);
- if (score==3)
- gfx_text (score3,550,250);
- x=gfx_wait ();
- break;
- }
- gfx_clear ();
- gfx_color(255,255,255);
- gfx_text(bye,600,300);
- if (score == 0)
- gfx_text (score0,550,250);
- if (score==1)
- gfx_text (score1,550,250);
- if (score==2)
- gfx_text (score2,550,250);
- if (score==3)
- gfx_text (score3,550,250);
- x=gfx_wait ();
- break;
- if (x == 'u') break;
- } //if
- } //while
- } //main
- void ready_up ()
- {
- char *memorise = "Please memorise the sequence";
- char *ready = "If ready press Y";
- gfx_clear();
- gfx_color (255,0,0);
- gfx_fillrectangle (100,100,250,250);
- gfx_color (134,0,0);
- gfx_fillrectangle (350,100,250,250);
- gfx_color (134,56,125);
- gfx_fillrectangle (600,100,250,250);
- gfx_color (156,89,87);
- gfx_fillrectangle (850,100,250,250);
- gfx_color (134,189,56);
- gfx_fillrectangle (1100,100,250,250);
- gfx_color (23,67,89);
- gfx_fillrectangle (100,350,250,250);
- gfx_color (89,0,255);
- gfx_fillrectangle (350,350,250,250);
- gfx_color (123,90,56);
- gfx_fillrectangle (600,350,250,250);
- gfx_color (134,255,67);
- gfx_fillrectangle (850,350,250,250);
- gfx_color (45,255,255);
- gfx_fillrectangle (1100,350,250,250);
- gfx_color (255,255,255);
- gfx_text (memorise,500,50);
- gfx_text (ready, 500,75);
- }
- void frame ()
- {
- int loop1;
- int x1 = 100;
- int x2 = 100;
- for (loop1=0; loop1<5; loop1++)
- {
- gfx_rectangle (x1,100,249,249);
- x1=x1+250;
- }
- for (loop1=0; loop1<5; loop1++)
- {
- gfx_rectangle (x2,350,249,249);
- x2=x2+250;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement