Added historic and balance file

This commit is contained in:
Apologieze
2022-04-10 14:33:34 +02:00
parent 902f976e7a
commit 017a92fb03
6 changed files with 118 additions and 35 deletions

BIN
Image/Original/button2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

BIN
Image/crashbutton1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
Image/crashbutton2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -1,9 +1,11 @@
from random import randint import time
import subprocess
import pygame as pg import pygame as pg
from sys import exit from sys import exit
from tkinter import Tk from tkinter import Tk
import ctypes as ct import ctypes as ct
from random import randint from random import randint
import json
DEBUG = True DEBUG = True
FULLSCREEN = False FULLSCREEN = False
@@ -11,6 +13,8 @@ running = False
screen_width, screen_height = Tk().winfo_screenwidth(), Tk().winfo_screenheight() screen_width, screen_height = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
res = (screen_width, screen_height) if FULLSCREEN else (1200, 800) res = (screen_width, screen_height) if FULLSCREEN else (1200, 800)
mid_screen = (res[0] // 2, res[1] // 2) mid_screen = (res[0] // 2, res[1] // 2)
with open('value.json', 'r') as f:
data = json.load(f)
pg.init() pg.init()
pg.mixer.init(channels=1) pg.mixer.init(channels=1)
@@ -32,9 +36,12 @@ def dark_bar():
value = 2 value = 2
value = ct.c_int(value) value = ct.c_int(value)
set_window_attribute(hwnd, rendering_policy, ct.byref(value),ct.sizeof(value)) set_window_attribute(hwnd, rendering_policy, ct.byref(value),ct.sizeof(value))
pg.display.set_mode((1,1)) pg.display.set_mode((res[0]-1,res[1]))
pg.display.set_mode(res, pg.RESIZABLE) pg.display.set_mode(res, pg.RESIZABLE)
if not FULLSCREEN:
dark_bar()
class Game_state(): class Game_state():
def __init__(self,balance=0.0): def __init__(self,balance=0.0):
self.balance = balance self.balance = balance
@@ -297,7 +304,7 @@ class Button():
def retirer(self): def retirer(self):
global live_bet global live_bet
game_state.balance += live_bet change_balance(live_bet)
gui.reset_balance_text() gui.reset_balance_text()
live_bet = 0.0 live_bet = 0.0
gui.cashout = True gui.cashout = True
@@ -344,7 +351,7 @@ class Timer():
self.text_rect = self.text.get_rect(center=self.rect.center) self.text_rect = self.text.get_rect(center=self.rect.center)
def reset(self): def reset(self):
game_state.balance -= initial_bet change_balance(-initial_bet)
gui.reset_balance_text() gui.reset_balance_text()
self.angle = 90 self.angle = 90
@@ -394,20 +401,22 @@ def new_round():
live_bet, initial_bet = 0.0, 0.0 live_bet, initial_bet = 0.0, 0.0
gui.reset_live_bet() gui.reset_live_bet()
def change_balance(n):
game_state.balance += n
with open('value.json', 'w') as json_file:
json.dump({"balance":round(game_state.balance,2)}, json_file)
def rocket_video_reset(h): def rocket_video_reset(h):
hauteur = res[1]-rocket.sprite.rect.bottom hauteur = res[1]-rocket.sprite.rect.bottom
rocket.sprite.rect.bottom = res[1]-hauteur rocket.sprite.rect.bottom = res[1]-hauteur
if not FULLSCREEN:
dark_bar()
"""Création de toutes les instances""" """Création de toutes les instances"""
number_font = pg.font.Font("Font/Poppins2.ttf", 90) number_font = pg.font.Font("Font/Poppins2.ttf", 90)
big_font = pg.font.Font("Font/Poppins2.ttf", 40) big_font = pg.font.Font("Font/Poppins2.ttf", 40)
mid_font = pg.font.Font("Font/Poppins2.ttf", 30) mid_font = pg.font.Font("Font/Poppins2.ttf", 30)
small_font = pg.font.Font("Font/Poppins2.ttf", 20) small_font = pg.font.Font("Font/Poppins2.ttf", 20)
game_state = Game_state(100.0) game_state = Game_state(data["balance"])
rocket = pg.sprite.GroupSingle() rocket = pg.sprite.GroupSingle()
rocket.add(Rocket(game_state)) rocket.add(Rocket(game_state))
@@ -429,13 +438,15 @@ while True:
rocket.sprite.rect.bottom = res[1]-hauteur rocket.sprite.rect.bottom = res[1]-hauteur
# screen = pg.display.set_mode(res, pg.RESIZABLE) # screen = pg.display.set_mode(res, pg.RESIZABLE)
if event.type == pg.QUIT: if event.type == pg.QUIT:
import launcher
pg.quit() pg.quit()
exit() exit()
mou = pg.mouse.get_pressed() mou = pg.mouse.get_pressed()
pos = pg.mouse.get_pos() pos = pg.mouse.get_pos()
screen.fill("#151937") screen.fill((21,25,55))
courbe.update() courbe.update()

View File

@@ -1,38 +1,109 @@
import tkinter as tk import time
import pygame as pg
from sys import exit
from tkinter import Tk
import ctypes as ct import ctypes as ct
import json
import subprocess
root = tk.Tk() DEBUG = True
root.title("Casino") FULLSCREEN = False
root.geometry("500x500") running = False
screen_width, screen_height = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
res = (screen_width, screen_height) if FULLSCREEN else (1200, 800)
mid_screen = (res[0] // 2, res[1] // 2)
with open('value.json', 'r') as f:
data = json.load(f)
w_width = 1000 pg.init()
w_height = 700 pg.display.set_icon(pg.image.load("Image/icon.png"))
screen_width, screen_height = root.winfo_screenwidth(), root.winfo_screenheight() screen = pg.display.set_mode(res, pg.FULLSCREEN) if FULLSCREEN else pg.display.set_mode(res, pg.RESIZABLE)
pg.display.set_caption('Launcher')
clock = pg.time.Clock()
balance = data["balance"]
center_x, center_y = int(screen_width/2 - w_width / 2), int(screen_height/2 - w_height / 2) def dark_bar():
root.geometry(f'{w_width}x{w_height}+{center_x}+{center_y}') """Fonction pour passer la fenêtre en thème sombre"""
root.configure(bg="#36393F")
label = tk.Label(root, text="Hello World")
label.pack()
a = tk.PhotoImage(file = "Image/button.png")
button = tk.Button(root, text="Fermer", borderwidth=0)
button.pack()
tk.Label(image=a).pack()
def dark_bar(window):
window.update()
DWMWA_USE_IMMERSIVE_DARK_MODE = 20 DWMWA_USE_IMMERSIVE_DARK_MODE = 20
set_window_attribute = ct.windll.dwmapi.DwmSetWindowAttribute set_window_attribute = ct.windll.dwmapi.DwmSetWindowAttribute
get_parent = ct.windll.user32.GetParent hwnd = pg.display.get_wm_info()["window"]
hwnd = get_parent(window.winfo_id())
rendering_policy = DWMWA_USE_IMMERSIVE_DARK_MODE rendering_policy = DWMWA_USE_IMMERSIVE_DARK_MODE
value = 2 value = 2
value = ct.c_int(value) value = ct.c_int(value)
set_window_attribute(hwnd, rendering_policy, ct.byref(value),ct.sizeof(value)) set_window_attribute(hwnd, rendering_policy, ct.byref(value),ct.sizeof(value))
root.iconify() pg.display.set_mode((1,1))
root.deiconify() pg.display.set_mode(res, pg.RESIZABLE)
dark_bar(root)
root.mainloop()
if not FULLSCREEN:
dark_bar()
class GameButton():
def __init__(self,image1,image2, id):
self.image_passive = pg.image.load(image1).convert_alpha()
self.image_active = pg.image.load(image2).convert_alpha()
self.image = self.image_passive
self.rect = self.image.get_rect(topleft=(50,50))
self.base_height = self.rect.bottom
self.anim_index = 0
self.id = id
def update(self):
if self.rect.collidepoint(pos):
self.image = self.image_active
if mou[0]:
self.click()
if self.anim_index < 4:
self.anim_index += 1
else:
if self.anim_index != 0:
self.image = self.image_passive
self.anim_index -= 1
self.rect.bottom = self.base_height - self.anim_index
screen.blit(self.image,self.rect)
def click(self):
if self.id == 1:
import crash
class GUI():
def __init__(self):
self.resize()
def resize(self):
self.text_balance = mid_font.render("¥" + str(balance), True, 'white')
self.rect_balance = self.text_balance.get_rect(topright=(res[0] - 50, 5))
self.back_rect = self.rect_balance.copy()
self.back_rect.width += 20
self.back_rect.height += 10
self.back_rect.center = self.rect_balance.center
def update(self):
pg.draw.rect(screen, (20,20,20), self.back_rect, border_radius=11)
screen.blit(self.text_balance, self.rect_balance)
mid_font = pg.font.Font("Font/Poppins2.ttf", 30)
crashbutton = GameButton("Image/crashbutton1.png", "Image/crashbutton2.png", 1)
gui = GUI()
while True:
for event in pg.event.get():
if event.type == pg.VIDEORESIZE:
res = (event.w, event.h)
mid_screen = (res[0] // 2, res[1] // 2)
gui.resize()
if event.type == pg.QUIT:
pg.quit()
exit()
pos = pg.mouse.get_pos()
mou = pg.mouse.get_pressed()
screen.fill((35,35,35))
crashbutton.update()
gui.update()
pg.display.update()
clock.tick(30)

1
value.json Normal file
View File

@@ -0,0 +1 @@
{"balance": 31.55}