Advertisement
Guest User

pusi kurac

a guest
Mar 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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.Windows.Forms;
  9.  
  10. namespace Bilijar
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19. private void btnPocetak_Click(object sender, EventArgs e)
  20. {
  21. timer1.Stop();
  22.  
  23. pictureBoxKugla.Image = Properties.Resources.bilijar_stop;
  24.  
  25. int sirina = panelMartinela.Width;
  26. int visina = panelMartinela.Height;
  27.  
  28. int cx = sirina / 5;
  29. int cy = visina / 2;
  30.  
  31. pictureBoxKugla.Left = cx - pictureBoxKugla.Width / 2;
  32. pictureBoxKugla.Top = cy - pictureBoxKugla.Height / 2;
  33. }
  34.  
  35. private void pictureBoxKugla_Click(object sender, EventArgs e)
  36. {
  37. timer1.Start();
  38. pictureBoxKugla.Image = Properties.Resources.bilijar_desno;
  39. korakX = 10;
  40. korakY = 0;
  41. }
  42.  
  43. int korakX, korakY;
  44.  
  45. private void timer1_Tick(object sender, EventArgs e)
  46. {
  47. if (pictureBoxKugla.Left + pictureBoxKugla.Width + korakX > panelMartinela.Width)
  48. korakX *= -1;
  49. else if (pictureBoxKugla.Left + korakX < 0)
  50. korakX *= -1;
  51. pictureBoxKugla.Left += korakX;
  52. }
  53.  
  54. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  55. {
  56. int jacina = (int)numericUpDown1.Value;
  57. timer1.Interval = 200 / jacina;
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement