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;
- using System.Windows.Forms.VisualStyles;
- namespace kulka_kolos_karna
- {
- public partial class Form1 : Form
- {
- public Random gen = new Random();
- public Pen pioro = new Pen(Color.Black, 8);
- public DateTime start;
- public DateTime stop;
- public kulka kula = new kulka(0,0,40,40);
- public int x = 350;
- public int y = 200;
- public Form1()
- {
- InitializeComponent();
- }
- //gen.Next(0,1000);
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- g.DrawEllipse(pioro, kula.x, kula.y, kula.w, kula.h);
- }
- public class kulka
- {
- public int x, y, h, w;
- public kulka(int sx,int sy, int sh, int sw)
- {
- x = sx;
- y = sy;
- h = sh;
- w = sw;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- x = gen.Next(0, 700);
- y = gen.Next(0, 380);
- kula = new kulka(x,y,40,40);
- start = DateTime.Now;
- panel1.Refresh();
- }
- private void panel1_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.X > kula.x - 10 && e.X < kula.x + 10 && e.Y < kula.y + 10 && e.Y > kula.y - 10)
- {
- kula.h = kula.h / 2;
- kula.w = kula.w / 2;
- kula.x = gen.Next(0, 700);
- kula.y = gen.Next(0, 380);
- panel1.Refresh();
- }
- if (kula.w <= 8 && kula.h <= 8)
- {
- stop = DateTime.Now;
- TimeSpan czas = stop - start;
- MessageBox.Show("Brawo", $"Zajelo ci to : {czas.ToString()}", MessageBoxButtons.OK,
- MessageBoxIcon.Information);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement