• Welcome to Dark Bit Factory & Gravity.
 

Pool

Started by Clanky, February 10, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

rain_storm

its the collisions only it needs rules better graphics etc. but the mechanics are up and runnin and we are one step closer btw Hows College ?

Challenge Trophies Won:

Clanky

#81
Uni is great! haha. hadn't had too many hard assignments, and my group are flying with our Innovation and Design assignment (we're making a rope bag for water skiing and abseiling and other rope sports haha!)

Staying on campus is a ball! Haha!

Yea, nice. Do you think you'll use the graphics I used?
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Shockwave

The collisions look like they work really well, I liked the graphics that you had before, I hope you use them in the finished version. The only things that I would suggest are that the balls are too dark, they take forever to slow down, also aiming and adjusting the power should be faster. These are just minor tweaks though, you've accomplished a lot here. It might be one of the toughest projects you'll do for quite a long time too!
Shockwave ^ Codigos
Challenge Trophies Won:

rain_storm

Yes Clanky the graphics that you developed are going in there but I wanted to get the rules etc in there first. But I think I will work on this first since both of you guys noticed it (which is a very good indicator that the time is right to address it)
Thanks for pointing out the controls and slow down Shocky I had blinded myself to this as I was building it this became unnoticeable but now that you mention it it does take forever for the balls to stop.

Challenge Trophies Won:

Tetra

Seems to be coming along very nicely, looking forward to see the final prod :)

Pool games are great  :updance:
Challenge Trophies Won:

Way.net

Just following the spiders earlier and came across this interesting thread. :)

Did a final version ever get released as would love to see it O0

rain_storm

Never did finish this but I will have another go at it. I would like to see this completed myself

Challenge Trophies Won:

rain_storm

Update, this is the current game engine. Ball spin is not gonna be included because these routines require straight lines. Collisions are time based and I've used swept routines for everything so ball speed is not constrained.

Well that's the theory anyways in practise it still has some minor glitches in the ball / wall collisions. This is as good as its gonna get cause I wrote that routine over a year ago and it was only loosely commented, I have no idea how it works any more.

The graphics are modified from Clankys design but I made the balls and holes larger the reason being that larger balls seem to reduce issues with the the wall collisions.

I just have to merge some game logic which Clanky has already done some work on. Rules and what not.

Challenge Trophies Won:

Shockwave

Excellent engine Rain Storm, I find the controls strange, when I pull the cue back and then hit X the cue flies forward and the cue ball just seems to creep forward, maybe I am missing a trick here?
Shockwave ^ Codigos
Challenge Trophies Won:

rain_storm

if you tap X it works best, the distance the cue is to striking the white ball when you release determines the power of the shot. I wanna use a timer eventually cause pulling back the cue just doesnt feel right. But it is good for debugging.

Challenge Trophies Won:

Clanky

Awesome RS! That looks so sweet.

The collisions are great.. although it seems as though the balls have the tendency to speed up if they bounce and bounce.


Just a few bugs;
When you sink the white ball - it is placed in the 'sunken balls area'. You can still shoot however.. collisions are calculated within the 'sunken balls area' as well.
Scenario: Once you have sunken a ball, sink the white ball. This will place the white ball in the area outside the table. You will still be able too shoot.. aim at the balls which have already been sunken.. these balls will collide and move around.
The cue is 'stuck' on the white ball after you shoot.. maybe the cue could disappear until you want to shoot again.

I'm still playing it : ) soo cooool.
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

bikemadness

Whew!
I could only juggle two balls, when trying my hand at this.
And I almost dropped them, when coming up with the maths
to get this basic pinball!


open window 640,512
ang1=pi/180
ang2=180/pi
ra=30
ball=6
dim dirs(ball),xs(ball),ys(ball),ssp(ball)
dim hitang(ball),hit(ball),reang(ball)
for a=1 to ball
dirs(a)=0
read xs(a),ys(a)
ssp(a)=0
next a
dirm=30
xm=500
ym=100
msp=8
repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
  setrgb 1,200,200,0
  fill rectangle 0,0 to 640,512
  for a=1 to ball
  setrgb 1,0,256,0
fill circle xs(a),ys(a),ra
  setrgb 1,0,0,0
  circle xs(a),ys(a),ra
hitang(a)=atan(xs(a)-xm,ym-ys(a))*ang2+180
hit(a)=(abs(xs(a)-xm)^2+abs(ys(a)-ym)^2)^0.5
reang(a)=((dirs(a)+180)-dirm)*2+dirm-180
if hit(a)<ra*2 dirm=reang(a)
dirs(a)=hitang(a)-90
line xs(a),ys(a) to xs(a)+cos(dirs(a)*ang1)*ra,ys(a)+sin(dirs(a)*ang1)*ra
  next a
xm=xm+cos(dirm*ang1)*msp
ym=ym+sin(dirm*ang1)*msp
  setrgb 1,250,120,0
fill circle xm,ym,ra
  setrgb 1,0,0,0
  circle xm,ym,ra
if xm<0+ra dirm=270-dirm+270
if xm>640-ra dirm=90-dirm+90
if ym<0+ra dirm=-dirm
if ym>510-ra dirm=180-dirm+180
if dirm>360 dirm=dirm-360
if dirm<0 dirm=dirm+360
until (1=0)
data 252,126,396,126,468,252,396,378,252,378,180,252

Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

rain_storm

Wow thats remarkably tight code and those collisions work very well.


abs(xs(a)-xm)^2

^taken from the pythagoras theorum is that faster (in yabasic) than the way its done below

(xs(a)-xm)*(xs(a)-xm)


also this code uses atan to reflect the movement vector about the normal of the collision plane

hitang(a)=atan(xs(a)-xm,ym-ys(a))*ang2+180
...
reang(a)=((dirs(a)+180)-dirm)*2+dirm-180
...
dirm=reang(a)
dirs(a)=hitang(a)-90
...
xm=xm+cos(dirm*ang1)*msp
ym=ym+sin(dirm*ang1)*msp

dirs is the surface normal and dirm = collision plane? Anyway its much tighter than the way I have done this

  ed = 1.0 // energy disapated (lost)
  ...
  D = 1 / sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
  ax = (x2-x1) * D
  ay = (y2-y1) * D
  va1 = dirX(A)*ax + dirY(A)*ay
  vb1 =-dirX(A)*ay + dirY(A)*ax
  va2 = dirX(B)*ax + dirY(B)*ay
  vb2 =-dirX(B)*ay + dirY(B)*ax
  vaP1 = va1 + (1+ed)*(va2-va1) / (1+mass(A)/mass(B))
  vaP2 = va2 + (1+ed)*(va1-va2) / (1+mass(B)/mass(A))
  vecX(A) = vaP1*ax - vb1*ay
  vecY(A) = vaP1*ay + vb1*ax
  vecX(B) = vaP2*ax - vb2*ay
  vecY(B) = vaP2*ay + vb2*ax


Challenge Trophies Won:

bikemadness

Thanks.
I really had to dig deep to remember the maths you see in the code - and the way it's used - from high school (it's been a while!) and with no reference material.
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

rain_storm

http://www.youtube.com/watch?v=CdpR3hU5bAI

^The 3D pool game written for yabasic, most of you will recognise it from youtube. Well here is the source code for that program...

http://canarddechien.blogspot.com/

Problem is it doesn't run, keeps giving parse errors. I've been reading through it to see how it works, but without the ability to edit and run it's not easy to see the inner workings.

Does anyone recognise this syntax cos it doesn't make any sense to me...

if ctnz< nzc="nzc+1" xoff="FOV*ctnx/ctnz"

strings are not "$" termated variable names, also are those supposed to be c like comparisons or is this source code simply erronious.

Challenge Trophies Won:

Jim

It looks like most of the quotes shouldn't be there at all.

Jim
Challenge Trophies Won:

Clyde

also the speech marks might be brackets ( ... ) that have got jumbled with formatting. if they are at all needed.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

rain_storm

on a lighter note this game is finished check my first post for the attachment. it turned out to be >38kb. Better late than never. Hope you dont mind the changes I made to your graphics Clanky, I tried to keep them very close to what you had in mind.

Back to the youtube pool. The source code is badly corrupted it is impossible to restore it with so much of the text missing.


pad="peek(">0 then :rem R


should be something more like


pad=peek("port1")
if pad>0 then :rem Read controller only if input <> 0


with more than half of the code already corrupt in a similar fashion to this. I asked him to reupload a working copy to his blog over on youtube just wait and see what comes of it.

Challenge Trophies Won:

rain_storm

ps2Yabasic 3D Pool has been corrected by its author Canard De Chien
http://textsnip.com/a87d35
AWESOME

Challenge Trophies Won: