Hello, this is My first time posting here. I'm making a 2 dimensional side scrolling game. What i'm doing is making a level editor, and i need a class that represents each type of block for instance: "Dirt" I need a class called dirt(which i have). Inside that class is a function called Run. with the code:
But for some reason it just doesn't work. I know that it's actually calling the function, and getting through it, because I tried putting Application.Exit(); at the end of G.FillRectangle(DrawTexture, DirtBlock); and it closes the program when i call the function(which is what i want). So i have no idea why it doesn't draw. If you know why please tell me. Thanks
public void run(int Xint, int Yint, PictureBox Drawspace, Bitmap Texture) { Rectangle DirtBlock = new Rectangle(0, 0, 0, 0); Graphics G; Bitmap MyTexture = Texture; DirtBlock.X = Xint; DirtBlock.Y = Yint; DirtBlock.Height = 50; DirtBlock.Width = 50; G = Drawspace.CreateGraphics(); G.DrawRectangle(Pens.Black, DirtBlock); TextureBrush DrawTexture = new TextureBrush(MyTexture); G.FillRectangle(DrawTexture, DirtBlock); }Now everything works just fine, except it won't actually draw the graphics. What i'm trying to do is call the function, and then in the function it will draw graphics on the main form which is where the function is originally being called from.
But for some reason it just doesn't work. I know that it's actually calling the function, and getting through it, because I tried putting Application.Exit(); at the end of G.FillRectangle(DrawTexture, DirtBlock); and it closes the program when i call the function(which is what i want). So i have no idea why it doesn't draw. If you know why please tell me. Thanks
Last edited by a moderator: