forrestcupp
Programmer
- Jul 22, 2006
- 25
I am using c#/.NET with GDI to program my version of the classic snake game where the snake moves around trying not to crash, and everytime it eats something it gets longer.
I started off with just a solid background color:
this.BackColor = Color.SomeColor;
And I got pretty high speeds out of my game. But when I added a background image for a textured background, it slowed it down a lot. I started off by using:
this.BackgroundImage = Image.FromFile("file.jpg");
To try to speed it back up, I tried embedding the image, which didn't do any good. I tried using an uncompressed bmp file instead of a jpg, which didn't help. I tried using a Bitmap instead of an Image. I also tried drawing the image from the OnPaint handler. Using the OnPaint handler did speed things up a little, but not nearly enough. I need the speed, so that at higher levels of the game, I can speed the snake up.
Does anyone know a good way to have a background image without slowing things down, or is this just a major hindrance of .NET and GDI?
I started off with just a solid background color:
this.BackColor = Color.SomeColor;
And I got pretty high speeds out of my game. But when I added a background image for a textured background, it slowed it down a lot. I started off by using:
this.BackgroundImage = Image.FromFile("file.jpg");
To try to speed it back up, I tried embedding the image, which didn't do any good. I tried using an uncompressed bmp file instead of a jpg, which didn't help. I tried using a Bitmap instead of an Image. I also tried drawing the image from the OnPaint handler. Using the OnPaint handler did speed things up a little, but not nearly enough. I need the speed, so that at higher levels of the game, I can speed the snake up.
Does anyone know a good way to have a background image without slowing things down, or is this just a major hindrance of .NET and GDI?