Answer the question
In order to leave comments, you need to log in
C#. Which is better: PictureBox or Paint?
In general, I'm making a game in WF where you need to pop the balls rising up. What is better for this: a PictureBox, when clicked with the mouse button, I will teleport it down so that it rises again, or Paint, when clicking on the picture of which a redraw will be performed? And all this on the condition that I need to organize randomly: an arbitrary number of balls will rise, and some will be ahead of others.
PS
Working with Paint in such a game is almost unrealistic. But still, maybe you know how to implement it?
Answer the question
In order to leave comments, you need to log in
I believe that you should first try to display the balls with an image, and if for some reason the pictures did not load, then draw them.
1. Create a variable with an image
2. When initializing the form with the game, we try to load an image into this variable
try
{
ImageBall = new Bitmap("путь до изображения");
}
catch (Exception ex)
{
MessageBox.Show(@"Не удалось загрузить: " + ex.Message, @"Ошибка при загрузке изображений!");
}
Bitmap bmp = new Bitmap(50,50);
Graphics gr = Graphics.FromImage(bmp); // это пространство на котором рисуется игра
Rectangle rect = new Rectangle(0,0,50,50); // размер шарика
if(ImageBall == null) // если картинка не загрузилась
{
gr.DrawEllipse(new Pen(Color.Black), rect); // рисуем круг
}
else
{
gr.DrawImage(ImageBalls, rect);
}
pictureBox1.Image = bmp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question