BrU32

C# Horse Race Game SRC

Sep 12th, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 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 Racetrack_Game_SRC
  12. {
  13.  
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20. public bool Bet_Made = false;
  21. public bool Winner = false;
  22. public int Result1;
  23. public int Score = 50;
  24. private void button2_Click(object sender, EventArgs e)
  25. {
  26. System.Random R1 = new System.Random();
  27. int Result;
  28. Result = R1.Next(4);
  29. if(Bet_Made==false){
  30. MessageBox.Show("Please place your bet first!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
  31. }
  32. if (Bet_Made == true)
  33.  
  34. {
  35. Bet_Made = false;
  36. if(Result==Result1)
  37. {
  38. Winner = true;
  39. MessageBox.Show("You Win!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Information);
  40. timer1.Enabled = true;
  41. Score++;
  42. Score++;
  43. Score++;
  44. Score++;
  45. Score++;
  46. numericUpDown2.Value = Score;
  47. }
  48. else
  49. {
  50. MessageBox.Show("You Lose!!","Race Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
  51. Score--;
  52. numericUpDown2.Value = Score;
  53.  
  54. if (Result == 0 && Winner==true)
  55. {
  56. MessageBox.Show("Horse #1 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  57. }
  58. if (Result == 1 && Winner == true)
  59. {
  60. MessageBox.Show("Horse #2 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  61. }
  62. if (Result == 2 && Winner == true)
  63. {
  64. MessageBox.Show("Horse #3 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  65. }
  66. if (Result == 3 && Winner == true)
  67. {
  68. MessageBox.Show("Horse #4 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  69. }
  70. }
  71. }
  72. }
  73. private void button1_Click(object sender, EventArgs e)
  74. {
  75. if (Bet_Made ==true)
  76. {
  77. MessageBox.Show("Bet Has Been Placed!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Information);
  78. return;
  79. }
  80. if (Score > 0)
  81. {
  82. Bet_Made = true;
  83. Score--;
  84. numericUpDown2.Value = Score;
  85. MessageBox.Show("Bet Has Been Placed!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Information);
  86. }
  87. else
  88. {
  89. MessageBox.Show("Game Over!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
  90. Application.Exit();
  91. }
  92. }
  93.  
  94. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  95. {
  96. Result1 = 0;
  97. }
  98.  
  99. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  100. {
  101. Result1 = 1;
  102. }
  103.  
  104. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  105. {
  106. Result1 = 2;
  107. }
  108.  
  109. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  110. {
  111. Result1 = 3;
  112. }
  113.  
  114. private void Form1_Load(object sender, EventArgs e)
  115. {
  116.  
  117. }
  118.  
  119. private void timer1_Tick(object sender, EventArgs e)
  120. {
  121. numericUpDown2.Value = Score;
  122. if (pictureBox1.Location.X>334)
  123. {
  124. timer1.Enabled = false;
  125. pictureBox1.Location = new System.Drawing.Point(0, 8);
  126. MessageBox.Show("Score: "+Score.ToString(), "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  127. numericUpDown2.Value = Score;
  128. }
  129. pictureBox1.Location = new System.Drawing.Point(pictureBox1.Location.X+5,pictureBox1.Location.Y);
  130. }
  131.  
  132. private void groupBox2_Enter(object sender, EventArgs e)
  133. {
  134.  
  135. }
  136.  
  137. private void Form1_MouseMove(object sender, MouseEventArgs e)
  138. {
  139. if (Score < 0)
  140. {
  141. MessageBox.Show("Sorry You Are Out Of Money!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Error);
  142. Application.Exit();
  143. }
  144. }
  145.  
  146. private void numericUpDown2_Click(object sender, EventArgs e)
  147. {
  148. numericUpDown2.Value = Score;
  149. MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  150. numericUpDown2.Value = Score;
  151. }
  152.  
  153. private void numericUpDown2_MouseDown(object sender, MouseEventArgs e)
  154. {
  155.  
  156. }
  157.  
  158. private void numericUpDown2_KeyDown(object sender, KeyEventArgs e)
  159. {
  160. numericUpDown2.Value = Score;
  161. MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
  162. numericUpDown2.Value = Score;
  163. }
  164.  
  165. private void numericUpDown2_KeyPress(object sender, KeyPressEventArgs e)
  166. {
  167. numericUpDown2.Value = Score;
  168. MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  169. numericUpDown2.Value = Score;
  170. }
  171.  
  172. private void timer2_Tick(object sender, EventArgs e)
  173. {
  174. numericUpDown2.Value = Score;
  175. }
  176. }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment