Forum
Hi,
Thanks for answer.
OK. I figure how work but I don't understand at the end.
I understand that I need all the xy vertex that form each zone.
Inside your TownScreen Class with the method associate add each zone.
But this I don't understand how work
module ImageMap
def define_zone polygon, interaction
@zones ||= Array.new
@zones << Zone.new(polygon, interaction)
end
def interactions_under point
@zones.select{ |z| z.region.contains?(point) }.map(&:interaction).flatten
end
def click(x,y)
puts interactions_under(Point(x,y))
end
end
I'm very glad if you could help me.
I download your GitHub project but I don't know exactly how execute it. :(
Salut,
Josep M
Hi,
Maybe you can use action points for each player. In function of the action the player consume their action points for that turn. One time is 0 no move or whatever. Then you can pass the turn to the other player. At the begin of each turn the action points are reset and available.
The flag option is nice but with the action points you can offer many actions.
For example you have 3AP each turn.
Move 1 space 1AP
Attack 2AP
Refuel 1AP
Then the player can choice a strategy and combime actions. When AP is 0 turn end.
Salut,
Josep M
Hi,
I will try this but if the transparent os over a non-transparent, then ever the mouse will over non-transparent...
When I initialize a new zone exist any way to associate a ID for this instance, creating an array of ID-instance?
The objetive is like a Risk game, I have zones and the players pawns on zones. Selecting one player pawn I should show the posibles destinations.
Thinking about maybe I can do the same from the pawn position that will be a square like the wargames chips, and from the know position xy show the zones in other color. Each zone will have a sprite sheet with the status of the zone. Then changing the frame I can show the posibles destinations.
But how select them,... :(
Hi,
Yes, sprite is a .png. I like the idea of check the pixel if is inside the rect but keep in mind that the transparent area of one zone is over the non-transparent area of other zone, so the pixel don't be transparent. Is posible define a shape and check if the pixel is inside?
What you mean as "spatial hash", an array of positions-zone?
Salut,
Josep M
Thanks for answer.
Would be possible add the "mouse_over" into the sprite class? I mean each sprite "know" if the cursor is over or not.
If I must iterate over many zone each update I guess will be slow, isn't?
I have over 50-100 zones, and are irregular forms, each zone is a country with transparent area.
Thoughts? :)
Salut,
Josep M
Hi,
I'm new to Gosu, excuse me if I ask something basic but I don't found an answer to this after read many post and tutorials.
How can I get the id of a clicked sprite? I want to create a map with clickable zones and show some data about the zone.
I have the whole map and the XY of each zone (.jpg) to put over the main map. Then the user click over any zone and perform and action.
It's possible do that?
Thanks in advance,
Josep M
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill