changed game layout away from using image
This commit is contained in:
@ -15,6 +15,6 @@ class Database:
|
||||
self.__cursor.execute(query)
|
||||
return self.__cursor.fetchall()
|
||||
|
||||
def fetchall(self, query:str):
|
||||
def fetchone(self, query:str):
|
||||
self.__cursor.execute(query)
|
||||
return self.__cursor.fetchone()
|
@ -2,6 +2,7 @@ import socket
|
||||
import threading
|
||||
import os
|
||||
import json
|
||||
import database
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
@ -9,6 +10,9 @@ load_dotenv()
|
||||
# retrieves host data from environment
|
||||
HOST = os.getenv("HOST")
|
||||
PORT = os.getenv("PORT")
|
||||
db = database.Database(os.getenv("DBNAME"), os.getenv("DBHOST"), os.getenv("DBUSER"), os.getenv("DBPASSWORD"), os.getenv("DBPORT"))
|
||||
|
||||
sessions = {}
|
||||
|
||||
# TODO: setup tcp service for authorization
|
||||
def handle_connection(socket:socket, address):
|
||||
@ -28,9 +32,13 @@ def handle_connection(socket:socket, address):
|
||||
|
||||
# decide which event should be performed
|
||||
if message_json["event"] == "login":
|
||||
|
||||
username = message_json["username"]
|
||||
password = message_json["password"]
|
||||
|
||||
# encode message and respond to client
|
||||
# TODO: connect to databasse
|
||||
# TODO: request user data
|
||||
db.fetchone(f"SELECT * FROM users WHERE username={username} AND password={password}")
|
||||
# TODO: validate user data
|
||||
# TODO: create session
|
||||
# TODO: return session to client
|
||||
|
@ -1,46 +0,0 @@
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
from Classes.System.Window import Window
|
||||
from Classes.System.InputHandler import InputHandler
|
||||
|
||||
|
||||
class App:
|
||||
|
||||
__window:Window
|
||||
__running:bool = True
|
||||
__player = pygame.Rect((300,250, 50,50))
|
||||
__FPS = 60
|
||||
__speed = 5
|
||||
__clock = pygame.time.Clock()
|
||||
|
||||
def __init__(self, width:int=800, height:int=600, title:str="default title"):
|
||||
self.__window = Window(width=width, height=height, title=title)
|
||||
self.startGameLoop()
|
||||
self.onCleanup()
|
||||
|
||||
def startGameLoop(self):
|
||||
while self.__running:
|
||||
|
||||
self.__clock.tick(self.__FPS)
|
||||
|
||||
#temporary refresh
|
||||
self.__window.clea().fill((0,0,0))
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,0,0), self.__player)
|
||||
|
||||
self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed))
|
||||
|
||||
# event handler
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
self.onCleanup()
|
||||
|
||||
# emits update to the game
|
||||
pygame.display.update()
|
||||
|
||||
def setRunning(self, running:bool):
|
||||
self.__running = running
|
||||
|
||||
def onCleanup(self):
|
||||
self.__running = False
|
||||
pygame.quit()
|
Binary file not shown.
@ -14,7 +14,7 @@ class App:
|
||||
__FPS = 60
|
||||
__clock = pygame.time.Clock()
|
||||
|
||||
def __init__(self, width:int=1280, height:int=720, title:str="default title"):
|
||||
def __init__(self, width:int=1920, height:int=1080, title:str="default title"):
|
||||
self.__window = Window(width=width, height=height, title=title)
|
||||
self.startGameLoop()
|
||||
self.onCleanup()
|
||||
@ -25,7 +25,31 @@ class App:
|
||||
cards = pygame.sprite.Group()
|
||||
|
||||
# game word
|
||||
world = World(pygame.image.load("Assets/Arenas/default.png").convert_alpha())
|
||||
# the field
|
||||
playerMonsterGroup = []
|
||||
playerSpellGroup = []
|
||||
enemyMonsterGroup = []
|
||||
ememySpellGroup = []
|
||||
enemyOtherGroup = []
|
||||
playerOtherGroup = []
|
||||
|
||||
cardWith = 200
|
||||
cardHeight = 250
|
||||
cardOffset = 400
|
||||
|
||||
# player card fields
|
||||
for i in range(5):
|
||||
playerMonsterGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * i), (2 * cardHeight) + 60, cardWith, cardHeight))
|
||||
playerSpellGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * i), (2 * cardHeight) + cardHeight + 70, cardWith, cardHeight))
|
||||
|
||||
enemyMonsterGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * (i+1)), 15, cardWith, cardHeight))
|
||||
ememySpellGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * (i+1)), cardHeight + 25, cardWith, cardHeight))
|
||||
|
||||
enemyOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 0), 15, cardWith, cardHeight))
|
||||
enemyOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 0), cardHeight + 25, cardWith, cardHeight))
|
||||
|
||||
playerOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 5), (2*cardHeight) + 60, cardWith, cardHeight))
|
||||
playerOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 5), (2*cardHeight) + cardHeight + 70, cardWith, cardHeight))
|
||||
|
||||
testMonsterCard = MonsterCard((500,500), "Assets/Cards/MonsterCards/testmonstercard/")
|
||||
cards.add(testMonsterCard)
|
||||
@ -34,8 +58,26 @@ class App:
|
||||
|
||||
self.__clock.tick(self.__FPS)
|
||||
|
||||
self.__window.getScreen().fill("grey100")
|
||||
world.draw(self.__window.getScreen())
|
||||
self.__window.getScreen().fill((0,0,0))
|
||||
# world.draw(self.__window.getScreen())
|
||||
|
||||
for card in playerOtherGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (0,255,0), card)
|
||||
|
||||
for card in playerMonsterGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,255,255), card)
|
||||
|
||||
for card in playerSpellGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,255,255), card)
|
||||
|
||||
for card in enemyOtherGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,0,0), card)
|
||||
|
||||
for card in enemyMonsterGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,0,255), card)
|
||||
|
||||
for card in ememySpellGroup:
|
||||
pygame.draw.rect(self.__window.getScreen(), (255,0,255), card)
|
||||
|
||||
# update sprite groups
|
||||
cards.update()
|
||||
|
@ -13,7 +13,7 @@ class Window:
|
||||
self.__height = height
|
||||
self.__title = title
|
||||
|
||||
self.__screen = pygame.display.set_mode((self.__width, self.__height))
|
||||
self.__screen = pygame.display.set_mode((self.__width, self.__height), pygame.FULLSCREEN)
|
||||
pygame.display.init()
|
||||
|
||||
pygame.display.set_caption = self.__title
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
card files/Unbenannt-1.psd
Normal file
BIN
card files/Unbenannt-1.psd
Normal file
Binary file not shown.
BIN
card files/arena.psd
Normal file
BIN
card files/arena.psd
Normal file
Binary file not shown.
Reference in New Issue
Block a user