Add to Favorites    Make Home Page 4092 Online  
 Language Categories  
 Our Services  

Home » Pascal Home » Pascal Projects Home » A car game. You have to drive the car in such a way that you dont strike a barrier on the road.

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title A car game. You have to drive the car in such a way that you dont strike a barrier on the road.
Description
Category Pascal » Pascal Projects
Hits 389278
Code Select and Copy the Code
{ Description: A car game. You have to drive the car in such a way that you dont strike a barrier on the road. } program hero; uses graph,crt; const dir='c: pgi'; var x1,x2,x3,driver,mode,moder,left1,left2,right1,right2:integer; y1,y2,y3,lan1,lan2,chan,s1,s2,s3,s4,r1,r2:integer; c,r,menu:char; left,right,crash:boolean; Procedure sides1(x,y,a,b,c:integer); Begin If c mod 2 =0 then Begin setcolor(red); rectangle(x,y,a,b); setfillstyle(1,red); floodfill(x+2,b-5,red); End Else Begin setcolor(white); rectangle(x,y,a,b); setfillstyle(1,white); floodfill(x+2,b-5,white); End; End; Procedure sides2(x,y,a,b,c:integer); Begin If c mod 2 =0 then Begin setcolor(white); rectangle(x,y,a,b); setfillstyle(1,white); floodfill(x+2,b-5,white); End Else Begin setcolor(red); rectangle(x,y,a,b); setfillstyle(1,red); floodfill(x+2,b-5,red); End; End; procedure lane1(d,e,f:integer); var a1,a2:integer; Begin a1:=315; a2:=325; if f mod 2 = 0 then Begin setcolor(white); rectangle(a1,d,a2,e); setfillstyle(1,white); floodfill(317,e-5,white); End else Begin setcolor(black); rectangle(a1,d,a2,e); setfillstyle(1,black); floodfill(317,e-5,black); End; end; procedure lane2(d,e,f:integer); var a1,a2:integer; Begin a1:=315; a2:=325; if f mod 2 = 0 then Begin setcolor(black); rectangle(a1,d,a2,e); setfillstyle(1,black); floodfill(317,e-5,black); End else Begin setcolor(white); rectangle(a1,d,a2,e); setfillstyle(1,white); floodfill(317,e-5,white); End; End; procedure rukawat1(a:integer); begin setfillstyle(1,7); floodfill(220,a-5,7); end; procedure rukawat2(a:integer); begin setfillstyle(1,black); floodfill(220,a-5,black); end; procedure rukawat3(a:integer); begin setfillstyle(1,7); floodfill(420,a-5,7); end; procedure rukawat4(a:integer); begin setfillstyle(1,black); floodfill(420,a-5,black); end; Procedure obst1; Begin setcolor(7); rectangle(s1,r1,s2,r2); rukawat1(r2); delay(200); rectangle(s1,r1,s2,r2); rukawat2(r2); End; Procedure obst2; Begin setcolor(7); rectangle(s3,r1,s4,r2); rukawat3(r2); delay(200); rectangle(s3,r1,s4,r2); rukawat4(r2); End; procedure car(x,y:integer); begin setcolor(white); line(x,y,x+50,y); {horizontal line} line(x,y,x-10,y+10); {left intersecting line} line(x+50,y,x+60,y+10); {right intersecting line} line(x-10,y+10,x-10,y+30); {left st line} line(x+60,y+10,x+60,y+30); {right st line} line(x-10,y+30,x+60,y+30); {end of bonnet} setfillstyle(1,blue); floodfill(x+20,y+20,white); rectangle(x+60,y+30,x+70,y+35); {right side view mirror} setfillstyle(1,7); floodfill(x+65,y+33,white); rectangle(x-20,y+35,x-10,y+30); {left side view mirror} setfillstyle(1,7); floodfill(x-15,y+33,white); line(x-10,y+30,x-10,y+100); {body side left} line(x+60,y+30,x+60,y+100); {body side right} line(x-10,y+30,x,y+45); {wind screen left} line(x+60,y+30,x+50,y+45); {wind screen right} rectangle(x,y+45,x+50,y+80); {main roof} setfillstyle(1,blue); floodfill(x+2,y+50,white); line(x+20,y+30,x,y+35 ); {left wiper} line(x+50,y+30,x+30,y+35); {right wiper} rectangle(x+10,y+50,x+40,y+60); {sunroof} setfillstyle(1,8); floodfill(x+20,y+55,white); line(x,y+60,x-10,y+60); {left door} line(x+50,y+60,x+60,y+60); {right door} line(x,y+80,x-10,y+100); {roof to body side left} line(x+50,y+80,x+60,y+100); {roof to body side right} line(x-10,y+100,x+60,y+100); {back wind screen} rectangle(x-10,y+100,x+60,y+115); setfillstyle(1,blue); floodfill(x+20,y+110,white); line(x,y+100,x+20,y+87); {back windscreen wiper} rectangle(x-20,y+115,x+70,y+130); {racing car's special raised trunk} setfillstyle(1,blue); floodfill(x,y+120,white); line(x-10,y+122,x+60,y+122); {racing car's (back) trunk horizontaly 1 } end; procedure car2(x,y:integer); begin setcolor(black); line(x,y,x+50,y); {horizontal line} line(x,y,x-10,y+10); {left intersecting line} line(x+50,y,x+60,y+10); {right intersecting line} line(x-10,y+10,x-10,y+30); {left st line} line(x+60,y+10,x+60,y+30); {right st line} line(x-10,y+30,x+60,y+30); {end of bonnet} setfillstyle(1,black); floodfill(x+20,y+20,black); rectangle(x+60,y+30,x+70,y+35); {right side view mirror} setfillstyle(1,black); floodfill(x+65,y+33,black); rectangle(x-20,y+35,x-10,y+30); {left side view mirror} setfillstyle(1,black); floodfill(x-15,y+33,black); line(x-10,y+30,x-10,y+100); {body side left} line(x+60,y+30,x+60,y+100); {body side right} line(x-10,y+30,x,y+45); {wind screen left} line(x+60,y+30,x+50,y+45); {wind screen right} rectangle(x,y+45,x+50,y+80); {main roof} setfillstyle(1,black); floodfill(x+2,y+50,black); line(x+20,y+30,x,y+35 ); {left wiper} line(x+50,y+30,x+30,y+35); {right wiper} rectangle(x+10,y+50,x+40,y+60); {sunroof} line(x,y+60,x-10,y+60); {left door} line(x+50,y+60,x+60,y+60); {right door} line(x,y+80,x-10,y+100); {roof to body side left} line(x+50,y+80,x+60,y+100); {roof to body side right} line(x-10,y+100,x+60,y+100); {back wind screen} rectangle(x-10,y+100,x+60,y+115); setfillstyle(1,black); floodfill(x+20,y+110,black); line(x,y+100,x+20,y+87); {back windscreen wiper} rectangle(x-20,y+115,x+70,y+130); {racing car's special raised trunk} setfillstyle(1,black); floodfill(x,y+120,black); line(x-10,y+122,x+60,y+122); {racing car's (back) trunk horizontaly 1} end; Procedure option; Begin while keypressed =true do Begin c:=readkey; case c of 'j':Begin car2(365,330); car(300,330); delay(30); car2(300,330); car(210,330); left:=true; right:=false; End; 'l':Begin car2(210,330); car(300,330); delay(30); car2(300,330); car(365,330); right:=true; left:=false; End; 'q': Begin y1:=450; End; End; End; End; {----------------------------MAIN BODY-----------------------------------} Begin initgraph(driver,mode,dir); setbkcolor(7); randomize; setcolor(1); settextstyle(4,horizdir,7); outtextxy(230,90,'MENU'); settextstyle(2,horizdir,7); outtextxy(100,170,'PRESS THE FOLLOWING KEYS TO PLAY OR QUIT'); outtextxy(250,220,'1: START'); outtextxy(250,250,'2: QUIT'); outtextxy(240,310,'DURING GAME'); outtextxy(180,360,'TO TURN CAR LEFT PRESS J'); outtextxy(180,390,'TO TURN CAR RIGHT PRESS L'); outtextxy(180,420,'PRESS Q TO QUIT'); menu:=readkey; while keypressed =true do Begin menu:=readkey; End; Case menu of '1':Begin cleardevice; setbkcolor(black); setcolor(green); rectangle(0,0,160,480); setfillstyle(1,green); floodfill(100,30,green); rectangle(480,0,640,480); setfillstyle(1,green); floodfill(500,400,green); setcolor(white); car(210,330); car2(365,330); left:=true; crash:=false; Repeat {--------------MAIN LOOP-----------------} y1:=0; y2:=25; lan1:=0; {MIDDLE LANE} lan2:=50; {MIDDLE LANE} left1:=160; left2:=170; right1:=470; right2:=480; moder:=0; s1:=200; s2:=275; s3:=360; s4:=435; r1:=110; r2:=120; chan:=random(20); Repeat moder:=moder+1; option; sides1(left1,y1,left2,y2,moder); {left side} sides1(right1,y1,right2,y2,moder);{right side} lane1(lan1,lan2,moder); delay(5); sides2(left1,y1,left2,y2,moder); {Left side alternate} sides2(right1,y1,right2,y2,moder); {Right side alternate} lane2(lan1,lan2,moder); Case chan of 0,1,2:Begin if r1<470 then obst1; if (r1=470)and (left=true) then Begin crash:=true; End; r1:=r1+120; r2:=r1+10; End; 5,6,7:Begin if r1<470 then obst2; if (r1=470)and (right=true) then Begin crash:=true; End; r1:=r1+120; r2:=r1+10; End; End; lan1:=lan1+50; lan2:=lan1+50; y1:=y1+25; y2:=y1+25; option; If lan1=450 then Begin lan1:=0; lan2:=50; End; Until(y1=450)or(crash=true); Until(c='q')or(crash=true); cleardevice; setbkcolor(cyan); If crash= true then Begin setcolor(red); settextstyle(2,horizdir,10); outtextxy(220,220,'GAME OVER'); outtextxy(100,280,'THANK YOU FOR PLAYING'); readkey; End; if c='q' then Begin setcolor(red); settextstyle(2,horizdir,8); outtextxy(150,220,'YOU HAVE CHOSEN TO QUIT'); readkey; End; End; '2':Begin cleardevice; setbkcolor(cyan); setcolor(red); settextstyle(2,horizdir,8); outtextxy(150,220,'YOU HAVE CHOSEN TO QUIT'); readkey; End; End; End.

Related Source Codes

Script Name Author
Calendar date to day number and back Nicky McLean
Matrix Multiple Cirruse Salehnasab
Function Power Recursive Cirruse Salehnasab
swim brian colston
tetris (Mini Project) mehdi farrokhzad
Macsi - space fighting game. Macsi P�ter
Recursive Monkey Puzzle Solution - Project Maxim C.L. Wrne
Maze Game Project In Pascal Mahmood
Excellent Rat in a Maze Program. VyomWorld
Student Database Information System. VyomWorld
Tic Tac Toe Game implemented in Pascal. VyomWorld
Game to Gain more blocks by drawing appropriate lines from correct places(dots). VyomWorld
To Find The Coinage Of The Amount Entered. VyomWorld
Randomizes two 3x3 arrays and indicates the numbers whih are common in both the arrays otherwise an cross 'x' is shown instead. VyomWorld
Program that checks the space on drive a: and also gives a graphical representation of memory. VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptId=171


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review