Advertisement
Skylighty

Untitled

Jun 12th, 2019
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace prusi2
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public DateTime start;
  16.         public DateTime stop;
  17.         public Random rand = new Random();
  18.         public kulka k = new kulka(350,200,20,20);
  19.         public Pen pioro = new Pen(Color.Black, 5);
  20.         public int points = 0;
  21.         public Form1()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void panel1_Paint(object sender, PaintEventArgs e)
  27.         {
  28.             Graphics g = e.Graphics;
  29.             g.DrawEllipse(pioro, k.x, k.y, k.w, k.h);
  30.         }
  31.  
  32.         private void timer1_Tick(object sender, EventArgs e)
  33.         {
  34.             k = new kulka(rand.Next(0,700),rand.Next(0,380),40,40);
  35.             panel1.Refresh();
  36.         }
  37.  
  38.         public class kulka
  39.         {
  40.             public int x, y, w, h;
  41.  
  42.             public kulka(int sx, int sy, int sw, int sh)
  43.             {
  44.                 x = sx;
  45.                 y = sy;
  46.                 w = sw;
  47.                 h = sh;
  48.             }
  49.         }
  50.  
  51.         private void panel1_MouseDown(object sender, MouseEventArgs e)
  52.         {
  53.             if (e.X > k.x && e.X < k.x + 40 && e.Y > k.y && e.Y < k.y + 40)
  54.             {
  55.                 points++;
  56.                 toolStripStatusLabel1.Text = $"Zebrałeś {points.ToString()} punktów";
  57.                 k = new kulka(rand.Next(0, 700), rand.Next(0, 380), 40, 40);
  58.                 panel1.Refresh();
  59.             }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement