This was just for practicing a bit of tight code, so i set my self a challenge of doing a Multi-player in under 100 lines without using colons, and here is the result.. not completely finished, and its not particularly neat or efficient, but good fun all the same.
arrow keys and right ctrl key for player 1
WASD and left shift key for player 2
You basically go around shooting each other.
hide mouse
Tiles=10
size=500
dim ZX#(2,2)
dim oZX#(2,2)
dim bulletmove(2)
dim playerscore(2)
make camera 1
set camera view 1,0,0,screen width(),screen height()/2
make camera 2
set camera view 2,0,screen height()/2,screen width(),screen height()
box 0,0,400,400,rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255)),rgb(rnd(255),rnd(255),rnd(255))
get image 1,0,0,400,400,1
circle 450,50,50
get image 2,400,0,500,100,1
for playernum=1 to 2
make object cube playernum,10
make object sphere playernum+2,1
texture object playernum,2
position object playernum,rnd(size),5,rnd(size)
next playernum
make matrix 1,size,size,Tiles,Tiles
randomize matrix 1,30
prepare matrix texture 1,1,2,2
for hy=1 to Tiles-1
for hx=1 to Tiles-1
if hy=1 or hx=1 or hy=Tiles-1 or hx=Tiles-1 then set matrix height 1,hx,hy,1000
set matrix tile 1,hy,hx,rnd(3)+1
next hx
next hy
update matrix 1
do
for pn=1 to 2
gosub player
text 10,10+(screen height()/2*(pn-1)),"Player "+str$(pn)+" :"+str$(playerscore(3-pn))
next pn
if playerscore(2)<>playerscore(1)
if playerscore(2)>playerscore(1)
center text screen width()/2,10,"Winning"
else
center text screen width()/2,10+screen height()/2,"Winning"
endif
endif
line 0,screen height()/2,screen width(),screen height()/2
loop
player:
ZX#(pn,1)=object position x(pn)
ZX#(pn,2)=object position z(pn)
set camera to follow pn,ZX#(pn,1),get ground height(1,ZX#(pn,1),ZX#(pn,2)),ZX#(pn,2),object angle y(pn),20,15,5,1
if keystate(200-(183*(pn-1)))=1
ZX#(pn,1)=newxvalue(ZX#(pn,1),object angle y(pn),0.4)
ZX#(pn,2)=newzvalue(ZX#(pn,2),object angle y(pn),0.4)
endif
if keystate(208-(177*(pn-1)))=1
ZX#(pn,1)=newxvalue(ZX#(pn,1),object angle y(pn),-0.4)
ZX#(pn,2)=newzvalue(ZX#(pn,2),object angle y(pn),-0.4)
endif
if keystate(203-(173*(pn-1)))=1 then yrotate object pn,object angle y(pn)-0.3
if keystate(205-(173*(pn-1)))=1 then yrotate object pn,object angle y(pn)+0.3
if ZX#(pn,1)>size-(size/tiles)*2-10 then ZX#(pn,1)=size-(size/tiles)*2-10
if ZX#(pn,1)<(size/tiles)*2+10 then ZX#(pn,1)=(size/tiles)*2+10
if ZX#(pn,2)>size-(size/tiles)*2-10 then ZX#(pn,2)=size-(size/tiles)*2-10
if ZX#(pn,2)<(size/tiles)*2+10 then ZX#(pn,2)=(size/tiles)*2+10
if object collision (pn,0)>0
if object visible(object collision (pn,0))=1
position object pn,oZX#(pn,1),get ground height(1,ZX#(pn,1),ZX#(pn,2))+5,oZX#(pn,2)
ZX#(pn,1)=oZX#(pn,1)
ZX#(pn,2)=oZX#(pn,2)
endif
else
position object pn,ZX#(pn,1),get ground height(1,ZX#(pn,1),ZX#(pn,2))+5,ZX#(pn,2)
endif
if object collision (pn,5-pn)=1 and object visible(5-pn)
inc playerscore(pn)
position object pn,rnd(size),get ground height(1,ZX#(pn,1),ZX#(pn,2)),rnd(size)
bulletmove(3-pn)=0
endif
if keystate(157-(115*(pn-1))) and bulletmove(pn)=0
bulletmove(pn)=200
position object pn+2,ZX#(pn,1),get ground height(1,ZX#(pn,1),ZX#(pn,2))+5,ZX#(pn,2)
yrotate object pn+2,object angle y(pn)
show object pn+2
endif
if bulletmove(pn)>0
move object pn+2,1.5
dec bulletmove(pn)
if get ground height(1,object position x(pn+2),object position z(pn+2))<0 or object collision (pn+2,0)>2 then bulletmove(pn)=0
else
hide object pn+2
endif
oZX#(pn,1)=ZX#(pn,1)
oZX#(pn,2)=ZX#(pn,2)
return
There is no such thing as "Too Fast!"