- [DEVEXPRESS] Chia sẻ code các tạo report in nhiều hóa đơn trên XtraReport C#
- [POWER AUTOMATE] Hướng dẫn gởi tin nhắn zalo từ file Excel - No code
- [C#] Chia sẻ code lock và unlock user trong domain Window
- [SOFTWARE] Giới thiệu bộ phần mềm tính Kết Cấu Thép HatteSale, Mộng Đơn, Dầm, Sàn, Móng Cọc, Vách, Xà Gồ, Tính Tải Trọng
- [DEVEXPRESS] Vẽ Biểu Đồ Stock Chứng Khoán - Công Cụ Thiết Yếu Cho Nhà Đầu Tư trên Winform
- [C#] Hướng dẫn bảo mật ứng dụng 2FA (Multi-factor Authentication) trên Winform
- [C#] Hướng dẫn convert HTML code sang PDF File trên NetCore 7 Winform
- [C#] Hướng dẫn viết ứng dụng chat với Gemini AI Google Winform
- Hướng dẫn khóa file bằng nhiều process id, không cho xóa tập tin
- Hướng dẫn cách tạo Product Id cho ứng dụng phần mềm XXXXX-XXXXX-XXXXX-XXXXX
- [SQLSERVER] Hướng dẫn tạo script sql từ ứng dụng Sqlserver management Studio
- [C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform
- [VB.NET] Hướng dẫn lấy thông tin tài khoản đăng nhập windows và khởi động lại ứng dụng ở chế độ Administrator
- [C#] Sử dụng thư viện Polly gửi lại request api khi request bị lỗi hay rớt mạng
- [DEVEXPRESS] Chia sẻ source code tạo báo cáo report in tem nhãn label trên C# winform
- [DEVEXPRESS] Hướng dẫn vẽ biểu đồ Bar Chart trên Winform
- [C#] Tạo form đăng nhập và đăng ký với hiệu ứng Sliding Animation Effect
- [C#] Hướng dẫn tạo thanh toán đơn hàng qua mã vạch VietQR sử dụng API PayOS hoàn toàn miễn phí
- [C#] Hướng dẫn ghi log ra RichTextBox giống Console trên Winform sử dụng thư viện Serilog
- [C#] Hướng dẫn cách tạo mã QR Code trên file Excel
[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!