Completenutter2
November 20th, 2007, 02:14 PM
Hi,
I am attempting to write a cross-platform Pictionary style game in Ruby using GTK+.
Using a drawing area and a pixmap, I've managed to get drawing working on the screen. My problems comes when I want to make the size of the line bigger.
I've managed to do it, but, either I'm missing something, or the way I'm drawing is seriously flawed.
My idea was to store the 'old' mouse position, and then draw a line from the old position to the current position when the mouse moves. This works fine when the size is left at the default, but when I increase it, things start going horribly wrong.
First of all, if I move the mouse slowly, the line is drawn exactly like it was before I changed the size, and I can only make it bigger by moving the mouse quicker, and even then, you can see the separate lines that I'm drawing.
http://aycu34.webshots.com/image/33713/2002786654404130434_rs.jpg
The guilty lines of code:
@pixmap.draw_line(@graphics_context, @last_x.to_i, @last_y.to_i, x, y)
def setupGC()
@graphics_context = Gdk::GC.new(self.window)
@graphics_context.set_rgb_fg_color(Gdk::Color.new( 65535,0,0))
@graphics_context.set_line_attributes(10, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_ROUND)
end
This is not a Ruby issue at all, I just think I'm missing something to do with GTK+ and would appreciate a gentle nudge in the general direction. Hours of searching google to no avail has lead me to posting here.
Thanks to anyone who can help.
I am attempting to write a cross-platform Pictionary style game in Ruby using GTK+.
Using a drawing area and a pixmap, I've managed to get drawing working on the screen. My problems comes when I want to make the size of the line bigger.
I've managed to do it, but, either I'm missing something, or the way I'm drawing is seriously flawed.
My idea was to store the 'old' mouse position, and then draw a line from the old position to the current position when the mouse moves. This works fine when the size is left at the default, but when I increase it, things start going horribly wrong.
First of all, if I move the mouse slowly, the line is drawn exactly like it was before I changed the size, and I can only make it bigger by moving the mouse quicker, and even then, you can see the separate lines that I'm drawing.
http://aycu34.webshots.com/image/33713/2002786654404130434_rs.jpg
The guilty lines of code:
@pixmap.draw_line(@graphics_context, @last_x.to_i, @last_y.to_i, x, y)
def setupGC()
@graphics_context = Gdk::GC.new(self.window)
@graphics_context.set_rgb_fg_color(Gdk::Color.new( 65535,0,0))
@graphics_context.set_line_attributes(10, Gdk::GC::LINE_SOLID, Gdk::GC::CAP_NOT_LAST, Gdk::GC::JOIN_ROUND)
end
This is not a Ruby issue at all, I just think I'm missing something to do with GTK+ and would appreciate a gentle nudge in the general direction. Hours of searching google to no avail has lead me to posting here.
Thanks to anyone who can help.