Game: Billiard - possible? how?

Hello,

as the thread is questioning, - is it possible to develop a billiard game in PHP and JavaScript? What techniques should be used and how?

I’ve never thought about something complex like billiard, therefore it would be awesome if you’d post suggestions on how to code such a game.

PS:. I am already experienced in PHP and JavaScript, therefore I don’t need a tutorial on how to code, thanks though.

Syrux

Well, it could be done. How well it’d run would be another question.

PHP would only need to be used if you were going to add multiplayer.

For Javascript, you’d need some method for them to supply input (either with some sort of form elements to specify angle and strength, or more graphical elements with things like dragging a pool cue around).

Your best bet for a fast game would be to make use of the HTML5 canvas element, though you could do it with simple images that are absolutely positioned. When they are hit, you just apply the regular physics to them and figure out where to move them, using one of the Javascript timer functions to handle the “game loop”.

Compare the dimensions and positions of each image together to figure out when you have collisions.

It’d all be pretty much exactly the same approach as you would take for developing any other game.

If you really want to attempt this, I highly recommend picking up a book (or three) on game design and studying up on some of those basics first. This could be a challenge without it. :wink:

I think that will be the most difficult part of writing the game.
It can be done (for example, this chrome experiment requires a newer browser, it works great in FF4 and Chrome of course), but it will be an interesting challenge at the least :slight_smile:

Luckily the physics for billards aren’t much more advanced then the basic physics formula you learn on day one… but if you don’t know the formula, it is tricky. =p