Skip to main content
gamedev.net
🔒 Locked

Select pieces

Started by apocalypse_k40 8 replies 2.1k views
Original Post
apocalypse_k40
apocalypse_k40
Hello everyone, I am really new in OpenGL. I want to write a simple checkers game. Drawings are ok but how can I make a checkers piece selected when the user clicks on it? Thanks in advance and best regars.. PS: Oh just forgot! I said drawings are ok but there is a little problem. You know a checkers piece is a cylindirical shape with a little concavity in the middle of it. I made the piece with a hole in the middle of it and tried to place a concave half spere (which is like a bowl) using clipping panes with no success. How can I accomplish this too?
apocalypse_k40
apocalypse_k40
----------------------------------------------------------------------------------
As for why your checker pieces doesn't work right, I have no clue. What seems to be not right about them?
----------------------------------------------------------------------------------
Actually I want the clipping plane erase the upper half of a sphere (to make it seem like a bowl) but the clipping plane doesn't work for me. Is there another way to get such a shape?


----------------------------------------------------------------------------------
A Flat gameboard makes things much easier.
----------------------------------------------------------------------------------
Well I thought to draw a 3D board which the user can rotate. On the other hand can't we construct 3D objects like windows controls? I mean whenever you click on some 3D object, an event is fired for that object?
apocalypse_k40
apocalypse_k40
So I can use a matrix array which holds 0 for empty and 1 for pieces and can say -assuming that my board is 80x80- each element of the array will represent a value of 10 and -assuming that there is a piece at first row 5th column- [0 0 0 0 1 0 0 0] says that a piece should drawn at the square [(0,40),(0,50),(10,40),(10,50)] or thinking vice versa if the user clicks at position inside the square [(0,40),(0,50),(10,40),(10,50)] the piece is selected?

If I am right how can I get the cursor position with openGL with respect to the upper left corner (as I know OpenGL uses lower left corner as (0,0) and what if the user rotates the board?

I know I am asking too much, please excuse me!
cmptrgear
cmptrgear
What you want is called picking.

Here is a tutorial of picking in openGL.

openGL picking
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson
cmptrgear
cmptrgear
Quote:
Original post by Anonymous Poster
glpicking really is not very good
I don't recommend it, especially in a situation like a checker's board when ray/plane intersection will be much Faster and likely a good enough effect (especially considering how flat a checker piece is.)

...glpicking will let you get the job done without Math, however the technique will be useless for anything but slow things like boardgames in the future
whereas calculating intersections yourself will be invaluable even tho hard at first...


Care to back that up with some facts? I have never noticed glpicking to be as slow as you seem to indicate.
"Pfft, Facts! Facts can be used to prove anything!" -- Homer J. Simpson

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.