Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace LaBall
- {
- public partial class Form1 : Form
- {
- private int x = 0;
- private int speed = 1;
- private int hit = 0;
- private int yball;
- private int xball;
- private int size = 25;
- public Form1()
- {
- InitializeComponent();
- timer1.Interval = 10;
- timer1.Start();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- x += speed;
- if (x > Size.Width) x = 0;
- SolidBrush pen = new SolidBrush(Color.Red);
- Graphics g = pictureBox1.CreateGraphics();
- Bitmap b = new Bitmap(Properties.Resources.Wasser, Size);
- g.DrawImage(b, 0, 0);
- Rectangle ball = new Rectangle(x, 100, size, size);
- g.FillEllipse(pen, ball);
- g.Dispose();
- }
- /* private void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == '+')
- {
- speed++;
- }
- if (e.KeyChar == '-')
- {
- speed--;
- }
- if (speed > 30) speed = 30;
- if (speed < 0) speed = 0;
- } */
- private void Form1_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == 'g')
- {
- size++; // Ball soll größer werden
- }
- if (e.KeyChar == 'k')
- {
- size--; // Ball soll kleiner werden
- }
- if (size > 50) size = 50;
- if (size < 10) size = 10;
- }
- private void pictureBox1_MouseDown_1(object sender, MouseEventArgs e)
- {
- // if (e.X <= xball + 25 && e.X >= xball - 25 && e.Y <= yball + 25 && e.Y >= yball - 25) //Prüft im durchmesser 25 pixel ob mausklick in der GraPHik ist.
- if (e.X < xball + size && e.X > xball && e.Y < yball + size && e.Y > yball)
- {
- hit++;
- lbl1_hit.Text = Convert.ToString(hit);
- }
- }
- private void lbl1_hit_Click(object sender, EventArgs e)
- {
- lbl1_hit.Parent = pictureBox1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement