Crazy Balls

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

Post by DrChip »

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
Attachments
image.jpg
image.jpg (123.11 KiB) Viewed 1894 times

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Crazy Balls

Post by Mr. Kibernetik »

Very interesting!
My crazy modification of "Crazy Balls":

Code: Select all

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

sprite "balls" begin scw,sch
sprite end
sprite "balls" show

DIM x(8),y(8),z(8),xa(8),ya(8),cr(8),cg(8),cb(8)
DIM trix(4),triy(4)

FOR a=1 TO 7
READ x(a),y(a),z(a),xa(a),ya(a)
cr(a)=rnd(1)!cg(a)=rnd(1)!cb(a)=rnd(1)
NEXT a

scr=650

refresh off
loop: 

mm=mm+.05
scr=scr-3
GOSUB bg
GOSUB ci
GOSUB scroll
GOSUB detect
refresh 
GOTO loop
END

bg:
red=200*SIN(mm/2)/255
grn=200*SIN(mm/3)/255
blu=200*SIN(mm/4)/255
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:
sprite "balls" copy "copy"
sprite "copy" alpha 0.9
sprite "balls" begin
refresh off
graphics clear
sprite "copy" stamp
FOR a=1 TO 7
fill color cr(a),cg(a),cb(a)
cr(a)+=rnd(.2)-.1
cg(a)+=rnd(.2)-.1
cb(a)+=rnd(.2)-.1
if cr(a)<0 then cr(a)=0
if cr(a)>1 then cr(a)=1
if cg(a)<0 then cg(a)=0
if cg(a)>1 then cg(a)=1
if cb(a)<0 then cb(a)=0
if cb(a)>1 then cb(a)=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
sprite end
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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Crazy Balls

Post by Mr. Kibernetik »

Mod #2 with text sprite scrolling:

Code: Select all

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

sprite "balls" begin scw,sch
sprite end
sprite "balls" show

sprite "text" begin scw*3,20
graphics clear 0,0,1
draw COLOR 1,1,1
DRAW TEXT "Crazy Balls in Basic is a challenge!" at scw,0
sprite end
sprite "text" at 0,sch-20
sprite "text" show
sprite "text" delay 0.01
sprite "text" dx -.25
sprite "text" loop

DIM x(8),y(8),z(8),xa(8),ya(8),cr(8),cg(8),cb(8)
DIM trix(4),triy(4)

FOR a=1 TO 7
READ x(a),y(a),z(a),xa(a),ya(a)
cr(a)=rnd(1)!cg(a)=rnd(1)!cb(a)=rnd(1)
NEXT a

refresh off
loop: 

mm=mm+.05
GOSUB bg
GOSUB ci
GOSUB detect
refresh 
GOTO loop
END

bg:
red=200*SIN(mm/2)/255
grn=200*SIN(mm/3)/255
blu=200*SIN(mm/4)/255
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:
sprite "balls" copy "copy"
sprite "copy" alpha 0.9
sprite "balls" begin
refresh off
graphics clear
sprite "copy" stamp
FOR a=1 TO 7
fill color cr(a),cg(a),cb(a)
cr(a)+=rnd(.2)-.1
cg(a)+=rnd(.2)-.1
cb(a)+=rnd(.2)-.1
if cr(a)<0 then cr(a)=0
if cr(a)>1 then cr(a)=1
if cg(a)<0 then cg(a)=0
if cg(a)>1 then cg(a)=1
if cb(a)<0 then cb(a)=0
if cb(a)>1 then cb(a)=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
sprite end
RETURN

detect:
get sprite "text" pos sprx,spry
IF sprx<-scw*2 THEN sprite "text" at 0,spry
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

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

Re: Crazy Balls

Post by DrChip »

Cool mod! Colorful! :)

Post Reply