Maze Runner

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

#include<graphics.

h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

int main() {

int gd = DETECT , gm;

char dir[] = "C:\\turbo c installer\\Turbo C++\\BGI";


initgraph(&gd, &gm, dir);

int j=20, k=250, l=10, co_mo=0, inc=0;


int i, m=10;

while (1) {
float maxx = getmaxx();

char arr3[] = "MAZE Runner";


setcolor (13);
settextstyle (1, HORIZ_DIR, 4);

int w = textwidth (arr3);

outtextxy (((maxx/2)-(w/2)), 100, arr3);

settextstyle (0, HORIZ_DIR, 1);


setcolor (9);
outtextxy (0, 400, "Press 'SPACE' to play the level");

char ch=getch();
if (ch==' ') break;
}

cleardevice ();

///////maze
//horizontal
setcolor (CYAN);
line (0, 100, 450, 100);
line (50, 130, 400, 130);
line (100, 160, 450, 160);
line (150, 190, 300, 190);
line (100, 220, 250, 220);
line (50, 250, 200, 250);
line (450, 370, 500, 370);
line (0, 400, 500, 400);
//vertical
setcolor (CYAN);
line (50, 130, 50, 370);
line (100, 160, 100, 220);
line (100, 280, 100, 400);
line (150, 250, 150, 370);
line (200, 280, 200, 400);
line (250, 220, 250, 370);
line (300, 190, 300, 400);
line (350, 160, 350, 370);
line (400, 190, 400, 400);
line (450, 100, 450, 370);
////////////
setcolor (YELLOW);
circle (500, 385, 10);

//////////
setcolor (WHITE);
circle (j, k, l);
setfillstyle (SOLID_FILL, YELLOW);
floodfill (j, k, WHITE);

/////////
setcolor (RED);
outtextxy (10, 70, "Escape from the Maze");
outtextxy (10, 85, "Press 'SPACE' to EXIT");
outtextxy (500, 280, "w -> UP");
outtextxy (500, 290, "s -> DOWN ");
outtextxy (500, 300, "a -> LEFT");
outtextxy (500, 310, "d -> RIGHT");

//------------count move------------
inc+=5;

settextstyle (DEFAULT_FONT, HORIZ_DIR, 1);


setcolor (DARKGRAY); // inner arc
arc (530, 200, 340-(inc), 80-(inc), 50);
arc (530, 200, 340-(inc), 80-(inc), 51);

arc (530, 200, 100+(inc), 200+(inc), 55); //mid


arc
arc (530, 200, 100+(inc), 200+(inc), 56);

setcolor (LIGHTGRAY);
//outer arc
arc (530, 200, 220-(inc), 320+(inc), 60);

setcolor (YELLOW);
outtextxy (515, 198, "MOVE");

char arr[50];
sprintf(arr, "%d", co_mo);

setcolor (CYAN);
outtextxy (520, 215, arr);
co_mo++;

// --------------loop-------------
for(i=0; i<m++; i++) {

if(k==110) {
if(j<450&&j>0)
k=k+5;
}

if(j==10) {
if(k<400&&k>100)
j+=5;
}

if(k==390) {
if(j<500&&j>0)
k-=5;
}

if(j==440) {
if(k>100&&k<380)
j-=5;
}

if(k==380) {
if(j<500&&j>440)
k+=5;
}

if(k>=120&&k<=140) {
if(j<410&&j>40&&k<=130)
k-=5;
if(j<410&&j>40&&k>=130)
k+=5;
}

if(k>=150&&k<=170&&j>=90&&j<=450) {
if(k<=160)k-=10;
k+=5;
}

if(k>=180&&k<=200&&j>=140&&j<=310)
{ if(k>=190)k+=10;
k-=5; }
if(k>=210&&k<=230&&j>=90&&j<=260)
{if(k>=220)k+=10;
k-=5;
}

if(k<=260&&k>=240&&j<=210&&j>40){
if(k>=250)k+=10;
k-=5;
}

if(k<=370&&k>=130&&j<=60&&j>=40){
if(j<=50) j-=10;
j+=5;
}

if(k<=220&&k>=160&&j<=110&&j>=90){
if(j<=100)j-=10;
j+=5;
}

if(k<=400&&k>=280&&j<=110&&j>=90){
if(j<=100)j-=10;
j+=5;
}
if(k<=370&&k>=250&&j<=160&&j>=140){
if(j<=150)j-=10;
j+=5;
}

if(k<=400&&k>=280&&j<=210&&j>=190){
if(j<=200)j-=10;
j+=5;
}

if(k<=370&&k>=220&&j<=260&&j>=240){
if(j<=250)j-=10;
j+=5;
}

if(k<=400&&k>=190&&j<=310&&j>=290){
if(j<=300)j-=10;
j+=5;
}

if(k<=370&&k>=160&&j<=360&&j>=340){
if(j<=350)j-=10;
j+=5;
}

if(k<=400&&k>=190&&j<=410&&j>=390){
if(j<=400)j-=10;
j+=5;
}

//------------count move------------
inc+=5;

settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setcolor(DARKGRAY); // inner arc
arc(530,200,340-(inc),80-(inc),50);
arc(530,200,340-(inc),80-(inc),51);

arc(530,200,100+(inc),200+(inc),55); //mid
arc
arc(530,200,100+(inc),200+(inc),56);

setcolor(LIGHTGRAY);
//outer arc
arc(530,200,220-(inc),320+(inc),60);

setcolor(YELLOW);
outtextxy(515,198, "MOVE");

//char arr[50];
sprintf(arr, "%d", co_mo);

setcolor(CYAN);
outtextxy(520,215,arr);
co_mo++;

///////////
char c=getch();
cleardevice();

if((c==75) || (c=='a')) {
j-=5;
}

if((c==80) || (c=='s')) {
k+=5;
}

if((c==77) || (c=='d')) {
j+=5;
}

if((c==72) || (c=='w')) {
k-=5;
}

if(c==' '){
return 0;
}

/////////
setcolor(RED);
outtextxy(10,70, "Escape from the Maze");
outtextxy(10,85, "Press 'SPACE' to EXIT");
outtextxy(500,280, "w -> UP");
outtextxy(500,290, "s -> DOWN ");
outtextxy(500,300, "a -> LEFT");
outtextxy(500,310, "d -> RIGHT");

///////maze
//horizontal
setcolor(CYAN);
line(0,100,450,100);
line(50,130,400,130);
line(100,160,450,160);
line(150,190,300,190);
line(100,220,250,220);
line(50,250,200,250);
line(450,370,500,370);
line(0,400,500,400);
//vertical
setcolor(CYAN);
line(50,130,50,370);
line(100,160,100,220);
line(100,280,100,400);
line(150,250,150,370);
line(200,280,200,400);
line(250,220,250,370);
line(300,190,300,400);
line(350,160,350,370);
line(400,190,400,400);
line(450,100,450,370);

setcolor(YELLOW);
circle (500, 385, 10);
//////////
setcolor (WHITE);
circle (j, k, l);
setfillstyle (SOLID_FILL, YELLOW);
floodfill (j, k, WHITE);

if(j>=500) {
return 1;
}
}

getch();
closegraph();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy