mirror of
https://github.com/Apologieze/Monkeycrash.git
synced 2026-03-18 21:30:28 +01:00
Added historic and balance file
This commit is contained in:
BIN
Image/Original/button2.png
Normal file
BIN
Image/Original/button2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 174 KiB |
BIN
Image/crashbutton1.png
Normal file
BIN
Image/crashbutton1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
Image/crashbutton2.png
Normal file
BIN
Image/crashbutton2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
29
crash.py
29
crash.py
@@ -1,9 +1,11 @@
|
||||
from random import randint
|
||||
import time
|
||||
import subprocess
|
||||
import pygame as pg
|
||||
from sys import exit
|
||||
from tkinter import Tk
|
||||
import ctypes as ct
|
||||
from random import randint
|
||||
import json
|
||||
|
||||
DEBUG = True
|
||||
FULLSCREEN = False
|
||||
@@ -11,6 +13,8 @@ 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)
|
||||
|
||||
pg.init()
|
||||
pg.mixer.init(channels=1)
|
||||
@@ -32,9 +36,12 @@ def dark_bar():
|
||||
value = 2
|
||||
value = ct.c_int(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)
|
||||
|
||||
if not FULLSCREEN:
|
||||
dark_bar()
|
||||
|
||||
class Game_state():
|
||||
def __init__(self,balance=0.0):
|
||||
self.balance = balance
|
||||
@@ -297,7 +304,7 @@ class Button():
|
||||
|
||||
def retirer(self):
|
||||
global live_bet
|
||||
game_state.balance += live_bet
|
||||
change_balance(live_bet)
|
||||
gui.reset_balance_text()
|
||||
live_bet = 0.0
|
||||
gui.cashout = True
|
||||
@@ -344,7 +351,7 @@ class Timer():
|
||||
self.text_rect = self.text.get_rect(center=self.rect.center)
|
||||
|
||||
def reset(self):
|
||||
game_state.balance -= initial_bet
|
||||
change_balance(-initial_bet)
|
||||
gui.reset_balance_text()
|
||||
|
||||
self.angle = 90
|
||||
@@ -394,20 +401,22 @@ def new_round():
|
||||
live_bet, initial_bet = 0.0, 0.0
|
||||
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):
|
||||
hauteur = res[1]-rocket.sprite.rect.bottom
|
||||
rocket.sprite.rect.bottom = res[1]-hauteur
|
||||
|
||||
if not FULLSCREEN:
|
||||
dark_bar()
|
||||
|
||||
"""Création de toutes les instances"""
|
||||
number_font = pg.font.Font("Font/Poppins2.ttf", 90)
|
||||
big_font = pg.font.Font("Font/Poppins2.ttf", 40)
|
||||
mid_font = pg.font.Font("Font/Poppins2.ttf", 30)
|
||||
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.add(Rocket(game_state))
|
||||
|
||||
@@ -429,13 +438,15 @@ while True:
|
||||
rocket.sprite.rect.bottom = res[1]-hauteur
|
||||
# screen = pg.display.set_mode(res, pg.RESIZABLE)
|
||||
if event.type == pg.QUIT:
|
||||
import launcher
|
||||
pg.quit()
|
||||
exit()
|
||||
|
||||
|
||||
mou = pg.mouse.get_pressed()
|
||||
|
||||
pos = pg.mouse.get_pos()
|
||||
screen.fill("#151937")
|
||||
screen.fill((21,25,55))
|
||||
|
||||
courbe.update()
|
||||
|
||||
|
||||
123
launcher.py
123
launcher.py
@@ -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 json
|
||||
import subprocess
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("Casino")
|
||||
root.geometry("500x500")
|
||||
DEBUG = True
|
||||
FULLSCREEN = False
|
||||
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
|
||||
w_height = 700
|
||||
screen_width, screen_height = root.winfo_screenwidth(), root.winfo_screenheight()
|
||||
pg.init()
|
||||
pg.display.set_icon(pg.image.load("Image/icon.png"))
|
||||
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)
|
||||
root.geometry(f'{w_width}x{w_height}+{center_x}+{center_y}')
|
||||
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()
|
||||
def dark_bar():
|
||||
"""Fonction pour passer la fenêtre en thème sombre"""
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
||||
set_window_attribute = ct.windll.dwmapi.DwmSetWindowAttribute
|
||||
get_parent = ct.windll.user32.GetParent
|
||||
hwnd = get_parent(window.winfo_id())
|
||||
hwnd = pg.display.get_wm_info()["window"]
|
||||
rendering_policy = DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
value = 2
|
||||
value = ct.c_int(value)
|
||||
set_window_attribute(hwnd, rendering_policy, ct.byref(value),ct.sizeof(value))
|
||||
root.iconify()
|
||||
root.deiconify()
|
||||
pg.display.set_mode((1,1))
|
||||
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
1
value.json
Normal file
@@ -0,0 +1 @@
|
||||
{"balance": 31.55}
|
||||
Reference in New Issue
Block a user