Arcade Racer by Trek2nd Jan 2005 18:51
|
---|
Summary A Text Based Arcade Racer Game. Description This was my second program ever made with DarkBASIC but it still has some helpful math and text examples for text based games and even 3D games. You need to download the Arcade Racer.zip file for the sounds but this game is run with absolutely no graphics. This is entirely free and I dont need any credit if you use some portion of the code in your future program. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Remstart .............................. . Arcade Racer . . Produced by . . Trek Software . . Written by DavidD3 2004 . .............................. Remend hide mouse Rem Load media Load music "Keepgoin.mid",1 Load sound "engine.wav",1 loop sound 1 load sound "carstart.wav",2 load sound "brakes.wav",3 load sound "car.wav",4 load sound "win.wav",5 load sound "shotgun.wav",6 load sound "pop.wav",7 load sound "explode.wav",8 load music "Inspire.mid",2 load bitmap "Trek.bmp",1 create bitmap 2,Bitmap width(1),bitmap height(1) set current bitmap 0 fade=1 change=1 sync on for n=1 to 195 cls fade=fade+change if fade>98 then change=-1 copy bitmap 1,2 fade bitmap 2,fade copy bitmap 2,0 sync next n cls wait 1000 Set text font "Impact" Set text size 55 Text 190,200,"Presents..." wait 1000 cls wait 500 wait 1000 Set text font "Impact" Set text size 65 Text 180,200,"Arcade Racer" play sound 2 wait 2000 play sound 3 cls delete sound 1 Rem Set top of program top: Rem Menu set cursor 170,150 Input "Would you like music? (y or n) ";music$ if music$="y" set cursor 140,130 endif if music$="y" then loop music 1 play sound 7 set cursor 150,190 Input "Would you like a dice window to popup? (y or n) ";dice$ play sound 7 Rem Flip coin to see who goes first set text font "Verdana" set text size 25 set cursor 130,230 Print "I will now flip a coin to see who goes first" set cursor 130,260 winner=2 Input "Player 1...would you like heads or tails? (h or t) ";headstails$ play sound 7 if headstails$="h" then gosub heads if headstails$="t" then gosub tails wait 1000 cls Rem Define variables and setup screen player1$="/" line$="_________________________________________________________________________" x=265 y=20 yii=400 yi=400 set cursor 5,250 color=RGB(255,0,0) INK color, 0 print player1$ set cursor 5,200 color=RGB(0,0,255) INK color, 0 print player1$ set cursor 5,205 color=RGB(255,255,255) INK color, 0 print line$ set cursor 5,255 print line$ place=5 place2=5 set cursor 235,440 print "Press spacebar to roll." Rem Begin Loop do Rem If spacebar is pressed activate turn. if spacekey()=1 play sound 4 cls dice=rnd(5)+1 set cursor 1,1 print dice wait 100 Rem Decide whose turn it is. turn=turn+1 if turn=3 then turn=1 turnprint=turn-1 if turnprint=0 then turnprint=2 if turn=1 then gosub player1 if turn=2 then gosub player2 set cursor 250,1 print "It's your turn player ";turnprint endif loop Rem Controls player 1 player1: Rem Decide whether to popup dice window or not if dice$="y" then cls rgb(25,25,25) : x=265 : y=255 set text font "Verdana" set text size 35 color=RGB(255,255,255) INK color, 0 set cursor x,y : print "You rolled a ";dice if dice$="y" then wait 1000 : cls rgb(0,0,0) Rem Setup screen set cursor 235,440 print "Press spacebar to roll." set cursor 5,205 color=RGB(255,255,255) INK color, 0 print line$ set cursor 5,255 print line$ Rem Activate movement and detect for winner place=place+dice*10 set cursor place,200 if place>570 then stop music 1 : wait 1000 : goto you_win color=RGB(0,0,255) INK color, 0 print player1$ set cursor place2,250 color=RGB(255,0,0) INK color, 0 print player1$ set cursor 180,400 Rem As player 1 if he would like to shoot player 2 if in range. if place=place2 print "Player 1 and player 2 are neck-and-neck!!" set cursor 180,425 Input "Would you like to shoot player 2? (y or n) ";shoot$ if shoot$="y" then place2=place2-30 : yii=360 : gosub explode endif Rem Detect how far ahead/behind player 2 is set cursor 180,yii if place>place2 then print "Player 1 is ahead of player 2 by ";(place-place2)/10;" spaces" if place<place2 then print "Player 2 is ahead of player 1 by ";(place2-place)/10;" spaces" return Rem Controls player 2 player2: Rem Same remarks as player 1 if dice$="y" then cls rgb(25,25,25) : x=265 : y=255 set text font "Verdana" set text size 35 color=RGB(255,255,255) INK color, 0 set cursor x,y : print "You rolled a ";dice if dice$="y" then wait 1000 : cls rgb(0,0,0) set cursor 235,440 print "Press spacebar to roll." set cursor 5,205 color=RGB(255,255,255) INK color, 0 print line$ set cursor 5,255 print line$ place2=place2+dice*10 set cursor place2,255 if place2>570 then stop music 1 : wait 1000 : goto you_win2 color=RGB(255,0,0) INK color, 0 print player1$ set cursor place,200 color=RGB(0,0,255) INK color, 0 print player1$ set cursor 180,400 if place=place2 print "Player 1 and player 2 are neck-and-neck!!" set cursor 180,425 Input "Would you like to shoot player 1? (y or n) ";shoot$ if shoot$="y" then place=place-30 : yi=360 : gosub explode endif set cursor 180,yi if place>place2 then print "Player 1 is ahead of player 2 by ";(place-place2)/10;" spaces" if place<place2 then print "Player 2 is ahead of player 1 by ";(place2-place)/10;" spaces" return Rem Displays player 2's winning screen you_win2: play sound 5 cls rgb(0,50,50) set text font "Verdana" set text size 35 color=RGB(255,0,0) INK color, 0 text 180,220,"YOU WIN PLAYER 2!!" wait 2000 cls set cursor 200,200 input "Play again? (y or n) ";again$ if again$="y" cls goto top else goto theend endif Rem Displays player 1's winning screen you_win: play sound 5 cls rgb(0,50,50) set text font "Verdana" set text size 35 color=RGB(0,0,255) INK color, 0 text 180,220,"YOU WIN PLAYER 1!!" wait 2000 cls set cursor 200,200 input "Play again? (y or n) ";again$ if again$="y" cls goto top else goto theend endif Rem Decides who goes first if choice was heads heads: randomize timer() picker=rnd(1)+1 if picker=1 turn=0 print "Heads...player 1 goes first." endif if picker=2 print "Tails...player 2 goes first." turn=1 endif return Rem Decides who goes first if choice was tails tails: randomize timer() picker=rnd(1)+1 if picker=2 turn=0 print "Tails...player 1 goes first." else print "Heads...player 2 goes first." turn=1 endif return Rem Ending Credits theend: plaze=50 syze=100 For n=1 to 10 syze=syze-5 plaze=plaze+5 Set text font "Impact" set text size syze color=RGB(0,255,0) INK color, 0 text plaze,230,"A Trek Software Production" wait 100 cls next n play sound 8 play music 2 text plaze,230,"A Trek Software Production" wait 1000 plaze=50 syze=100 For n=1 to 10 syze=syze-5 plaze=plaze+5 Set text font "Impact" set text size syze color=RGB(0,255,0) INK color, 0 text plaze,230,"Created by DavidD3 on 7-20-04" wait 100 cls next n play sound 8 text plaze,230,"Created by DavidD3 on 7-20-04" wait 2000 plaze=50 syze=100 For n=1 to 10 syze=syze-5 plaze=plaze+5 Set text font "Impact" set text size syze color=RGB(0,255,0) INK color, 0 text plaze,230,"Press any key to exit" wait 100 cls next n play sound 8 text plaze,230,"Press any key to exit" wait key end Rem Chucks the shot player back 3 spaces. explode: cls set cursor place2,255 color=RGB(255,0,0) INK color, 0 print player1$ set cursor place,200 color=RGB(0,0,255) INK color, 0 print player1$ set cursor 5,205 color=RGB(255,255,255) INK color, 0 print line$ set cursor 5,255 print line$ set cursor 235,440 print "Press spacebar to roll." play sound 6 return |