Removed pygame-menu and code cleanup

Added game class
This commit is contained in:
2024-02-06 22:28:14 +01:00
parent caad5c9dbc
commit 2a60195960
6 changed files with 163 additions and 106 deletions

View File

@@ -1,6 +1,7 @@
import pygame
import random as rand
class GameObject():
"""TODO Install a body array with positions of mainbody and adders"""
@@ -175,6 +176,7 @@ class Player(GameObject_new):
self.__snake_body = [[100,100+size], [100,100+size*2], [100,100+size*3], [100,size*5]]
super().__init__(name, surface, surface_size, init_pos_x, init_pos_y, visibility)
self.__snake = {"head":"data/models/snake_head_1.png", "body":"data/models/snake_body_1.png", "tail":""}
self._startmoving = False
__movedirection = {"up":False, "down":False, "left":False, "right":False}
@@ -253,6 +255,8 @@ class Player(GameObject_new):
image = pygame.image.load(self.__snake["body"])
image = pygame.transform.scale(image, (30,40))
image = pygame.transform.rotate(image, 270)
surface.blit(image, (0,5))
self._surface.blit(surface, (pos[0], pos[1]))
#print((pos[0], pos[1]))

30
modules/Game_new.py Normal file
View File

@@ -0,0 +1,30 @@
#Behandelt später die Hauptschleife und Klassenobjekte
class Game():
def __init__(self) -> None:
self.__state = {
"started":False,
"playermove":False,
"win":False,
"lose":False,
"paused":False,
"menu":False
}
def get_state(self, state):
return self.__state[state]
def change_state(self, state):
"""Toggles the selected game state"""
if(not self.__state[state]):
self.__state[state] = True
else:
self.__state[state] = False
def scoreboard(self):
pass
def spawn_fruit(self):
pass
def spawn_player(self):
pass

View File

@@ -139,6 +139,7 @@ class User:
return self.__all_listed_users
def checkuserdb(self):
"""Checks for existing user, else return false"""
cursor = self.__sqlhandle.cursor()
rows=cursor.execute("SELECT * FROM user")
rows_count =len(list(rows))