Page 1 of 1

Tanks - Simple parabolic shooting game

Posted: Wed Sep 11, 2013 7:23 am
by Wilshusen

Code: Select all

dim m(1025)
randomize(current_second())
graphics
rem print screen_height()
punts0=2!punts1=2

INICI:
graphics clear 0,0,0
a=512
m(0)=rnd(500)+200! m(1024)=rnd(500+200)!m(512)=rnd(700)
rem m(0)=500!m(512)=600!m(1024)=500
draw color 0,0.5,0
draw line 0,m(0) to 0,700
draw line 512,m(512) to 512,700
draw line 1024,m(1023) to 1024,700
x1=rnd(400)+50! x2=rnd(400)+575!y1=0!y2=0

TERRA:
a=a/2 ! if a<1 then goto MAIN
for b=a to 1024 step a*2
   m(b)=((m(b-a)+m(b+a))/2) + rnd(1)*a*3-a*1.5
   if m(b)<100 then m(b)=100
   if b<x1+25 and b>x1-25 and y1=0 then y1=m(b)
   if b<x1+25 and b>x1-25 and y1>0 then m(b)=y1
   if b<x2+25 and b>x2-25 and y2=0 then y2=m(b)
   if b<x2+25 and b>x2-25 and y2>0 then m(b)=y2
   draw color rnd(0.3),rnd(0.3)+0.2,0
   draw line b,m(b) to b,700
next b
go to TERRA


MAIN:
player=0
for a = 0 to 1024
if m(a)>700 then m(a)=700
next a

TANK:
fill color 0.5,0,0! fill rect x1,m(x1) size 20,8
fill color 0.7,0,0! fill rect x1,m(x1)+3 size 15,3
fill color 0.6,0,0! fill rect x1,m(x1)-11 size 8,6

fill color 0,0,0.7! fill rect x2,m(x2) size 20,8
fill color 0,0,1! fill rect x2,m(x2)+3 size 15,3
fill color 0,0,0.8! fill rect x2,m(x2)-11 size 8,6


LOOP2: 
if player=0 then fill color 1,0,0 else fill color 0.3,0,0
fill rect 0,0 to punts0*40,39 
if player=1 then fill color 0,0,1 else fill color 0,0,0.3
fill rect 0,40 to punts1*40,80
draw color 1,1,1! draw line 80,0 to 80,80

rem x=x1!y=m(x1)-17
ESPERA:
xf=touch_x(0)!yf=touch_y(0)!if xf<0 then go to ESPERA
rem if player=0 then x=x1!y=m(x1)-17!ix=(xf-x1)/100!iy=(yf-m(x1))/100
rem if player=1 then x=x2!y=m(x2)-17!ix=(xf-x2)/100!iy=(yf-m(x2))/100 


t=10!c=1
Gosub TIRO
t=1!c=0
Gosub TIRO
goto FINAL

TIRO:
if player=0 then 
   x=x1!y=m(x1)-17!ix=(xf-x1)/100!iy=(yf-m(x1))/100
   end if
if player=1 then
    x=x2!y=m(x2)-17!ix=(xf-x2)/100!iy=(yf-m(x2))/100
   end if
DISPARO:
time reset
x=x+ix!y=y+iy!iy=iy+.02
draw color c,c,0
draw rect x,y size 1
if b<x1+25 and b>x1-25 and y1=0 then y1=m(b)
if b<x1+25 and b>x1-25 and y1>0 then m(b)=y1
TEMPS:If timer()<t then goto TEMPS
if x<0 or x>1024 then return
if y<m(x) then goto DISPARO
return

FINAL:
bom=0
if player=1 then
   if x>x1-30 and x<x1+30 then gosub BOOM
   if bom=1 then punts1=punts1+1
   end if
if player=0 then 
   if x>x2-30 and x<x2+30 then gosub BOOM 
   if bom=1 then punts0=punts0+1
   end if

if player=0 then player=1 else player=0

if bom=1 then INICI
goto LOOP2


BOOM:
bom=1
fill color 1,1,1
for a =1 to 10
time reset
fill circle x,y size a*15
LOOP3: if timer()<50 then LOOP3 
next a 
for a=100 to 0 step -5
time reset
fill color a/100, a/100, a/100
fill circle x,y size 153-a/50
LOOP4: if timer()<100 then LOOP4
next a 
pause 2
return

Re: Tanks - Simple parabolic shooting game

Posted: Wed Sep 11, 2013 9:22 am
by Mr. Kibernetik
Nice!

But I also noticed a bug in smart BASIC - goto FINAL: must not allow ":" after the label name. This bug will be corrected in next release of smart BASIC, but this also will make your current version non-runable...

Re: Tanks - Simple parabolic shooting game

Posted: Mon Jan 04, 2016 6:30 pm
by Wilshusen
Mr. Kibernetik wrote:Nice!

But I also noticed a bug in smart BASIC - goto FINAL: must not allow ":" after the label name. This bug will be corrected in next release of smart BASIC, but this also will make your current version non-runable...
Ok, program updated