I am working on a Space Invaders game using C# WinForms and during the gameplay stage I will want the invaders to move down vertically and a bit horizontally towards the bottom of the screen. The issue with having many of these invaders on the screen is the amount of Picture Boxes you have to make of each single one. So say I would have 15 invaders, I would have allocate 15 picture boxes to each individual invader. Is there a way of merging these boxes into a big one or something that will help manage them when handling the gameplay aspects?
Asked
Active
Viewed 82 times
0
-
1You can use just one `PictureBox` to draw everything on it. The animation is done by redrawing, not by moving `PictureBox`es. – Sinatr Oct 26 '17 at 14:04
-
Create a single in-memory bitmap and then render the various game elements onto it, one by one. Then show this single bitmap in a single `PictureBox`. Repeat in every game cycle. As an optimization, you can pre-render multiple visuals that don't change over time onto a single bitmap ahead of time to decrease the number of drawing calls you need in a single cycle. – xxbbcc Oct 26 '17 at 14:20
-
Sooner or later you are going to discover that Graphics.DrawImage() will significantly improve your program. Not just the logic but also its speed. PictureBox is useful in point-and-click GUI design, but nothing else. – Hans Passant Oct 26 '17 at 14:22