[Gtk-sharp-list] howto draw a line

Kees Jongenburger keesj@dds.nl
12 Jul 2002 08:14:00 +0200


Hi, 

I am very very new to c# and gtksharp. I am having great time 
but it's very difficult to known where error lies, is it my programming 
is it mono? is it gtksharp? anyway I am trying to write a little game
using gtksharp/c# (Pong). 

I am stucked because I can't find a way to draw lines on the screen 
I have tried different approaches.
-1 tried to create an DrawingArea and using the Expose event. but I
can't find any method to draw on it :(

public void expose(object obj, EventArgs args){
	if (args is SignalArgs){
             SignalArgs signalArgs = (SignalArgs)args;
             signalArgs.RetVal = true;
        }
        if (obj is Pong){
            Pong thePong = (Pong)obj;
            Gdk.Window w = ParentWindow;
        }
}
one other "problem" is that I can't write the 
ExposeEvent += new EventHandler(pong.expose); in the Pong constructor

I have to do something like this:

Pong pong = new Pong();
pong.ExposeEvent += new EventHandler(pong.expose);

-2 using a Gtk.image by loading it from disk and then changing the image

Gtk.Image image= new Gtk.Image();
image.Pixbuf = new Gdk.Pixbuf("pong.xpm");
Gdk.Image img = image.ImageProp;
for (int x =0 ; x < 640;x++){
      for (int y =0 ; y < 200;y++){
               img.PutPixel(0,0,1);
      }
}
but that gives
(<unknown>:3170): Gdk-CRITICAL **: file gdkimage-x11.c: line 676
(gdk_image_put_pixel): assertion `GDK_IS_IMAGE (image)' failed

Do you think it is now possible to create a little multi-user game?
I can think of a other possibility 
-loading a background
-loading the two pong bats and placing them on the background
-moving the ball around
is that possible?

any help is welcome :)

bye and thanks