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 Racetrack_Game_SRC
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public bool Bet_Made = false;
- public bool Winner = false;
- public int Result1;
- public int Score = 50;
- private void button2_Click(object sender, EventArgs e)
- {
- System.Random R1 = new System.Random();
- int Result;
- Result = R1.Next(4);
- if(Bet_Made==false){
- MessageBox.Show("Please place your bet first!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- }
- if (Bet_Made == true)
- {
- Bet_Made = false;
- if(Result==Result1)
- {
- Winner = true;
- MessageBox.Show("You Win!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Information);
- timer1.Enabled = true;
- Score++;
- Score++;
- Score++;
- Score++;
- Score++;
- numericUpDown2.Value = Score;
- }
- else
- {
- MessageBox.Show("You Lose!!","Race Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
- Score--;
- numericUpDown2.Value = Score;
- if (Result == 0 && Winner==true)
- {
- MessageBox.Show("Horse #1 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- if (Result == 1 && Winner == true)
- {
- MessageBox.Show("Horse #2 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- if (Result == 2 && Winner == true)
- {
- MessageBox.Show("Horse #3 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- if (Result == 3 && Winner == true)
- {
- MessageBox.Show("Horse #4 Won!!","Race Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (Bet_Made ==true)
- {
- MessageBox.Show("Bet Has Been Placed!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (Score > 0)
- {
- Bet_Made = true;
- Score--;
- numericUpDown2.Value = Score;
- MessageBox.Show("Bet Has Been Placed!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("Game Over!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- Application.Exit();
- }
- }
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- Result1 = 0;
- }
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- Result1 = 1;
- }
- private void radioButton3_CheckedChanged(object sender, EventArgs e)
- {
- Result1 = 2;
- }
- private void radioButton4_CheckedChanged(object sender, EventArgs e)
- {
- Result1 = 3;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- numericUpDown2.Value = Score;
- if (pictureBox1.Location.X>334)
- {
- timer1.Enabled = false;
- pictureBox1.Location = new System.Drawing.Point(0, 8);
- MessageBox.Show("Score: "+Score.ToString(), "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
- numericUpDown2.Value = Score;
- }
- pictureBox1.Location = new System.Drawing.Point(pictureBox1.Location.X+5,pictureBox1.Location.Y);
- }
- private void groupBox2_Enter(object sender, EventArgs e)
- {
- }
- private void Form1_MouseMove(object sender, MouseEventArgs e)
- {
- if (Score < 0)
- {
- MessageBox.Show("Sorry You Are Out Of Money!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Error);
- Application.Exit();
- }
- }
- private void numericUpDown2_Click(object sender, EventArgs e)
- {
- numericUpDown2.Value = Score;
- MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
- numericUpDown2.Value = Score;
- }
- private void numericUpDown2_MouseDown(object sender, MouseEventArgs e)
- {
- }
- private void numericUpDown2_KeyDown(object sender, KeyEventArgs e)
- {
- numericUpDown2.Value = Score;
- MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!","Race Track Game SRC",MessageBoxButtons.OK,MessageBoxIcon.Stop);
- numericUpDown2.Value = Score;
- }
- private void numericUpDown2_KeyPress(object sender, KeyPressEventArgs e)
- {
- numericUpDown2.Value = Score;
- MessageBox.Show("Sorry can't add or remove to/from score like this nice try!!", "Race Track Game SRC", MessageBoxButtons.OK, MessageBoxIcon.Stop);
- numericUpDown2.Value = Score;
- }
- private void timer2_Tick(object sender, EventArgs e)
- {
- numericUpDown2.Value = Score;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment