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.Windows.Forms;
- namespace Bilijar
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void btnPocetak_Click(object sender, EventArgs e)
- {
- timer1.Stop();
- pictureBoxKugla.Image = Properties.Resources.bilijar_stop;
- int sirina = panelMartinela.Width;
- int visina = panelMartinela.Height;
- int cx = sirina / 5;
- int cy = visina / 2;
- pictureBoxKugla.Left = cx - pictureBoxKugla.Width / 2;
- pictureBoxKugla.Top = cy - pictureBoxKugla.Height / 2;
- }
- private void pictureBoxKugla_Click(object sender, EventArgs e)
- {
- timer1.Start();
- pictureBoxKugla.Image = Properties.Resources.bilijar_desno;
- korakX = 10;
- korakY = 0;
- }
- int korakX, korakY;
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (pictureBoxKugla.Left + pictureBoxKugla.Width + korakX > panelMartinela.Width)
- korakX *= -1;
- else if (pictureBoxKugla.Left + korakX < 0)
- korakX *= -1;
- pictureBoxKugla.Left += korakX;
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- int jacina = (int)numericUpDown1.Value;
- timer1.Interval = 200 / jacina;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement