mirror of
https://github.com/Apologieze/Monkeycrash.git
synced 2026-01-18 16:27:32 +01:00
New comment and small improvement
This commit is contained in:
@@ -3,6 +3,7 @@ from random import randint
|
||||
import json
|
||||
|
||||
class Gen:
|
||||
"""A class that generate the coinflip game"""
|
||||
def crea(self, tempres, fullscreen):
|
||||
self.DEBUG = True
|
||||
self.FULLSCREEN = fullscreen
|
||||
@@ -115,7 +116,6 @@ class Button():
|
||||
self.receiver.reset_text()
|
||||
|
||||
def update(self):
|
||||
#color = self.color_active if self.rect.collidepoint(pos) and not mou[0] else self.color_passive
|
||||
if self.rect.collidepoint(gen.pos):
|
||||
if gen.mou[0]:
|
||||
color = self.color_passive
|
||||
@@ -302,6 +302,7 @@ class GUI():
|
||||
gen.screen.blit(self.text_screen, self.text_screen_rect)
|
||||
|
||||
def change_balance(n):
|
||||
"""Change the in game balance and the local balance file"""
|
||||
temp = str(gen.balance+n).split('.')
|
||||
gen.balance = round(float(temp[0]) + float("0." + temp[1][:min(2, len(temp[1]))]), 2)
|
||||
gen.gui.display_balance.resize()
|
||||
@@ -310,6 +311,7 @@ def change_balance(n):
|
||||
|
||||
|
||||
def init(tempres, fullscreen):
|
||||
"""Function used to start the game"""
|
||||
global gen
|
||||
gen = Gen()
|
||||
gen.crea(tempres, fullscreen)
|
||||
|
||||
21
crash.py
21
crash.py
@@ -1,17 +1,14 @@
|
||||
import pygame as pg
|
||||
from sys import exit
|
||||
import ctypes as ct
|
||||
from random import randint
|
||||
import json
|
||||
|
||||
class Gen():
|
||||
"""A class that generate the crash game"""
|
||||
def crea(self, tempres, fullscreen):
|
||||
self.DEBUG = False
|
||||
self.FULLSCREEN = fullscreen
|
||||
self.CHANGESCENE = 0
|
||||
self.running = False
|
||||
# pg.init()
|
||||
#screen_width, screen_height = Tk().winfo_screenwidth(), Tk().winfo_screenheight()
|
||||
self.tempres = tempres
|
||||
self.res = tempres[0] if self.FULLSCREEN else tempres[1]
|
||||
self.mid_screen = (self.res[0] // 2, self.res[1] // 2)
|
||||
@@ -41,7 +38,7 @@ class Gen():
|
||||
|
||||
self.courbe = Courbe()
|
||||
self.gui = Gui(self.game_state)
|
||||
self.historic = Historic()
|
||||
self.history = History()
|
||||
|
||||
self.timer = Timer()
|
||||
|
||||
@@ -87,7 +84,7 @@ class Gen():
|
||||
|
||||
self.gui.update()
|
||||
|
||||
self.historic.update()
|
||||
self.history.update()
|
||||
|
||||
self.rocket.draw(self.screen)
|
||||
self.rocket.update()
|
||||
@@ -168,7 +165,7 @@ class Rocket(pg.sprite.Sprite):
|
||||
if self.fall_index < 50:
|
||||
if self.fall_index == 0:
|
||||
new_round()
|
||||
gen.historic.add_value(self.multi_max,self.multi_color)
|
||||
gen.history.add_value(self.multi_max,self.multi_color)
|
||||
self.multi_color = "#ff0000"
|
||||
self.explosion.play()
|
||||
self.fall_index += 1
|
||||
@@ -420,7 +417,8 @@ class Timer():
|
||||
pg.mixer.music.play()
|
||||
self.reset()
|
||||
|
||||
class Historic():
|
||||
class History():
|
||||
"""Show the last multipliers"""
|
||||
def __init__(self):
|
||||
self.text_list = []
|
||||
self.rect_list = []
|
||||
@@ -453,7 +451,7 @@ def new_round():
|
||||
gen.gui.reset_live_bet()
|
||||
|
||||
def change_balance(n):
|
||||
# gen.game_state.balance += n
|
||||
"""Change the in game balance and the local balance file"""
|
||||
temp = str(gen.game_state.balance+n).split('.')
|
||||
gen.game_state.balance = round(float(temp[0]) + float("0." + temp[1][:min(2, len(temp[1]))]), 2)
|
||||
with open('value.json', 'w') as json_file:
|
||||
@@ -465,8 +463,7 @@ def rocket_video_reset(h):
|
||||
|
||||
|
||||
def init(tempres, fullscreen):
|
||||
"""Function used to start the game"""
|
||||
global gen
|
||||
gen = Gen()
|
||||
gen.crea(tempres, fullscreen)
|
||||
|
||||
|
||||
gen.crea(tempres, fullscreen)
|
||||
@@ -4,6 +4,7 @@ import ctypes as ct
|
||||
import json
|
||||
|
||||
class Gen:
|
||||
"""A class that generate the launcher to launch game"""
|
||||
def crea(self, tempres, fullscreen):
|
||||
self.DEBUG = True
|
||||
self.FULLSCREEN = fullscreen
|
||||
|
||||
2
scene.py
2
scene.py
@@ -4,7 +4,7 @@ import coinflip
|
||||
import pygame as pg
|
||||
|
||||
class Scene():
|
||||
"""Gestionnaire des différentes scène qui permet de naviguer facilement entre les différents jeu et le launcher"""
|
||||
"""Scene Manager that allows you to easily navigate between the different games and the launcher"""
|
||||
def change_scene(self,nb):
|
||||
self.current_scene = self.scenes[nb-1]
|
||||
self.current_scene.init(self.res, self.FULLSCREEN)
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"balance": 100.0}
|
||||
{"balance": 99.6}
|
||||
Reference in New Issue
Block a user