' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' % -=Tank Zone Coded By: Shockwave=- % ' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' ' ++++++++++++++++++++++++++++ ' + Completed In August 2002 + '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ' See the very bottom of the listing for the diary of this ' game. I am putting my personal greetings here instead of ' on the title screen for a change. ' ' Oh well.. For better or worse it's finished (some shape) ' The second ever (I think) PS2 Yabasic 3D game. '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ' ' To Xalthorn, Fryer and Jim. Thank you all for your very ' nice programs. Thanks also for letting me use your names ' in this game. ' ' To Doctor, thanks for your emails and friendship. You ' have become a very competent programmer amd a good mate. ' Really it was your comments after you saw the preview ' that made me get my finger out and finish this. ' Thank you for everything Chris. ' ' To Xalthorn, well, here it is. for what it's worth. I ' hope you like it a little. ;o) And I hope that you will ' forgive me for naming the enemy tanks after you and that ' we're still friends Marc! ' Congratulations on Gemocide and your website by the way. ' ' To Fryer, well, this is how it finished up.. A bit of a ' mess but it works. There was no way I'd have got this ' into 50fps. lol. Looks like there's two of us that have ' managed to do a 3d Yabasic game now... Who's next? ' ' To Jim Shaw, I guess a lot of people will run this in ' the emulator, and find out that it's waaaaayyy too slow ' in there. But I want to thank you for all the work that ' you have put into the emulator, you've opened up the ' language to a lot of new people and it's made my life ' much easier too. So thank you. ' ' To Jo Morrow, how's the 3D stuff coming? Have you done ' that pyramid program yet? Okay, my next challenge to you ' is to do a better version of this game. lol. ' ' To Demoneye, not a lot of code from U, but I have to say ' that you do a great job in modding the Yabasic forums. ' thanks Brad. ' ' To Snakedogg.. Mamma Mia. Here I go again.. Sorry, I ' couldn't resist it. Nice Job on the forums. Keep up the ' good work and do some more code ffs. Your stuff is real ' nice when you put your mind to it Pete. ' ' To Zingster, Rob, you are my favourite affiliate. I know ' you cant use this as you don't have a PS2, but I've put ' your site on the title screen of this game. Hope you ' get some hits from it as it's a cool place. ' ' To Jinx, Nice to see that you're doing some nice stuff ' with 3D. Let's think... Hmm, well I released the ' starcube demo about 9 months ago, you've just done your ' own version of it, so I'll pencil your tank game in for ' early 2003?!? heh. ' ' To Parabellum, your programs are making me all nostalgic ' and misty eyed, thinking of my Amiga days. ;o) Try not ' to eat too many snails, the shells can cause indigestion ' ' Combatking, well, you made it onto my greets list so Hi! ' ' Kyataavl, revenge.. I hope to get this game published, ' if and when I do, I'd like to point out to your friends ' what you've been doing with my programs. ' yes, get this. Christian Richard aka kyataavl takes my ' programs and removes my name from the source listings ' so he can show off to his friends saying he made them. ' There you go, national exposure for you, lamer :P ' It's one way of getting into my greetings though. ' ' Bigyabasic, you're in here because you've impressed me ' with your attitude to learning programming. ' ' Drew001001, come back to the forums mate. We miss you. ' ' Handshakes to these cool guys also; ' Master Tonberry, Adam lay, Sephiroth, Balroq, ' Bongotrummor, Pyro the maniac, Tenchiman, Gothi, ' Matt, Mr.furious, Yaloopy, ell and all the rest of you ' that I know from the Yabasic forums and at Gamevine. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' If you want to know more about PS2 Yabasic; ' Go to : www.yabasic.co.uk and visit the forums. ' I administrate this board with some of my friends, it's ' the hub of the PS2 Yabasic programming community and a ' very friendly place with well over 275,000 visits in the ' last year and something like 17,000 messages posted. We ' are getting bigger and better all the time. ' ' You can post your comments on the message board and they ' will be welcome. Or if you just want to say hello to me; ' An email to: Shockwave@ps2-yabasic.co.uk Will do the job ' ' If you want to download the latest Yabasic games, demos ' and utilities, visit www.ps2-yabasic.co.uk ' ' If you love videogaming, you could do a lot worse than ' visit www.gamevine.net. The best cross platform board I ' have found. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Now prepare for 1,087 lines of messy code; '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% gosub setup '========================================================= ' Main Loop Begins; '========================================================= repeat gosub title gosub new_game '========================================================= ' Outer Game Loop Begins; '========================================================= repeat gosub next_level gosub new_level '========================================================= ' Inner Game Loop Begins; '========================================================= repeat '--------------------------------------------------------- ' Double Buffer '--------------------------------------------------------- setdrawbuf dw dw=1-dw setdispbuf dw gosub clear_screen gosub clearworld gosub moveenemy gosub player_control_move gosub playerbullet gosub enemybullet gosub rotatemap gosub rotateshots gosub sort_world gosub draw3d gosub overlay if energy<0 energy=0 until ((energy=0) or (complete=0)) '========================================================= ' Inner Game Loop Ends; '========================================================= until (energy=0) gosub game_over '========================================================= ' Outer Game Loop Ends; '========================================================= if score>high high=score until (1=2) '========================================================= ' Main Loop Closes; '========================================================= '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' Handles Most Aspects Of Enemy Bullets; '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% label enemybullet '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Bullet rotations. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bxr=bxr+4 byr=byr+7 bzr=bzr+25 if bxr>360 bxr=bxr-360 if byr>360 byr=byr-360 if bzr>360 bzr=bzr-360 for a=1 to maxobj '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Tank firing pause; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if objectf(a)>0 then objectf(a)=objectf(a)-1 fi if objectss(a)>0 then objectst(a)=objectst(a)-1:rem decrease shot life if objectst(a)=0 objectss(a)=0:rem remove bullet objectsx(a)=objectsx(a)+objectsxd(a) objectsz(a)=objectsz(a)+objectszd(a) if objectsx(a)<-500 objectss(a)=0 if objectsx(a)>500 objectss(a)=0 if objectsz(a)<-500 objectss(a)=0 if objectsz(a)>500 objectss(a)=0 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Collisions; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if objectsx(a)>px-10 and objectsx(a)pz-10 and objectsz(a)px+80 objectx(a)=objectx(a)-.5 if objectz(a)pz+80 objectz(a)=objectz(a)-.5 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Stop Tanks From Bunching Up: '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for b=1 to maxobj if b<>a and objects(b)=1 then if (objectx(a)>(objectx(b)-100)) and (objectx(a)<(objectx(b)+100)) then if (objectz(a)>(objectz(b)-100)) and (objectz(a)<(objectz(b)+100)) then objectx(a)=obxold:rem Bunched up, revert to objectz(a)=obzold:rem old positions. fi fi fi next b fi next a return '========================================================= 'This small Sub handles The Player Bullets and Collisions '========================================================= label playerbullet if pt>0 pt=pt-1 if pt=0 ps=0 if pt=0 return sx=sx+sxd sz=sz+szd if sx<-500 ps=0 if sx>500 ps=0 if sz<-500 ps=0 if sz>500 ps=0 '--------------------------------------------------------- ' Check for collisions! '--------------------------------------------------------- for a=1 to maxobj if objects(a)=1 then if sx>objectx(a)-4 and sxobjectz(a)-4 and szpx-200) and (shotx(a)pz-200) and (shotz(a)-120 and xx<760 then worldt(worldpos)=2 :rem store object type worldo(worldpos)=shoto(a) :rem store orientation. worldx(worldpos)=xx :rem Store X Screen. worldy(worldpos)=yy :rem Store Y Screen. worldz(worldpos)=shotsize : rem Store Z Pos. worlds(worldpos)=1 worldpos=worldpos+1 fi fi next a return '========================================================= ' Bubble sort visible display from back to front '========================================================= label sort_world 'toxyz for a=1 to worldpos for b=a to worldpos if worldz(b) > worldz(b+1) then ssz=worldz(b) ssy=worldy(b) ssx=worldx(b) sst=worldt(b) sso=worldo(b) worldz(b)=worldz(b+1) worldy(b)=worldy(b+1) worldx(b)=worldx(b+1) worldt(b)=worldt(b+1) worldo(b)=worldo(b+1) worldz(b+1)=ssz worldy(b+1)=ssy worldx(b+1)=ssx worldt(b+1)=sst worldo(b+1)=sso end if next b next a return '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 'This Routine Looks Through The World Arrays And Draws 'The Game Display From The Information In The Arrays. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% label draw3d for a=1 to worldpos+1 if worldt(a)=1 gosub drawtank :rem Draw Tank if worldt(a)=2 gosub drawshot :rem Draw Bullet next a return label drawshot '############################################### '## Rotate And Scale Each Point! Store Result ## '############################################### for b=23 to 28 x1=x(b) y1=y(b) z1=z(b) '###################### '## X,Y,Z rotations! ## '###################### xx=x1 yy=y1*cs(bxr)+z1*sn(bxr) zz=z1*cs(bxr)-y1*sn(bxr) y1=yy x1=xx*cs(byr)-zz*sn(byr) z1=xx*sn(byr)+zz*cs(byr) zz=z1 xx=x1*cs(bzr)-y1*sn(bzr) yy=x1*sn(bzr)+y1*cs(bzr) '######################## '## Apply Perspective! ## '######################## xx=(worldz(a)*(xx/((zz/50)+1))+worldx(a)) yy=(worldz(a)*1.5)*(yy/((zz/50)+1))+worldy(a) tx(b)=xx ty(b)=yy tz(b)=zz next b setrgb 1,ran(255),ran(255),ran(255) line tx(23),ty(23) to tx(24),ty(24) line tx(25),ty(25) to tx(26),ty(26) line tx(27),ty(27) to tx(28),ty(28) return label drawtank '############################################### '## Rotate And Scale Each Point! Store Result ## '############################################### tr=mod(360+worldo(a)+pr,360) for b=1 to 22 x1=x(b) y1=y(b)+1 z1=z(b) '###################### '## X,Y,Z rotations! ## '###################### xx=x1 yy=y1*cs(0)+z1*sn(0) zz=z1*cs(0)-y1*sn(0) y1=yy x1=xx*cs(tr)-zz*sn(tr) z1=xx*sn(tr)+zz*cs(tr) zz=z1 xx=x1*cs(0)-y1*sn(0) yy=x1*sn(0)+y1*cs(0) '######################## '## Apply Perspective! ## '######################## xx=-xx xx=worldz(a)*(xx/((zz/50)+1))+worldx(a) yy=(worldz(a)*1.5)*(yy/((zz/50)+1))+worldy(a) tx(b)=xx ty(b)=yy tz(b)=zz next b '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Draw the tank '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ r=-100 : g=0 : b=-100 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Gun is facing away; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if tz(20)>=tz(17) then f1=17 : f2=20 : f3=22 : f4=19:gosub draw f1=20 : f2=17 : f3=18 : f4=21:gosub draw f1=22 : f2=21 : f3=18 : f4=19:gosub draw f1=22 : f2=20 : f3=21 : f4=22:gosub draw fi '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Body; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ f1=1 : f2=2 : f3=4 : f4=3:gosub draw f1=6 : f2=7 : f3=4 : f4=2:gosub draw f1=5 : f2=6 : f3=2 : f4=1:gosub draw f1=4 : f2=7 : f3=8 : f4=3:gosub draw f1=8 : f2=5 : f3=1 : f4=3:gosub draw f1=5 : f2=9 : f3=10 : f4=6:gosub draw f1=10 : f2=12 : f3=7 : f4=6:gosub draw f1=12 : f2=11 : f3=8 : f4=7:gosub draw f1=11 : f2=9 : f3=5 : f4=8:gosub draw f1=14 : f2=16 : f3=12 : f4=10:gosub draw f1=13 : f2=14 : f3=10 : f4=9:gosub draw f1=16 : f2=15 : f3=11 : f4=12:gosub draw f1=13 : f2=9 : f3=11 : f4=15:gosub draw f1=13 : f2=15 : f3=16 : f4=14:gosub draw '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Gun Is Facing Towards; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if tz(20)0 then light =abs(n/50) setrgb 1,r,g+light,b fill triangle tx(f1),ty(f1) to tx(f2),ty(f2) to tx(f3),ty(f3) fill triangle tx(f1),ty(f1) to tx(f4),ty(f4) to tx(f3),ty(f3) if worldt(a)=1 then setrgb 1,0,20,0 line tx(f1),ty(f1) to tx(f2),ty(f2) line tx(f2),ty(f2) to tx(f3),ty(f3) line tx(f3),ty(f3) to tx(f4),ty(f4) line tx(f4),ty(f4) to tx(f1),ty(f1) fi fi return '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' This Subroutine Erases All The Old Data From The Arrays ' That Hold The Data From Which The Screen Display Is Made '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% label clearworld '========================================================= ' Clear out all the old display data; '========================================================= for a=1 to (maxobj*2)+1 worldt(a)=0 :rem Empty Object Types. worldo(a)=0 :rem Empty Orientations. worldx(a)=0 :rem Empty X Positions. worldy(a)=0 :rem Empty Y Positions. worlds(a)=0 next a for a=1 to maxshot shotx(a)=0 shots(a)=0 shotz(a)=0 shotv(a)=0 shoto(a)=0 next a shotpos=1 worldpos=1 return '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 'This Subroutine Rotates All The Enemy Tank Positions In 'Relation To The Player And Decides What Tanks To Draw. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% label rotatemap for a=1 to maxobj if objects(a)<0 then objects(a)=objects(a)+1 objecto(a)=objecto(a)+objects(a) fi '--------------------------------------------------------- ' Calculate if tank needs to be displayed; '--------------------------------------------------------- objectv(a)=0 if (objectx(a)>px-200) and (objectx(a)pz-200) and (objectz(a)-120 and xx<760 then worldt(worldpos)=1 :rem store tanktype worldo(worldpos)=objecto(a) :rem store orientation. worldx(worldpos)=xx :rem Store X Screen. worldy(worldpos)=yy :rem Store Y Screen. worldz(worldpos)=tanksize : rem Store Z Pos. worlds(worldpos)=mod(359+objects(a),360) worldpos=worldpos+1 fi fi next a return '######################################################### ' This Subroutine Clears The Screen And Draws ' The Artificial Horizon And Sky. '######################################################### label clear_screen if flsh>0 flsh=flsh/1.5 if rmb>0 rmb=rmb/3 setrgb 1,2+flsh,22+flsh,7+flsh setrgb 2,2+flsh,53+flsh,7+flsh setrgb 3,6+flsh,53+flsh,7+flsh gtriangle 0,256 to 640,512 to 0,512 setrgb 3,2+flsh,22+flsh,7+flsh gtriangle 0,256 to 640,512 to 640,256 setrgb 1,30+flsh,50,80 setrgb 2,40+flsh,40,30 setrgb 3,50+flsh,30,80 gtriangle 0,0 to 640,258 to 640,0 setrgb 3,40+flsh,40,30 gtriangle 0,0 to 640,258 to 0,258 '--------------------------------------------------------- ' Draw Background Moutains '--------------------------------------------------------- sp=pr sp=sp-640 'setrgb 1,100,255,66 setrgb 1,12+(flsh/2),32,7 setrgb 2,2+(flsh/2),22,7 setrgb 3,0,0,0 for a=1 to 72 gtriangle sp*9,mh(a) to (sp*9)-100,258 to (sp*9)+100,258 sp=sp+10 next a return '######################################################### ' Draw The Screen Display + Score table. '######################################################### label overlay '--------------------------------------------------------- ' Heading Display: '--------------------------------------------------------- setrgb 1,40,120,40 line 0,170-rmb to 640,170-rmb for a=int (-(pr)) to 640 step 36 line a,167-rmb to a,174-rmb next a setrgb 1,50,140,60 text 320,174-rmb,"HEADING:"+str$(pr)+" DEG","cc" '--------------------------------------------------------- ' Overlay; '--------------------------------------------------------- setrgb 1,10,10,30 fill rect 100,400+rmb to 540,512 fill triangle 0,512 to 100,512 to 100,400 fill triangle 640,512 to 540,512 to 540,400 '--------------------------------------------------------- ' Map Box: '--------------------------------------------------------- mb=mb+.5 if mb>499 mb=361 setrgb 1,30,180,130 rect 250,360 to 400,500 setrgb 1,100,150,100 line 251,mb to 400,mb '--------------------------------------------------------- ' Plot Enemies On Map; '--------------------------------------------------------- fr=0:rem evasive action lo=0:rem range lock on ra=0:rem range lock on for a=1 to maxobj if objects(a)=1 then if (objectx(a)>px-200) and (objectx(a)pz-200) and (objectz(a)rtarg objecto(a)=objecto(a)-(.5+(level/10)) if objecto(a)obo-.5 and objecto(a)px-200) and (objectx(a)pz-200) and (objectz(a)50 fry=0 setrgb 1,50,155+fry,50 rect 10,12 to 630,100 text 320,25,"FRYER 3000 BATTLE COMPUTER","cc" text 320,95,"STATUS DISPLAY OF SHAW SYSTEMS CYBERTANK","cc" text 190,49,"<~ENEMY RADAR LOCK STATUS ","cc" text 190,68,"<~ENEMY IN DANGEROUS RANGE","cc" text 500,49,"HULL CONDITION:","cc" setrgb 1,255,255,255 rect 399,59 to 601,71 setrgb 1,100,energy,0 fill rect 400,60 to 400+energy,70 setrgb 1,50,155+L,50 if lo=1 setrgb 1,255,0,0 fill rect 40,40 to 50,50 setrgb 1,50,155,50 if ra=1 setrgb 1,255,0,0 fill rect 40,60 to 50,70 if fr=1 then setrgb 1,100+fry*5,100+fry,100+fry text 320,150,"WARNING ENEMY RANGE AND RADAR LOCK!","cc" fi setrgb 1,100,255,255 text 320,130,"SCORE:"+str$(score),"cc" if rmb>1 then setrgb 1,0,0,0 for a=1 to 640 step 100 a=a+ran(10) line a,0 to ran(640),512 next a fi setrgb 1,255,155,155 if pt=0 text 320,196,"GUN READY","cc" if pt>0 text 320,196,"RE-LOADNG","cc" return '######################################################### ' Read The Pad And Move The Player Around The World. '######################################################### label player_control_move pxold=px : rem FOR USE IN COLLISION DETECTION pzold=pz : rem FOR USE IN COLLISION DETECTION '========================================================= ' Pause Game; '========================================================= if and (c,8)<>0 then setrgb 1,255,255,255 text 320,246,"TANK ZONE (C) SHOCKWAVE 2002","cc" text 320,266,"PAUSE MODE PRESS (SELECT) TO CONTINUE","cc" dw=1-dw setdispbuf dw repeat until (and (peek("port1"),1)<>0) fi '========================================================= ' Forward Movement; '========================================================= if and (c,16)<>0 then px=px+(sin((pr)*pi/180)*2) pz=pz-(cos((pr+180)*pi/180)*2) fi '========================================================= ' Backward Movement; '========================================================= if and (c,64)<>0 then px=px-(sin((pr)*pi/180)*2) pz=pz+(cos((pr+180)*pi/180)*2) fi '========================================================= ' Firing! '========================================================= if ((and(c,16384)<>0) and pt=0 and ps=0) then ps=1 pt=50:rem Player Shot Timer. sx=px:rem Player shot position X sz=pz:rem Player shot position Z so=pr:rem Player Shot Orientation sxd=-(sin((pr+180)*pi/180)*6) szd=-(cos((pr+180)*pi/180)*6) flsh=flsh+500 fi '========================================================= ' Limit Player Movement In 3D World. '========================================================= if px<-500 px=-500 if px>500 px=500 if pz<-500 pz=-500 if pz>500 pz=500 '========================================================= ' Convert "pr" into a Viable Angle For Rotation; '========================================================= if pr<0 pr=359 pr=mod(pr,360) c=peek("port1") if and (c,128)<>0 pr=pr+2 if and (c,32)<>0 pr=pr-2 for a=1 to maxobj if objects(a)=1 then if px>objectx(a)-20 and pxobjectz(a)-20 and pz-100 and objectz(a)<100 objectz(a)=200+a*40 next a flsh=0 pt=0 pss=0 complete=5:rem Level complete indicator return '||||||||||||||||||||||||||||||||||||||||||||||||||||||||| '######################################################### ' Initialise Everything Ready For The Game; '######################################################### '||||||||||||||||||||||||||||||||||||||||||||||||||||||||| label setup open window 640,512 high=350:rem High Score '========================================================= 'Tank Variables, the following storage will contain the 'Tanks position, type, status and orientation. '========================================================= maxobj=5 : rem Maximum No. of tanks dim objects(maxobj) : rem Tank Status 0-off 1-on dim objectx(maxobj) : rem Tank X position In World dim objectz(maxobj) : rem Tank Z position In World dim objectt(maxobj) : rem Tank Type 1,2 or 3 dim objectf(maxobj) : rem Tank firing timer dim objectsxd(maxobj) : rem Tank firing X Dir dim objectszd(maxobj) : rem Tank firing Z Dir dim objectsx(maxobj) : rem Tank firing X dim objectst(maxobj) : rem Tank bullet Timer dim objectsz(maxobj) : rem Tank firing Z dim objectso(maxobj) : rem Tank firing O dim objectss(maxobj) : rem Tank firing Status dim objecto(maxobj) : rem Tank rotation dim objectv(maxobj) : rem Tank Visible/Invisible dim screenx(maxobj) : rem Screen Display Position X dim screeny(maxobj) : rem Screen Display Position Y dim shotx(maxobj+1):rem Shot X pos dim shotz(maxobj+1):rem Shot Z pos dim shott(maxobj+1):rem Shot timer dim shots(maxobj+1):rem Shot Status dim shoto(maxobj+1):rem Shot Orientation dim shotv(maxobj+1):rem Shot Visible/invisible maxshot=maxobj+1 dim tanksize(maxobj) tsize=12 '========================================================= 'World Array Format; 'type, orientation, xscreen, yscreen, Z pos. '========================================================= dim worldt((maxobj*2)+2 ) dim worldo((maxobj*2)+2 ) dim worldx((maxobj*2)+2 ) dim worldy((maxobj*2)+2 ) dim worldz((maxobj*2)+2 ) dim worlds((maxobj*2)+2 ) '########################## '## Define Sine Tables!! ## '########################## dim cs(360) dim sn(360) for ang=0 to 360 cs(ang)=cos(ang*(pi/180)) sn(ang)=sin(ang*(pi/180)) next ang '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Storage For 3D Objects; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dim x(28) : Rem X co-ordinate store dim y(28) : Rem Y co-ordinate store dim z(28) : Rem Z co-ordinate store dim tx(28) : Rem Transformed X co-ordinate store dim ty(28) : Rem Transformed Y co-ordinate store dim tz(28) : Rem Transformed Z co-ordinate store '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Background Scenery; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dim mh(72): Rem define random heights for mountains. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Read in the 3D objects data; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for a=1 to 28 read x(a),y(a),z(a) next a return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' 3D Objects; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '"Tank" ~ 22 Vertices. data 5,2,2,-5,2,2,5,2,-2,-5,2,-2 data 6,0,5,-6,0,5,-6,0,-5,6,0,-5 data 5,-2,2,-5,-2,2,5,-2,-2,-5,-2,-2 'data 5,-4,2,-5,-4,2,5,-4,-2,-5,-4,-2 data 5,-4,1,-5,-4,1,5,-4,-1,-5,-4,-1 data 5,-3,0,5,-2,1,5,-2,-1 data 10,-3,0,10,-2,1,10,-2,-1 '"Bullet" 6 vertices. (Cross) data 0,0,1,0,0,-1 data 1,0,0,-1,0,0 data 0,1,0,0,-1,0 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Do The Simple Text Based Get Ready Screen; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ label game_over for c=1 to 2 setdrawbuf dw dw=1-dw setdispbuf dw l=0 setrgb 1,40,60,40 setrgb 2,50,80,50 setrgb 3,20,40,20 gtriangle 0,0 to 640,512 to 0,512 gtriangle 0,0 to 640,512 to 640,0 for a=1 to 4 setrgb 1,l,l,l text 320-a,230-a,"MESSAGE FROM FRYER 3000 BATTLE COMPUTER:","cc" text 320-a,250-a,"YOU REACHED LEVEL "+str$(level+1)+", COMMANDER","cc" text 320-a,270-a,"SHAW SYSTEMS HULL SHIELDS ARE DESTROYED","cc" text 320-a,290-a,"YOU SCORED "+str$(score)+", COMMANDER","cc" text 320-a,310-a,"THANK YOU FOR PLAYING TANK ZONE","cc" text 320-a,330-a,"PLEASE RETURN AGAIN TO DO BATTLE WITH XALTHORN INDUSTRIES","cc" text 320-a,490-a,"PRESS SELECT ON YOUR DPAD TO GO TO TITLE SCREEN","cc" l=l+70 next a next c wait .5 repeat c=peek("port1") until (and(c,1)<>0) return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Do The Simple Text Based Get Ready Screen; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ label next_level for c=1 to 2 setdrawbuf dw dw=1-dw setdispbuf dw l=0 setrgb 1,40,60,40 setrgb 2,50,80,50 setrgb 3,20,40,20 gtriangle 0,0 to 640,512 to 0,512 gtriangle 0,0 to 640,512 to 640,0 for a=1 to 4 setrgb 1,l,l,l text 320-a,230-a,"MESSAGE FROM FRYER 3000 BATTLE COMPUTER:","cc" text 320-a,250-a,"WELCOME TO LEVEL "+str$(level+1)+", COMMANDER","cc" text 320-a,270-a,"SHAW SYSTEMS HULL SHIELDS ARE FULLY CHARGED UP","cc" text 320-a,290-a,"PLEASE NOTE THAT XALTHORN INDUSTRIES CYBER TANKS","cc" text 320-a,310-a,"BECOME MORE DEADLY WITH EACH NEW LEVEL","cc" text 320-a,330-a,"GOOD LUCK COMMANDER","cc" text 320-a,490-a,"PRESS SELECT ON YOUR DPAD TO BEGIN","cc" l=l+70 next a next c wait .5 repeat c=peek("port1") until (and(c,1)<>0) return '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Do The Simple Text Based Title Screen; '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ label title for c=1 to 2 setdrawbuf dw dw=1-dw setdispbuf dw l=0 setrgb 1,40,60,40 setrgb 2,50,80,50 setrgb 3,20,40,20 gtriangle 0,0 to 640,512 to 0,512 gtriangle 0,0 to 640,512 to 640,0 for a=1 to 4 setrgb 1,l,l,l text 320-a,30-a,"TANK ZONE : CODED BY SHOCKWAVE (C) 2002","cc" text 320-a,70-a,"THE AIM OF THE GAME:","cc" text 320-a,90-a,"YOU ARE IN COMMAND OF A SHAW SYSTEMS CYBERTANK. YOUR MISSION","cc" text 320-a,110-a,"IS TO DESTROY THE XALTHORN INDUSTRIES ENEMY CYBER TANKS","cc" text 320-a,130-a,"THE XALTHORN IND. TANKS ARE UNFORTUNATELY VERY","cc" text 320-a,150-a,"ADVANCED. LUCKILY FOR YOU, YOU HAVE THE FRYER 3000","cc" text 320-a,170-a,"BATTLE COMPUTER ABOARD YOUR OWN WAR MACHINE.","cc" text 320-a,190-a,"FRYER WILL WARN YOU WHEN A XALTHORN HAS A LOCK ON YOU.","cc" text 320-a,210-a,"'HE' WILL ALSO MONITOR YOUR TANKS OTHER FUNCTIONS.","cc" text 320-a,230-a,"USE YOUR D-PAD L&R TO ROTATE YOUR TANK, U&D TO MOVE","cc" text 320-a,250-a,"PRESS (X) TO FIRE YOUR CYBER CANNON, START TO PAUSE","cc" text 320-a,270-a,"KILL ALL TANKS TO GET TO NEXT LEVEL!","cc" text 320-a,290-a,"LONG DISTANCE SHOTS GET YOU HIGHER SCORES","cc" text 320-a,310-a,"IF ENEMYS BLAST YOU AT CLOSE RANGE IT DOES MORE DAMAGE","cc" text 320-a,330-a,"IT'S GAME OVER WHEN YOUR HULL GETS TOO DAMAGED!","cc" text 320-a,350-a,"HAVE FUN WITH IT GUYS AND GIRLS. (C) SHOCKWAVE (NICK SIMPSON).","cc" text 320-a,390-a,"CHECK OUT: WWW.PS2-YABASIC.CO.UK","cc" text 320-a,410-a,"CHECK OUT: WWW.YABASIC.CO.UK","cc" text 320-a,430-a,"CHECK OUT: WWW.GAMEVINE.NET","cc" text 320-a,450-a,"EMAIL ME: SHOCKWAVE@PS2-YABASIC.CO.UK","cc" text 320-a,470-a,"HIGH SCORE:"+str$(high)+" LAST GAME:"+str$(score),"cc" text 320-a,490-a,"PRESS SELECT ON YOUR DPAD TO BEGIN","cc" l=l+70 next a next c repeat c=peek("port1") until (and(c,1)<>0) return '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ' Diary Of This Game; '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ '--------------------------------------------------------- ' This is my first attempt to write a 3D game in Yabasic, ' I decided to do a version of the old tank classic ' For my own curiosity more than anything. '--------------------------------------------------------- 'I can forsee that this program will need a lot of matrix 'rotations and a fair chunk of AI and I doubt it if I will 'be able to manage 50fps... 25fps looks attainable though. 'Edit 21/07. 25 fps?!? Who was I trying to kid? '12 fps more likely. '--------------------------------------------------------- ' 'Program History: '~~~~~~~~~~~~~~~~ '16/05/02 Basic rotation code started, Test mode created. 'The rotation code doesn't quite work right yet. It is 'producing odd angles. The rotation variable is working 'properly. Problem probably caused by radians. '--------------------------------------------------------- '18/05/02, The Rotation code to rotate the tank is now 'working properly and you can "Drive" the tank around the '3D world, although there is nothing visible on screen to 'indicate this, the debug mode shows that the tank is in 'fact moving around in the 3D world. 'Added the directional arrow to show which direction you 'are facing. 'Added a simple screen overlay that's meant to be the view 'of the world from your tank. I'll make this look a lot 'prettier when I've got the game working :) '--------------------------------------------------------- '20/05/02, Map code added, started to impliment the enemy 'tanks, you can now drive around the "world" and encounter 'the enemy.. The tanks are just represented by yellow 'blobs at the moment though. 'Changed the blobs to expanding rectangles to indicate the 'size of the tank. 'Program framed out in Debug mode today for the first time 'Designed and tested the enemy tank graphic with another 'of my 3D programs, the object weighs in at 22 Veritces, 'Non convex and 18 polygons. Cell shaded too. This game's 'DEFINATELY going to run slower than 50 fps now!! '--------------------------------------------------------- '22/05/02, It's slow progress, I'm so busy at work that it 'is hard to grab a moment to work on this.. I spend all 'day thinking of ideas for the game and then I end up 'falling asleep before I can impliment them.. Nevertheless 'today I did manage to get a couple of hours work done. 'As is usual I began by doing some tidying up (indenting). 'I have re-designed the screen overlay today and squashed 'the map into a less obtrusive part of the screen. The 'code up to now is all working perfectly, I added some 'graphical jazz to the map with a radar bar scrolling 'down. The next major part of the code will be to create 'a proper depth sorted view of the world, once that's 'done I can put the tanks in. 'When the tanks are in I can start to turn this into a 'game with gameplay. It's simpler to think of this game as 'a 2D game that operates entirely based on the map, the 'game engine just turns a visible chunk of the map into 'a 3D screen display... This seems to be the secret in 'coding 3D games, it's how I like to think of it anyway.. 'Sure there's a bunch more stuff to do with a 3D game 'than a 2D game but it's just lots of small programs that 'work together to create the whole experience in the end. 'Sheesh, written loads in this diary today so I'll stop 'for now. '--------------------------------------------------------- '25/05/02, I've jumped the gun today and gone ahead of my 'plans... I was going to sort the 3D world before I put 'the tanks in, but I've gone and done the tanks now. And 'there I go again.. Right, alterations and additions in 'the correct order this time; 'Got rid of the green blob on the radar and replaced it 'with the directional arrow (looks much better now).. 'Fixed a slight bug with the radar (the scan line was 'moving 1 Pixel too far down the screen). Added the world 'arrays, the screen will be constructed from these arrays. 'added the tank model. Added display code for the tanks. 'replaced those awful expanding tanks with proper 3D ones! 'YAY!!! Now I'll have to sort the world and tweak the 'tank drawing bit. '--------------------------------------------------------- '27/05/02, The 3D world is now being depth sorted. The 'sort routine that I have made will also handle the shots 'of the player and enemy. I have tested it and found it to 'be working correctly... I now need to alter the tank 'code so that the range is calculated as a circle and not 'as a square bounding box.. Very late now so it will have 'to wait for another day... '--------------------------------------------------------- '01/06/02. Well, a big gap since the last entry, I have 'implimented some "tidying up" stuff today. I changed the 'tanks colours to green first of all. Then I made the 'tanks actual visible image rotate in relation to your own 'rotation, for instance if you approach a tank from behind 'you see the behind, if you approach from the front, you 'see the front. Also I increased the draw distance all the 'way to the horizon as well.. Slower now but looking 100% 'better. '--------------------------------------------------------- '04/06/02, After a major, major problem the game is back 'on track.. Basically I had problems in making the enemy 'tanks rotate to face the player, it's fixed now. I've 'also given the game a major overhaul. The graphics have 'been made much more "retro". I've removed the overlay 'and all the other unnescessary junk and just left the 'radar and the gun sight... The only other things that 'I'll need are an energy bar and a score, the screen 'display will be complete. The colours have been made to 'look much more surreal too, and I'm pleased with the way 'that they're looking. 'I'm going to add collisions betwen player and enemys 'next I think, although there are a number of things that 'can go into the game now and it doesn't matter much what 'order I do them in now I suppose. '--------------------------------------------------------- '05/06/02. Another graphical overhaul, I've changed the 'colours around again, and added the background mountains. 'These seem sufficient to illustrate that the tank is 'rotating. 'I decided to try and impliment the player's bullets. It's 'half done, but as "Jim Shaw" might say, I've been 'presented with another "gotcha!". The bullet changes it's 'position on the map sometimes when the dpad is pressed. 'I don't know why this is happening, but I guess I'll find 'out sooner or later... 'I also suspect that re-writing the map rotation code 'will be needed to allow for the bullets. '--------------------------------------------------------- '08/06/02. The glitch with the bullet position was due 'to duplicate variable names and not the logic of the code 'I'm thankfull for this as logical errors are more of a 'pain to sort out. 'The collisions between player bullets and enemy tanks is 'in, I added a little spin of the enemy tank when it gets 'blasted.. It looks quite surreal as I haven't got the 'player's bullet graphic on screen yet... I haven't 'yet decided what shape the bullets should be. I'll have 'to write the 3D bullet handling code soon though. '--------------------------------------------------------- '09/06/02. Bullet code is now in place and working, not 'tested or optimised yet. I have used a fast spinning cube 'for the bullet graphic. '--------------------------------------------------------- '15/06/02. The player cannot drive straight through enemy 'tanks any more. That collision has been implimented this 'is the first chance I have had to work on this game for 'almost a week! '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '21/07/02. Well after a break of over a month, I feel so 'guilty about not working on this game that I have decided 'to try and get it finished. I've added a few preliminary 'fixes to the game to get back into it. The code is a real 'mess. I can't believe that it was me who wrote it. 'I have however managed to do quite a bit of work on the 'game today.. Here's what's been altered/added:- '* Stopped the stupid Looking Y rotation of shot tanks. 'they just spin around thier X axis when hit now. '* Spaced the enemy tanks out properly. '* Stopped the tanks bunching when they track you. '* Stopped one player shot killing more than one tank at a 'time. '* Fixed a bug in the world sort. '* These mods have slowed the game down a bit but it's a 'bit more complete now. '* Added Battle Computer HUD to display. '* Added Radar lock LED. '* Added In Range LED. '* Added Energy Bar. '* Added Score Display. '* Added Scoring. '* Changed Gunsight Graphics. '* Enemy shot logic put in place. If enemy is in range and 'facing you, warning display comes up. '* Enemy bullets implimented. The Enemy now fires at you 'with un-nerving accuracy. This will be a tough game! '* Enemy bullets now collide with the player. '/\ That's not bad going at all!! That's at least a weeks 'progress condensed into one afternoon. Essentially all I 'have to do now is tweak it and turn it into a game.. 'All the mechanics of the engine are now in place. '* Changed bullet graphic to Wireframe cross type thing. '* Added lighting effects. '* The game is pretty good fun actually. :o) Result. '* Added Title screen (text based for speed). '* Added Game Over Screen (text based for speed). '* Added Get ready screen (text based for speed). '* Created game loops. 'The game is complete. 'Todays additions took me 10 hours... What can I say? 'Thank god for that? 'Oh, and it's 12 fps... Sorry S8n( '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~