Crazy Balls v.1

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Crazy Balls v.1

Post by DrChip »

REM
REM Crazy Balls .1
REM I need help with the background and flickering.
REM the triangles should fade in and out. I'm too sleepy
REM to fix it... Enjoy!
REM iPhone 6 Plus / iOS 8.2b3

'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:
graphics clear
refresh off
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,.grn,.blu
'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,0,blu
'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
'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,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,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
'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,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,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
Attachments
image.jpg
image.jpg (136.98 KiB) Viewed 1796 times
image.jpg
image.jpg (131.7 KiB) Viewed 1796 times

Post Reply