Author Topic: How high can you get the ball?  (Read 5262 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
How high can you get the ball?
« on: November 22, 2008 »
For me, this is noteworthy.
The extensive use of gtriangle.
I did'nt really understand it before and never used it.

However, on with the show.
'X' to pull back plunger, pinball action.
Will you see the trick?

Code: [Select]
open window 640,512
peakshow=2 rem of 4 math displays
ballx=320
bally=420
hitx=320
hity=420
sunx=500
suny=100
ang=pi/180
r=25
arc=10
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,256,256,256
setrgb 2,0,256,0
setrgb 3,0,256,0
gtriangle 640,512 to 0,450 to 640,450
setrgb 2,256,256,256
gtriangle 0,512 to 640,512 to 0,450
setrgb 2,0,0,256
setrgb 3,0,0,256
gtriangle 640,450 to 0,0 to 640,0
setrgb 2,256,256,256
gtriangle 0,450 to 640,450 to 0,0
for a=1 to 360 step arc
setrgb 2,200,200,50
setrgb 3,200,200,50
gtriangle sunx,suny to sin(ang*a)*r+sunx,cos(ang*a)*r+suny to sin(ang*(a+arc))*r+sunx,cos(ang*(a+arc))*r+suny
next a
if hity<450 then
hity=450
move=0
moveblok=0
endif
if hity>450 move=5
rem 'move simulates ball weight (greater, lighter)
if hity>490 hity=490
c=peek("port1")
if and(c,16384)>0 then
hity=hity+5
else
moveblok=moveblok+move
hity=hity-moveblok
endif
if hity-bally<30 start=moveblok
start=start-1
bally=bally-start
if bally>hity-30 then
bally=hity-30
start=-start*.9
rem multiplier simulates gravity. (1, no gravity)
endif
if bally>hity-31 then
recoil=start
recoil=recoil-.5
hity=hity+recoil
endif
setrgb 1,0,0,0
if peakshow=1 then
line 330,bally-r to 400,bally-r
text 340,bally-r-3,str$(int(height)-40)
endif
if peakshow=2 then
peak=450-bally
if start=0 height=peak
if bally=450 height=0
if peak>height newhite=peak
line 330,430-newhite to 400,430-newhite
text 340,430-newhite-3,str$(int(newhite)-40)
endif
if peakshow=3 then
peak=450-bally
if start=0 height=peak
if bally=450 height=0
if peak>height newhite=peak
setrgb 1,0,0,0
text 450,500,str$(int(newhite))
text 250,500,str$(int(start))
text 390,500,str$(int(height))
endif
if peakshow=4 then
setrgb 1,0,0,0
text 200,500,str$(move)
text 250,500,str$(moveblok)
text 390,500,str$(hity-bally)
endif
setrgb 1,256,256,0
fill rectangle hitx-10,hity-5 to hitx+10,hity+5
setrgb 1,0,0,0
rectangle hitx-10,hity-5 to hitx+10,hity+5
rem spring
for y=0 to 25 step 0.1
x=cos(y)
dot x*10+320,y*2*((500-hity)/50)+(hity+5)
next y
for a=1 to 360 step arc
setrgb 1,256,256,256
setrgb 2,256,0,0
setrgb 3,256,0,0
gtriangle ballx,bally to sin(ang*a)*r+ballx,cos(ang*a)*r+bally to sin(ang*(a+arc))*r+ballx,cos(ang*(a+arc))*r+bally
next a
until (1=0)
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17407
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: How high can you get the ball?
« Reply #1 on: November 22, 2008 »
303 seems to be about the limit for me :)

I like the way you've used the gtriangles here to make shaded spheres.
It's a time honoured tradition in Yabasic :D
Shockwave ^ Codigos
Challenge Trophies Won:

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: How high can you get the ball?
« Reply #2 on: November 22, 2008 »
I must have been subconsciously thinking about it for months, because suddenly, I just got it.

When the light dawns, it's as bright as hell.
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Xone

  • C= 64
  • **
  • Posts: 79
  • Karma: 10
    • View Profile
Re: How high can you get the ball?
« Reply #3 on: January 14, 2009 »
just got 308.

Nicely done BM  :)

Offline Yaloopy

  • Death From Above
  • DBF Aficionado
  • ******
  • Posts: 2876
  • Karma: 35
    • View Profile
    • UltraPaste
Re: How high can you get the ball?
« Reply #4 on: January 14, 2009 »
308 as well. Great little game to demonstrate some gtriangles.
Fuck L. Ron Hubbard and fuck all his clones.
Challenge Trophies Won:

Offline Galileo

  • ZX 81
  • *
  • Posts: 22
  • Karma: 0
    • View Profile
Re: How high can you get the ball?
« Reply #5 on: September 04, 2014 »
Good job! Hopefully I can do as good programs like yours.