import tkinter as tk
from tkinter import messagebox
import random
class MinesGameApp:
def __init__(self, root):
self.root = root
self.root.title("Mines Game - RXWin Style")
self.root.configure(bg="#121212")
self.grid_size = 5
self.mines_count = 5
self.bet_amount = 10
self.revealed_tiles = 0
self.balance = 1000
self.currency = "USD"
self.buttons = []
self.mines_positions = set()
self.setup_ui()
def setup_ui(self):
tk.Label(self.root, text="Mines Game", font=("Helvetica", 18), fg="white",
bg="#121212").pack(pady=10)
tk.Label(self.root, text="Number of Mines:", fg="white",
bg="#121212").pack()
self.mines_input = tk.Entry(self.root)
self.mines_input.pack()
self.mines_input.insert(0, str(self.mines_count))
tk.Label(self.root, text="Bet Amount:", fg="white", bg="#121212").pack()
self.bet_input = tk.Entry(self.root)
self.bet_input.pack()
self.bet_input.insert(0, str(self.bet_amount))
tk.Label(self.root, text="Currency:", fg="white", bg="#121212").pack()
self.currency_var = tk.StringVar(value=self.currency)
self.currency_menu = tk.OptionMenu(self.root, self.currency_var, "USD",
"EUR", "BTC", "ETH")
self.currency_menu.pack()
self.balance_label = tk.Label(self.root, text=f"Balance: {self.balance}
{self.currency}", fg="white", bg="#121212")
self.balance_label.pack()
tk.Button(self.root, text="Start Game", command=self.start_game,
bg="#4caf50", fg="white").pack(pady=10)
self.grid_frame = tk.Frame(self.root, bg="#121212")
self.grid_frame.pack()
self.cashout_button = tk.Button(self.root, text="Cashout",
command=self.cashout, bg="#ff9800", fg="white", font=("Helvetica", 14))
self.cashout_button.pack(pady=10)
self.cashout_button.config(state="disabled")
def start_game(self):
self.mines_count = int(self.mines_input.get())
self.bet_amount = int(self.bet_input.get())
self.currency = self.currency_var.get()
if self.bet_amount > self.balance:
messagebox.showerror("Error", "Bet amount exceeds balance!")
return
self.balance -= self.bet_amount
self.update_balance_label()
self.revealed_tiles = 0
self.mines_positions = set(random.sample(range(self.grid_size ** 2),
self.mines_count))
for widget in self.grid_frame.winfo_children():
widget.destroy()
self.buttons = []
for row in range(self.grid_size):
button_row = []
for col in range(self.grid_size):
btn = tk.Button(self.grid_frame, text="", width=5, height=2,
bg="#1e1e1e", fg="white", font=("Helvetica", 14),
command=lambda r=row, c=col: self.reveal_tile(r,
c))
btn.grid(row=row, column=col, padx=2, pady=2)
button_row.append(btn)
self.buttons.append(button_row)
self.cashout_button.config(state="normal")
def reveal_tile(self, row, col):
index = row * self.grid_size + col
if index in self.mines_positions:
self.buttons[row][col].config(bg="red", text="💣") # Bomb emoji
self.game_over(False)
else:
self.buttons[row][col].config(bg="#4caf50", text="💎") # Diamond emoji
self.buttons[row][col].config(state="disabled")
self.revealed_tiles += 1
if self.revealed_tiles == (self.grid_size ** 2 - self.mines_count):
self.game_over(True)
def cashout(self):
winnings = self.revealed_tiles * self.bet_amount # Example payout logic
self.balance += winnings
self.update_balance_label()
messagebox.showinfo("Cashout", f"You cashed out with {winnings}
{self.currency}!")
self.cashout_button.config(state="disabled")
def game_over(self, won):
if won:
messagebox.showinfo("Game Over", "You won!")
else:
messagebox.showerror("Game Over", "You hit a mine!")
self.cashout_button.config(state="disabled")
def update_balance_label(self):
self.balance_label.config(text=f"Balance: {self.balance} {self.currency}")
if __name__ == "__main__":
root = tk.Tk()
app = MinesGameApp(root)
root.mainloop()