Hi everybody !
I'm new in programming, and have decided to develop a little game with Ruby + Gosu (a bejeweled clone) on Windows 7 and I need use of the mouse.
I've already figured that the best way to use the mouse clicks in the game is in the update method, with a case statement.
The problem is when I want to set the reaction of clicking on a pawn here is my code :
case mouse_x
when (5..517)
case mouse_y
when (5..517)
if button_down?(Gosu::MsLeft)
then self.selectpion((mouse_x-5)/64, (mouse_y-5)/64)
end
end
#other instructions that works well
end
selectpion is a method that require the line and column index for a 2D array as arguments. But it seems that in this code, (mouse_x-5)/64 don't return an integer, but a range : (0..7) (and the same for mouse_y).
And it would be fastidious to detail the 64 cases for the selection of the pawns.
Can anyone tell me how to deal with it (or provide me a link for a code that would solve my problem) ?
Loading...