Added Gameobjects class

This commit is contained in:
2024-07-17 18:10:07 +02:00
parent ccdd382485
commit 797619cd1b
3 changed files with 17 additions and 14 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
modules/__pycache__/gameobjects.cpython-312.pyc

20
main.py
View File

@@ -1,6 +1,7 @@
import pygame
import subprocess
import random
from modules.gameobjects import *
@@ -26,9 +27,10 @@ ROT = (255,0,0)
font1 = pygame.font.SysFont("Noto Sans 10pt", 25)
PLAYGROUND = pygame.Surface((1024,728))
obj1 = GameObjects("Test", 0,0)
gamestate = True
#Mapfiles for Mapgen
@@ -52,6 +54,7 @@ pacman_animation.append(pygame.image.load("models/pacman_1_4.png"))
pacman_animation.append(pygame.image.load("models/pacman_1_5.png"))
#ITEMS
fruits = list()
@@ -92,7 +95,6 @@ def generate_map(*mapfile):
startpos_x = 0
startpos_y += map_wall_size
generate_map()
movement_map_center = (map_space_size-pacman_size)/2
@@ -155,11 +157,8 @@ while(gamestate==True):
pacman_posx -= pacman_movespeed
MAINSCREEN.blit(pacman_animation[count], (pacman_posx,pacman_posy))
MAINSCREEN.blit(pacman_animation[0], (pacman_posx,pacman_posy))
count += 1
if count == 5: count = 0
for row in map1:
MAINSCREEN.blit(row["object"], (row["x"],row["y"]))
@@ -184,11 +183,4 @@ while(gamestate==True):
MAINSCREEN.blit(hash_label, (10, MAINSCREEN_SIZE[1]-40))
pygame.display.flip()
clock.tick(60)
count2 += 1
if(count2 == 60):
count2 = 0
clock.tick(60)

10
modules/gameobjects.py Normal file
View File

@@ -0,0 +1,10 @@
import pygame
class GameObjects():
def __init__(self, name, posx:int, posy:int) -> None:
self.posx = posx
self.posy = posy
self.name = name
self.rect:pygame.rect
pass