//Draws an arbitrary space object to the drawing pane. // Note: Won't work for doors. private void drawSpaceObject(SpaceObject obj, PaintEventArgs e) { Image img = Image.FromFile(currdir + "\\" + obj.TextureName + ".png"); //In order to do rotations and scaling in windows forms, we need to determine where // the upper right, upper left, and lower left corners map to. We determine these, and // tell the graphics to draw the image. //Find the new point for the upper-left corner DrawPoint upper_left = Conversion.Vector2ToDrawPoint(obj.mapPointOnImage(0, 0)); //Find the new point for the upper-right corner float x_ur = obj.getOriginalWidth(); float y_ur = 0; DrawPoint upper_right = Conversion.Vector2ToDrawPoint( obj.mapPointOnImage(x_ur, y_ur)); //Find the new point for the lower-left corner float x_ll = 0; float y_ll = obj.getOriginalHeight(); DrawPoint lower_left = Conversion.Vector2ToDrawPoint(obj.mapPointOnImage(x_ll, y_ll)); //Define the point mapping. DrawPoint[] destmapping = {upper_left, upper_right, lower_left}; DrawRect srcrect = new DrawRect(0,0,img.Width / obj.NumberOfFrames,img.Height); //Draw the image with the specified position and scaling. e.Graphics.DrawImage(img, destmapping, srcrect, GraphicsUnit.Pixel); }