This commit is contained in:
Apologieze
2022-05-23 18:35:56 +02:00
5 changed files with 17 additions and 17 deletions

View File

@@ -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
@@ -162,7 +162,7 @@ class Coin():
if self.acceleration:
self.speed += self.speed*0.025
#print(self.speed)
if self.speed > 4:
if self.speed > 5:
self.acceleration = False
else:
if self.speed > 0.8:
@@ -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)

View File

@@ -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 = True
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()
@@ -73,7 +70,6 @@ class Gen():
self.gui.video_size_reset()
self.timer.video_size_reset()
self.rocket.sprite.rect.bottom = self.res[1] - hauteur
# screen = pg.display.set_mode(res, pg.RESIZABLE)
elif event.type == pg.QUIT:
pg.mixer.music.stop()
self.CHANGESCENE = 1
@@ -88,7 +84,7 @@ class Gen():
self.gui.update()
self.historic.update()
self.history.update()
self.rocket.draw(self.screen)
self.rocket.update()
@@ -169,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
@@ -421,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 = []
@@ -454,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:
@@ -466,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)

View File

@@ -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

View File

@@ -4,6 +4,7 @@ import coinflip
import pygame as pg
class Scene():
"""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)

View File

@@ -1 +1 @@
{"balance": 200.06}
{"balance": 99.6}