using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Lucky_7
{
public partial class frmRoulette : Form
{
private int speed;
// This piece of code is responsible for creating private int speed
public frmRoulette()
{
InitializeComponent();
}
private void btnPlay_Click(object sender, EventArgs e)
{
int[] x = { 183, 201, 217, 235, 252, 266, 278, 287, 293, 295, 294, 293, 288, 276, 264, 248, 232, 213, 195, 176, 157, 139, 123, 108, 94, 89, 82, 77, 76, 74, 81, 88, 100, 115, 129, 147, 163 };
int[] y = { 68, 68, 75, 80, 88, 100, 112, 127, 146, 162, 180, 197, 211, 226, 241, 251, 259, 262, 267, 269, 267, 260, 251, 240, 229, 212, 199, 182, 166, 147, 133, 116, 102, 87, 80, 74, 69 };
int speed = 30;
int pos = int.Parse(txtPos.Text);
//This line of code converts the string representation of a number to its 32-bit signed integer equivalent
picBall.Location = new Point(x[pos], y[pos]);
// This piece of code is reponsible for creating feature that will check if coordinates are correct
}
Random rnd = new Random(36);
//Generates random seed of numbers between 0-36
private void btnRoll_Click(object sender, EventArgs e)
{
int[] x = { 183, 201, 217, 235, 252, 266, 278, 287, 293, 295, 294, 293, 288, 276, 264, 248, 232, 213, 195, 176, 157, 139, 123, 108, 94, 89, 82, 77, 76, 74, 81, 88, 100, 115, 129, 147, 163 };
int[] y = { 68, 68, 75, 80, 88, 100, 112, 127, 146, 162, 180, 197, 211, 226, 241, 251, 259, 262, 267, 269, 267, 260, 251, 240, 229, 212, 199, 182, 166, 147, 133, 116, 102, 87, 80, 74, 69 };
// These are the coordinates which are essential to make the ball go around the circle
int stop = rnd.Next(1, 36);
// This short piece of code generates random number generator between 1-36
for (int loopCount = 0; loopCount < 5; loopCount++)
// This is responsible for creating a loop so ball will go around exactly five times
{
for (int i = 0; i < x.Length; i++)
// This short piece of code represents the total numbers of elements in all the dimensions of the array
{
picBall.Location = new Point(x[i], y[i]);
this.Refresh();
int speed = 30;
Thread.Sleep(speed);
speed = speed + 250;
// this piece of code is responsible for speed of the ball so every lap ball will go faster
if (i == stop && loopCount == 4)
{
break;
}
// This piece of code is responsible for stopping a ball at random position
}
}
}
private void picBall_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
برچسب:
نویسنده: آیلین رضوانی