Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (601)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Pulpcore Pool Game (Advice Please).  (Read 2817 times)
0 Members and 1 Guest are viewing this topic.
Offline steveyO
« Posted 2010-01-24 22:37:46 »

After quite annoyingly wasting an hour playing a miniclip pool game this afternoon it ocurred to me it 'may' be relatively easy to write a simplified version of one using Pulpcore.

I put this together in about 2 hours using Pulpcores bubblemark code (ok, I nicked a pool table/cue from the net, so will replace the stolen graphics if I continue with this).  Doesn't do anything yet!

http://www.bullsquared.com/pool/pool.jsp  (Pulpcore applet)

Source code for those not familiar with Pulpcore/Bubblemark tests here:
http://www.interactivepulp.com/pulpcore/bubblemark/
http://www.interactivepulp.com/pulpcore/bubblemark/src/Ball.java


Question, is:  I know nothing about ball physics/java physics libraries etc.. (Can't say I even understand the Ball.java elastic collision code either)..  Anyone know if it would be easy to change this (the vx/vy velocities) to put in some ball momentum code so the balls actually stop (easy noob examples please?).. Or would it be better to use a physics engine and if so, which one?  I guess for cueball top/back spin and side would have to do this myself regardless (or do any of the physics libraries handle this too)?

Not sure whether I'll continue with this one (depending on complexity of physics) or add the ever growing uncompleted work shelf! 

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline Karmington

Senior Devvie


Medals: 1
Projects: 1


Co-op Freak


« Reply #1 - Posted 2010-01-24 23:16:01 »

It's been done so many times, if you have no real spark for the game or the physics i don't see why bother...
But, Basic ball to ball collision already being there, (though if you look at it a bit it allows balls to pass through each other every so often) there should already be velocity / acceleration variables to tweak, f.ex. (acceleration * 0.9) dampens speed nicely, depending on your unit scale of course.
Adding curves is also doable, easiest by adjusting the direction of the ball i.e. cheating, not by actually modelling the spin and friction to the realistic level.

Offline Nate

« JGO Bitwise Duke »


Medals: 158
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #2 - Posted 2010-01-25 07:08:00 »

I like this simulation:
http://compsci.ca/v3/viewtopic.php?t=14897
It looks ahead to determine how long until the next collision. When you step the simulation, if a collision would happen within the step, it steps the simulation to the collision, does the collision response, and then steps the rest of the way (or until the next collision). This is really neat, but the math is a bit hairy (although it is done for you in that thread). This approach works well with a box, but less so if you want advanced features like pillars or whatever inside the box, or if you want curved trajectories.

The other (less cool but simpler) way to do it is what you already have. Just apply a constant friction to slow down your balls. Eg, vx *= 0.9.

Your pool game will look more realistic if you use two friction values. If your velocity is below some threshold, apply kinetic friction, otherwise apply static friction. The reason why is when a pool ball is hit, it is not yet rolling. The ball is being pushed along the table surface and the friction is high. The friction with the table surface causes angular momentum. As the ball slows it starts rolling, which causes less friction with the table surface.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline steveyO
« Reply #3 - Posted 2010-01-25 15:53:05 »

Well, if am brutally honest,  have absolutely no spark/interest whatsover for the physics, but am gonna bother,  if that upsets anyone, so be it.  Yesterday I found a 100+ page .pdf tutorial describing all the game physics on programming a pool game. Nuf said!

Anyway,  new version is up (changes described on webpage)..  I have multiplied the vx/vy by 0.99 (0.90 slows balls down too quickly) and when they reach below a certain velocity, I set the velocies to 0.   Not perfect but a very good approximation (a few tweaks may improve too).  Will have a look at some of the kinetic friction pages later to see if that can help provide a little more realism (especially when ball falls under a certain velocity).

The looking ahead code (if can get it working) would be cool so I can provide some little helper arrows (so player can see which direction next ball will go!).  The pocket jaws may be bitch to code too, but if can get these 3 things working the rest should be quite straightforward.... persecutioncomplex

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline pjt33
« Reply #4 - Posted 2010-01-25 16:44:21 »

Well, if am brutally honest,  have absolutely no spark/interest whatsover for the physics, but am gonna bother,  if that upsets anyone, so be it.  Yesterday I found a 100+ page .pdf tutorial describing all the game physics on programming a pool game. Nuf said!
<snip>
The looking ahead code (if can get it working) would be cool so I can provide some little helper arrows (so player can see which direction next ball will go!).  The pocket jaws may be bitch to code too, but if can get these 3 things working the rest should be quite straightforward.... persecutioncomplex
Does the tutorial describe resolving multiple simultaneous collisions involving the same ball? That's where things really get ugly.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (48 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!