MiniTron by Richard Davey29th Aug 2003 23:35
|
---|
Summary I wanted to write a game in 20 lines of code or less. Thus MiniTron was born. Proper 2 player action, includes very basic A.I for the enemy, keyboard handling and math based collis Description ========================================================== Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` MiniTron ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` By Rich Davey (rich@fatal-design.com) ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` Music listened to while coding this ` Interstellar Harmony Volume 1 ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` Note: ` ` The objective was to write a complete ` game in 20 lines of code or less. I ` did it in 19. Includes 2 players and ` rudimentary Artificial Intelligence! sync rate 0 : sync on : hide mouse : dim grid(639,479) : ink rgb(255,255,255),0 for a=0 to 639 : grid(a,0)=1 : grid(a,479)=1 : dot a,0 : dot a,479 : next a for a=0 to 479 : grid(0,a)=1 : grid(639,a)=1 : dot 0,a : dot 639,a : next a x=50 : y=100 : d=2 : keycheck=timer() : ex=600 : ey=100 : ed=4 : c=0 do if d=1 : dec y : endif : if d=2 : inc x : endif : if d=3 : inc y : endif : if d=4 : dec x : endif if ed=1 : dec ey : endif : if ed=2 : inc ex : endif : if ed=3 : inc ey : endif : if ed=4 : dec ex : endif if grid(x,y)=1 then set cursor 0,0 : print "YOU DIE" : wait key : end if grid(ex,ey)=1 then set cursor 0,0 : print "YOU WIN" : wait key : end ink rgb(255,0,0),0 : dot x,y : ink rgb(0,255,0),0 : dot ex,ey : grid(x,y)=1 : grid(ex,ey)=1 if timer()>keycheck+125 : if leftkey()=1 : dec d : keycheck=timer() : if d=0 : d=4 : endif: endif : if rightkey()=1 : inc d : keycheck=timer() : if d=5 then d=1 : endif : endif if ed=1 : if grid(ex,ey-1)=1 then c=1 : endif if ed=2 : if grid(ex+1,ey)=1 then c=1 : endif if ed=3 : if grid(ex,ey+1)=1 then c=1 : endif if ed=4 : if grid(ex-1,ey)=1 then c=1 : endif if c=1 : inc ed : c=0 : if ed=5 then ed=1 if ed=0 then ed=4 : endif sync loop |