- [VB.NET] Hướng dẫn giải captcha sử dụng dịch vụ AZCaptcha API trên winform
- [C#] Hướng dẫn chứng thực đăng nhập ứng dụng bằng vân tay (Finger Print) trên máy tính
- [C#] Color Thief cách xuất màu sắc thiết kế từ hình ảnh
- [C#] Cách tạo bản quyền và cho phép dùng thử ứng dụng Winform
- [C#] Hướng dẫn sử dụng trình duyệt web Chrome convert HTML sang tập tin file PDF
- [C#] Kết nôi điện thoại Android, IOS với App Winform via Bluetooth
- [DATABASE] Cách query cộng trừ dồn dần trong Sqlserver
- [C#] Thiết kế ứng dụng Console đẹp với thư viện Spectre.Console
- [C#] Thiết kế ứng dụng Single Instance và đưa ứng dụng lên trước nếu kiểm tra ứng dụng đang chạy
- [C#] Giới thiệu JSON Web Token và cách đọc chuỗi token
- [C#] Cách tăng giảm font chữ tất cả các control trên winform
- [DEVEXPRESS] Tích hợp chức năng Tìm kiếm Search vào CheckedComboboxEdit
- [C#] Gởi email Metting Calendar Reminder kèm nhắc thời gian lịch họp
- [C#] Tìm kiếm xem danh sách từ khóa có tồn tại trong đoạn văn bản hay không
- [C#] Thiết kế giao diện ứng dụng trên Console sử dụng thư viện Terminal.Gui
- [C#] Hướng dẫn tạo mã VietQR Payment API Winform
- [C#] Sử dụng thư viện BenchmarkDotNet đo hiệu năng của hảm Method
- [DEVEXPRESS] Tìm kiếm không dấu tô màu highlight có dấu trên C# Winform
- [C#] Chia sẻ source code tạo hiệu ứng pixel Image trên winform
- [C#] Hướng dẫn kiểm tra số Container hợp lệ hay không
[C#] Chia sẻ source code Game Spin Lucky Wheel
Xin chào các bạn, hôm nay mình tiếp tục chia sẻ đến các bạn source code Game Spin Lucky Wheel trên C#, Winform.
[C#] Source code Game Spin Lucky Wheel Winform
Đây là một giới thiệu ngắn về trò chơi Lucky Wheel:
Lucky Wheel là một trò chơi may mắn truyền thống mà bao gồm việc xoay một bánh xe với nhiều lựa chọn giải thưởng.
Người chơi có thể đặt cược vào nơi họ nghĩ rằng bánh sẽ dừng lại, và nếu dự đoán của họ đúng, họ có thể nhận được giải thưởng.
Trò chơi thường được chơi tại các hội chợ, hội chợ và trong các sòng bạc, và nó có thể được chuyển tải cho việc sử dụng trong nhiều môi trường khác nhau.
Lucky Wheel là một trò chơi đơn giản và vui nhộn mà được người ta trên mọi độ tuổi yêu thích.
Giao diện demo ứng dụng:
Video demo ứng dụng:
Source code C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DrawLuckyWheel
{
public partial class Form1 : Form
{
bool wheelIsMoved;
float wheelTimes;
Timer wheelTimer;
LuckyCirlce koloFortuny;
public Form1()
{
InitializeComponent();
wheelTimer = new Timer();
wheelTimer.Interval = 30; // speed
wheelTimer.Tick += wheelTimer_Tick;
koloFortuny = new LuckyCirlce();
}
public class LuckyCirlce
{
public Bitmap obrazek;
public Bitmap tempObrazek;
public float kat;
public int[] wartosciStanu;
public int stan;
public LuckyCirlce()
{
tempObrazek = new Bitmap(Properties.Resources.lucky_wheel);
obrazek = new Bitmap(Properties.Resources.lucky_wheel);
wartosciStanu = new int[] { 12, 11, 10 ,09, 08, 07, 06, 05, 04, 03, 02, 01};
kat = 0.0f;
}
}
public static Bitmap RotateImage(Image image, float angle)
{
return RotateImage(image, new PointF((float)image.Width / 2, (float)image.Height / 2), angle);
}
public static Bitmap RotateImage(Image image, PointF offset, float angle)
{
if (image == null)
throw new ArgumentNullException("image");
Bitmap rotatedBmp = new Bitmap(image.Width, image.Height);
rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
Graphics g = Graphics.FromImage(rotatedBmp);
g.TranslateTransform(offset.X, offset.Y);
g.RotateTransform(angle);
g.TranslateTransform(-offset.X, -offset.Y);
g.DrawImage(image, new PointF(0, 0));
return rotatedBmp;
}
private void RotateImage(PictureBox pb, Image img, float angle)
{
if (img == null || pb.Image == null)
return;
Image oldImage = pb.Image;
pb.Image = RotateImage(img, angle);
if (oldImage != null)
{
oldImage.Dispose();
}
}
private void wheelTimer_Tick(object sender, EventArgs e)
{
if (wheelIsMoved && wheelTimes > 0)
{
koloFortuny.kat += wheelTimes / 10;
koloFortuny.kat = koloFortuny.kat % 360;
RotateImage(pictureBox1, koloFortuny.obrazek, koloFortuny.kat);
wheelTimes--;
}
koloFortuny.stan = Convert.ToInt32(Math.Ceiling(koloFortuny.kat / 30));
if (koloFortuny.stan == 0)
{
koloFortuny.stan = 0;
}
else
{
koloFortuny.stan -= 1;
}
label1.Text = Convert.ToString(koloFortuny.wartosciStanu[koloFortuny.stan]);
}
private void btnPlay_Click(object sender, EventArgs e)
{
wheelIsMoved = true;
Random rand = new Random();
wheelTimes = rand.Next(150, 200); //random số vòng quay
wheelTimer.Start();
}
}
}
Thanks for watching!