Author Topic: LOTTO!  (Read 3259 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 319
  • Karma: 25
  • Hard players don't go home.
    • View Profile
LOTTO!
« on: July 29, 2007 »
I have tried random number picking once before, but I've come up with something else.
A bit more realistic to what I really wanted.

X to activate

Code: [Select]
open window 640,512
br=15
grd=450
ball=40
dim bx(ball),by(ball),drop(ball)
dim bm(ball),dir(ball),sp(ball)
for a=1 to ball
dir(a)=int(ran(2))
if dir(a)=0 sp(a)=-4
if dir(a)=1 sp(a)=4
bx(a)=int(ran(600))+20
by(a)=br
' drop(a)=ran(.1)+.1
bm(a)=0
next a
repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
c=peek("port1")   
setrgb 1,200,200,0
fill rectangle 0,0 to 640,512
setrgb 1,0,0,0
line 0,grd to 300,grd
line 0,grd+1 to 300,grd+1
line 340,grd to 640,grd
line 340,grd+1 to 640,grd+1
for a=1 to ball
if and(c,16384)>0 then
dir(a)=int(ran(2))
if dir(a)=0 sp(a)=-4
if dir(a)=1 sp(a)=4
bx(a)=int(ran(600))+20
by(a)=br
drop(a)=ran(.1)+.1
bm(a)=0
hold=0
endif
bx(a)=bx(a)+sp(a)
if bx(a)<15 or bx(a)>625 sp(a)=-sp(a)
bm(a)=bm(a)+drop(a)
by(a)=by(a)+bm(a)
if bx(a)>0 and bx(a)<300 and by(a)>grd-br then
bm(a)=-bm(a)*.95
by(a)=grd-br
endif
if bx(a)>340 and bx(a)<640 and by(a)>grd-br then
bm(a)=-bm(a)*.95
by(a)=grd-br
endif
if by(a)>480 then
      hold=hold+1
      bx(a)=hold*(br*2)-br
      by(a)=480
      sp(a)=0
      bm(a)=0
    endif
setrgb 1,0,250,0
fill circle bx(a),by(a),br
setrgb 1,0,0,0
circle bx(a),by(a),br
text bx(a)-10,by(a)+2,str$(a)
next a
until (1=0)

The holding pattern doesn't quite work.

A curious thing I've noticed.
I know that text and rectangles are drawn faster than circles.
But when I put text inside my circles, it goes back to full speed.



« Last Edit: July 29, 2007 by bikemadness »
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: LOTTO!
« Reply #1 on: July 29, 2007 »
I like that idea - it's like a real lottery machine :)

Jim
Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: LOTTO!
« Reply #2 on: July 30, 2007 »
Nice piece of code. I tried a lotto sim, but not like yours! lol. Mine was a game... but it wasn't as styalised as yours.
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: LOTTO!
« Reply #3 on: August 07, 2007 »
Thats news to me i never heard that trick to speed up circles :P nice find man

Challenge Trophies Won: