Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace prusi2
- {
- public partial class Form1 : Form
- {
- public DateTime start;
- public DateTime stop;
- public Random rand = new Random();
- public kulka k = new kulka(350,200,20,20);
- public Pen pioro = new Pen(Color.Black, 5);
- public int points = 0;
- public Form1()
- {
- InitializeComponent();
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- g.DrawEllipse(pioro, k.x, k.y, k.w, k.h);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- k = new kulka(rand.Next(0,700),rand.Next(0,380),40,40);
- panel1.Refresh();
- }
- public class kulka
- {
- public int x, y, w, h;
- public kulka(int sx, int sy, int sw, int sh)
- {
- x = sx;
- y = sy;
- w = sw;
- h = sh;
- }
- }
- private void panel1_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.X > k.x && e.X < k.x + 40 && e.Y > k.y && e.Y < k.y + 40)
- {
- points++;
- toolStripStatusLabel1.Text = $"Zebrałeś {points.ToString()} punktów";
- k = new kulka(rand.Next(0, 700), rand.Next(0, 380), 40, 40);
- panel1.Refresh();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement