Some changes...
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1673,3 +1673,4 @@ modules/__pycache__/Tilemap.cpython-312.pyc
|
|||||||
modules/__pycache__/Tileset.cpython-312.pyc
|
modules/__pycache__/Tileset.cpython-312.pyc
|
||||||
modules/__pycache__/Tiletype.cpython-312.pyc
|
modules/__pycache__/Tiletype.cpython-312.pyc
|
||||||
modules/__pycache__/Utils.cpython-312.pyc
|
modules/__pycache__/Utils.cpython-312.pyc
|
||||||
|
__pycache__/Animation.cpython-312.pyc
|
||||||
|
|||||||
27
Animation.py
Normal file
27
Animation.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Animation(object):
|
||||||
|
def __init__(self, image, start_x, start_y, num, width, height, duration) -> None:
|
||||||
|
self.image = image
|
||||||
|
|
||||||
|
self.start_x = start_x
|
||||||
|
self.start_y = start_y
|
||||||
|
self.num = num
|
||||||
|
self.width = width
|
||||||
|
self.height = height
|
||||||
|
|
||||||
|
self.duration = duration
|
||||||
|
self.time = 0
|
||||||
|
self.current = 0
|
||||||
|
|
||||||
|
def render(self, screen, pos):
|
||||||
|
screen.blit(self.image, pos, pygame.Rect(self.start_x + (self.width * self.current), self.start_y, self.width, self.height))
|
||||||
|
|
||||||
|
def update(self, time=1):
|
||||||
|
self.time += time
|
||||||
|
|
||||||
|
if self.time > self.duration:
|
||||||
|
self.time = 0
|
||||||
|
self.current += 1
|
||||||
|
if self.current >= self.num:
|
||||||
|
self.current = 0
|
||||||
5
Player.py
Normal file
5
Player.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Player(object):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
pass
|
||||||
@@ -21,15 +21,14 @@ class Tilemap(object):
|
|||||||
for i in range(0, self.height):
|
for i in range(0, self.height):
|
||||||
self.tiles.append(list())
|
self.tiles.append(list())
|
||||||
for j in range(0, self.width):
|
for j in range(0, self.width):
|
||||||
x = random.randint(0,4)
|
if i == 15:
|
||||||
if x == 0:
|
|
||||||
self.tiles[i].append("grass")
|
self.tiles[i].append("grass")
|
||||||
elif x == 1:
|
elif i == 15:
|
||||||
self.tiles[i].append("water")
|
self.tiles[i].append("water")
|
||||||
elif x == 2:
|
elif i > 15:
|
||||||
self.tiles[i].append("mud")
|
self.tiles[i].append("mud")
|
||||||
else:
|
else:
|
||||||
self.tiles[i].append("block")
|
self.tiles[i].append("empty")
|
||||||
|
|
||||||
def render(self, screen):
|
def render(self, screen):
|
||||||
|
|
||||||
|
|||||||
5
main.py
5
main.py
@@ -1,5 +1,6 @@
|
|||||||
import pygame
|
import pygame
|
||||||
import Tilemap
|
import Tilemap
|
||||||
|
import Animation
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
@@ -29,10 +30,10 @@ def main():
|
|||||||
while running:
|
while running:
|
||||||
# Framerate auf 30 Frames pro Sekunde beschränken.
|
# Framerate auf 30 Frames pro Sekunde beschränken.
|
||||||
# Pygame wartet, falls das Programm schneller läuft.
|
# Pygame wartet, falls das Programm schneller läuft.
|
||||||
clock.tick(30)
|
clock.tick(60)
|
||||||
|
|
||||||
# screen Surface mit Schwarz (RGB = 0, 0, 0) füllen.
|
# screen Surface mit Schwarz (RGB = 0, 0, 0) füllen.
|
||||||
screen.fill((0, 0, 0))
|
screen.fill((198, 209, 255))
|
||||||
|
|
||||||
# Alle aufgelaufenen Events holen und abarbeiten.
|
# Alle aufgelaufenen Events holen und abarbeiten.
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
|
|||||||
Reference in New Issue
Block a user