Crazy Balls
Posted: Thu Jan 22, 2015 2:08 am
REM
REM Crazy Balls
REM
REM iPhone 5 / iOS 8.2 b4
'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
pi=3.1415
graphics
DIM x(8),y(8),z(8),xa(8),ya(8)
DIM trix(4),triy(4)
FOR a=1 TO 7
READ x(a),y(a),z(a),xa(a),ya(a)
NEXT a
scr=650
loop:
refresh off
graphics clear 0,0,0
mm=mm+.05
scr=scr-3
GOSUB bg
GOSUB ci
GOSUB scroll
GOSUB detect
refresh on
GOTO loop
END
bg:
red=200*SIN(mm/2)
grn=200*SIN(mm/3)
blu=200*SIN(mm/4)
fill COLOR red/255,grn/255,blu/255
'triangle
trix(0)=0
triy(0)=0
trix(1)=csw
triy(1)=0
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,blu/255
'triangle
trix(0)=0
triy(0)=0
trix(1)=0
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,0,blu/255
'triangle
trix(0)=scw
triy(0)=0
trix(1)=csw
triy(1)=0
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,grn/255,0
'triangle
trix(0)=scw
triy(0)=0
trix(1)=scw
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,0
'triangle
trix(0)=0
triy(0)=sch
trix(1)=0
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
draw COLOR 0,0,blu/255
'triangle
trix(0)=0
triy(0)=sch
trix(1)=csw
triy(1)=sch
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,grn/255,0
'triangle
trix(0)=scw
triy(0)=sch
trix(1)=csw
triy(1)=sch
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,0
'triangle
trix(0)=scw
triy(0)=sch
trix(1)=scw
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
RETURN
ci:
FOR a=1 TO 7
fill color 1,1,1
fill CIRCLE x(a),y(a) size z(a)
x(a)=x(a)+xa(a)
y(a)=y(a)+ya(a)
IF x(a)>scw-z(a) THEN
xa(a)=-xa(a)
END IF
IF x(a)<0+z(a) THEN
xa(a)=-xa(a)
END IF
IF y(a)>(sch-z(a))-20 THEN
ya(a)=-ya(a)
END IF
IF y(a)<0+z(a) THEN
ya(a)=-ya(a)
END IF
NEXT a
RETURN
scroll:
fill COLOR 0,0,1
fill RECT 0,sch to scw,sch-20
draw COLOR 1,1,1
DRAW TEXT "Crazy Balls in Basic is a challenge!" at scr,sch-20
RETURN
detect:
IF scr<-450 THEN
scr=scw
END IF
RETURN
balls:
DATA 20,20,5,2,2
DATA 20,20,7,3,3
DATA 20,20,9,4,4
DATA 20,20,11,5,5
DATA 20,20,13,6,6
DATA 20,20,15,7,7
DATA 20,20,17,8,8
REM Crazy Balls
REM
REM iPhone 5 / iOS 8.2 b4
'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
pi=3.1415
graphics
DIM x(8),y(8),z(8),xa(8),ya(8)
DIM trix(4),triy(4)
FOR a=1 TO 7
READ x(a),y(a),z(a),xa(a),ya(a)
NEXT a
scr=650
loop:
refresh off
graphics clear 0,0,0
mm=mm+.05
scr=scr-3
GOSUB bg
GOSUB ci
GOSUB scroll
GOSUB detect
refresh on
GOTO loop
END
bg:
red=200*SIN(mm/2)
grn=200*SIN(mm/3)
blu=200*SIN(mm/4)
fill COLOR red/255,grn/255,blu/255
'triangle
trix(0)=0
triy(0)=0
trix(1)=csw
triy(1)=0
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,blu/255
'triangle
trix(0)=0
triy(0)=0
trix(1)=0
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,0,blu/255
'triangle
trix(0)=scw
triy(0)=0
trix(1)=csw
triy(1)=0
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,grn/255,0
'triangle
trix(0)=scw
triy(0)=0
trix(1)=scw
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,0
'triangle
trix(0)=0
triy(0)=sch
trix(1)=0
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
draw COLOR 0,0,blu/255
'triangle
trix(0)=0
triy(0)=sch
trix(1)=csw
triy(1)=sch
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR 0,grn/255,0
'triangle
trix(0)=scw
triy(0)=sch
trix(1)=csw
triy(1)=sch
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
fill COLOR red/255,0,0
'triangle
trix(0)=scw
triy(0)=sch
trix(1)=scw
triy(1)=csh
trix(2)=csw
triy(2)=csh
fill poly trix, triy count 3
RETURN
ci:
FOR a=1 TO 7
fill color 1,1,1
fill CIRCLE x(a),y(a) size z(a)
x(a)=x(a)+xa(a)
y(a)=y(a)+ya(a)
IF x(a)>scw-z(a) THEN
xa(a)=-xa(a)
END IF
IF x(a)<0+z(a) THEN
xa(a)=-xa(a)
END IF
IF y(a)>(sch-z(a))-20 THEN
ya(a)=-ya(a)
END IF
IF y(a)<0+z(a) THEN
ya(a)=-ya(a)
END IF
NEXT a
RETURN
scroll:
fill COLOR 0,0,1
fill RECT 0,sch to scw,sch-20
draw COLOR 1,1,1
DRAW TEXT "Crazy Balls in Basic is a challenge!" at scr,sch-20
RETURN
detect:
IF scr<-450 THEN
scr=scw
END IF
RETURN
balls:
DATA 20,20,5,2,2
DATA 20,20,7,3,3
DATA 20,20,9,4,4
DATA 20,20,11,5,5
DATA 20,20,13,6,6
DATA 20,20,15,7,7
DATA 20,20,17,8,8