Posted: Tue Apr 18, 2006 10:41 am Post subject: Irregularly Shaped Buttons
What's the most efficient way to have irregularly shaped buttons (like territories in Risk)? I was thinking of having a large array to store each point that is on the button but I'm not sure if this is the best way.
Sponsor Sponsor
Albrecd
Posted: Tue Apr 18, 2006 11:40 am Post subject: (No subject)
If you can rectangles for parts of the shape and make up the rest with each point in an array, you could cut down the array size.
Ex:
Posted: Tue Apr 18, 2006 4:39 pm Post subject: (No subject)
wut about using whatdotcolor, and colouring the areas with different colours. If you wanted to use the same colours over and over, wut you could do is make colours that are almost the same by using RGB.addColor.
Delos
Posted: Tue Apr 18, 2006 4:57 pm Post subject: (No subject)
HellblazerX wrote:
wut about using whatdotcolor, and colouring the areas with different colours. If you wanted to use the same colours over and over, wut you could do is make colours that are almost the same by using RGB.addColor.
For simpler shapes, whatdotcolour might be an option. But as soon as one progresses to more complex shapes, one would need to rely on equations to determine the next coordinate required to drawn the needed arcs, diagonals, etc.
Attempting to draw even a simple circle with whatdotcolour will result in many spots being missed due to rounding (whatdotcolour takes integer parameters, and equations will invariably return real numbers).
Hence using something analagous to Draw.Polygon() or Draw.FillPolygon would be a better approach. As for efficiency...Turing and graphics have never been the best of friends.
GlobeTrotter
Posted: Tue Apr 18, 2006 5:14 pm Post subject: (No subject)
I'm not entirely sure how efficient this would be, but it would work. Just about any shape can be thought of as a combination of triangles. Define a shape as a flexible array of a triangle type. To draw its is fairly simple then. To check if it has been clicked, do the following:
loop through each triangle and use a point_in_triangle algorithm to determine whether the triangle has been clicked. If any are true, you have clicked the button.
do_pete
Posted: Tue Apr 18, 2006 5:23 pm Post subject: (No subject)
I did it my way but I used an array with 200,000 elements
NikG
Posted: Tue Apr 18, 2006 6:41 pm Post subject: (No subject)
Quote:
For simpler shapes, whatdotcolour might be an option. But as soon as one progresses to more complex shapes, one would need to rely on equations to determine the next coordinate required to drawn the needed arcs, diagonals, etc.
Attempting to draw even a simple circle with whatdotcolour will result in many spots being missed due to rounding (whatdotcolour takes integer parameters, and equations will invariably return real numbers).
Delos, why would he need to draw using whatdotcolor?
Couldn't he just draw using any method with different colors, and use whatdotcolor to return the one clicked on?
Cervantes
Posted: Tue Apr 18, 2006 8:29 pm Post subject: (No subject)
Short put, each continent in risk is supposed to have it's own colour, and territories within the continent have the same colour. Therefore, the best you could do would be to determine which continent you clicked on. That just isn't good enough.
If you really wanted to do it this way, you'd have to use RGB to adjust your colour palette so you get very similar shades of green, red, blue, purple etc. This way you can colour each territory in each continent a slightly different colour. To us, they will all look the same, but Turing's whatdotcolour should be able to pick up on the difference, so long as you leave the colour palette in that modified form.
Sponsor Sponsor
Delos
Posted: Tue Apr 18, 2006 11:10 pm Post subject: (No subject)
Are you sure about that Cervantes? If I recall (and I may be mistaken), changing the RGB values won't change the correspond whatdotcolour references...I vaguely recall attempting something similar a while back. I might test it out later and post the results.
@NikG - I was just responding to the above suggestion of using whatdotcolour, and pointing out some of its short comings.
zylum
Posted: Wed Apr 19, 2006 12:06 am Post subject: (No subject)
you can always have completely different colors for each territory but only draw them when the users clicks one it... if you are using offscreenonly you can do this with out the user even realising this. when the user clicks with the mouse, draw the territories and then use whatdotcolor (without updating the screen). then redraw what should be on the screen before you update it...
here is a simple example of what i mean:
code:
setscreen ("offscreenonly")
var mx, my, md, clr : int
loop
mousewhere (mx, my, md)
if md = 1 then
for i : 0 .. 9
for j : 0 .. 9
Draw.FillBox (i * maxx div 10, j * maxx div 10, (i + 1) * maxx div 10, (j + 1) * maxy div 10, i * 10 + j)
end for
end for
end if
clr := whatdotcolor (mx, my)
Draw.FillBox (0, 0, maxx, maxy, blue)
locate (1, 1)
put clr
View.Update
end loop
the screen is blue but there is a checkered pattern being drawn behind the View.Update. so when the user clicks, that pattern is drawn and then whatdotcolor is used.
Cervantes
Posted: Wed Apr 19, 2006 5:50 pm Post subject: (No subject)
That works, zylum? Strange. I thought whatdotcolour looked at the front buffer, not the back.
edit: Oh wait, that's Draw.Fill()
Delos: I think that's how it works. I seem to recall making a program that would load an image and then convert it to greyscale. The only way any sort of quality was maintained is by converting the 256 colours we have to work with to shades of grey. Whatdotcolour then matched each pixel in the original, coloured image with its closest colour in the modified greyscale palette.
But hey, it's been a while.
HellblazerX
Posted: Thu Apr 20, 2006 5:04 pm Post subject: (No subject)
Sorry, Delos, I think you misunderstood me. I suggested of using whatdotcolor as a method for checking what country the user clicked, not actually drawing the button (in fact, I have no idea how you could do that). And changing the RGB value will return a different whatdotcolor value.
TokenHerbz
Posted: Thu Apr 20, 2006 5:11 pm Post subject: (No subject)
anyone here of a graph thingy? I was in irc when hacker_dan mentioned somthing about useing a graph of some sort to make risk easily(er), (with the right knowledge)... i didn't really get what he was talking about, but thats just me, anyone know of this???
It could be the key....
Andy
Posted: Fri Apr 21, 2006 10:43 am Post subject: (No subject)
i made risk a couple of years ago and what i did was i made two maps, one with all the terrains, and one just simple colored with each territory a different colour. then when you're checking for which territory is selected, put the display in offscreen only, and draw up the single colored map, use whatdotcolor to figure out wich country it is, then draw back your original.
Dan
Posted: Fri Apr 21, 2006 11:26 am Post subject: (No subject)
And thats why you are the whatdotcolor Warrior, lol.
This sugestion was not so much for being able to click on contents, but for the progaming of the AI.
There are serveral methods you could use for the colescion dection on contents. Person i whould not make it color bases becues this whould mean that you could not chage the color of things esaly or make them textchurced or multi-colored.
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!