forked from InfoProjekt/game
Compare commits
No commits in common. "c17b65d2f332cca09d81fa820b214359ab4d382a" and "2970e5cecd7737362c5c2300b46edcdb58aa8073" have entirely different histories.
c17b65d2f3
...
2970e5cecd
4 changed files with 3 additions and 79 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 626 B |
70
main.py
70
main.py
|
|
@ -52,7 +52,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
|||
rooms = genRooms(WIDTH, HEIGHT, 'grass', objects)
|
||||
level.append(Stage('blau', 'normal', None, [], WIDTH, HEIGHT, 'blue', rooms))
|
||||
scene = Scene('test', 'normal', None, None, WIDTH, HEIGHT, level)
|
||||
freeze = False #Gameplay is freezed in certain situations
|
||||
freeze = True #Gameplay is freezed in certain situations
|
||||
|
||||
while running:
|
||||
screen.fill('#000000')
|
||||
|
|
@ -85,7 +85,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
|||
for thing in objects[0]:
|
||||
thing.book.hidden = not freeze
|
||||
if not thing.update(pygame.key.get_pressed(), pygame.mouse.get_pos(), objects):
|
||||
village(screen, clock, running, background, isblack, WIDTH, HEIGHT)
|
||||
menu(screen, clock, running, background, isblack, WIDTH, HEIGHT)
|
||||
thing.draw(screen)
|
||||
|
||||
for mob in objects[1]:
|
||||
|
|
@ -99,71 +99,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
|||
objects[0][0].book.addspell('windslash')
|
||||
scene.update(False, objects)
|
||||
|
||||
else:
|
||||
objects[0][0].book.hidden = not freeze
|
||||
objects[0][0].book.draw(screen)
|
||||
objects[0][0].book.update()
|
||||
# flip() the display to put your work on screen
|
||||
pygame.display.flip()
|
||||
|
||||
clock.tick(fps) # limits FPS to 60
|
||||
|
||||
def village(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
||||
main = [MainCharacter('Herbert', 100, 'people/oldman.png', 500, 500, 20, 5, 1, 1, 50)]
|
||||
mobs = []
|
||||
weapons = []
|
||||
others = [Fire('f1', 0, 200, 300), Portal('p1', 0, 1000, 500)]
|
||||
npcs = [NPC('name', 100, 'people/oldlady.png', 1, 200, 200)]
|
||||
objects = [main, mobs, npcs, weapons, others]
|
||||
room = Room('village', 'village', 'art/images/background/village.png', objects, WIDTH - 64, HEIGHT - 64, [True, True, True, True], 0)
|
||||
freeze = True #Gameplay is freezed in certain situations
|
||||
|
||||
while running:
|
||||
screen.fill('#000000')
|
||||
events = pygame.event.get()
|
||||
for event in events:
|
||||
if event.type == pygame.QUIT:
|
||||
quitGame()
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_e: #when book is open gameplay is freezed
|
||||
freeze = not freeze
|
||||
# RENDER YOUR GAME HERE
|
||||
"""with open(background, 'r') as i:
|
||||
bg = pygame.image.load(i)
|
||||
bg = pygame.transform.scale(bg, (WIDTH, HEIGHT))
|
||||
# fill the screen with an image to clear the screen
|
||||
screen.blit(bg, (0, 0))
|
||||
"""
|
||||
if not freeze:
|
||||
objects = room.getObjects()
|
||||
screen.blit(room.background, (32, 32))
|
||||
|
||||
for thing in objects[4]:
|
||||
if thing.update(objects):
|
||||
play(screen, clock, running, background, isblack, WIDTH, HEIGHT)
|
||||
thing.draw(screen)
|
||||
|
||||
for weapon in objects[3]:
|
||||
weapon.update(objects)
|
||||
weapon.draw(screen)
|
||||
|
||||
for thing in objects[0]:
|
||||
thing.book.hidden = not freeze
|
||||
if not thing.update(pygame.key.get_pressed(), pygame.mouse.get_pos(), objects):
|
||||
menu(screen, clock, running, background, isblack, WIDTH, HEIGHT)
|
||||
thing.draw(screen)
|
||||
|
||||
for mob in objects[1]:
|
||||
mob.update(objects)
|
||||
mob.draw(screen)
|
||||
|
||||
for npc in objects[2]:
|
||||
npc.update(pygame.key.get_pressed(), objects)
|
||||
npc.draw(screen)
|
||||
|
||||
objects[0][0].book.addspell('windslash')
|
||||
room.update(objects)
|
||||
|
||||
else:
|
||||
objects[0][0].book.hidden = not freeze
|
||||
objects[0][0].book.draw(screen)
|
||||
|
|
@ -212,7 +148,7 @@ def options(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
|||
|
||||
def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT):
|
||||
objects = []
|
||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'textbox.png', 'medieval', 48, "Play", village, attributes=[screen, clock, running, background, isblack, WIDTH, HEIGHT]))
|
||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'textbox.png', 'medieval', 48, "Play", play, attributes=[screen, clock, running, background, isblack, WIDTH, HEIGHT]))
|
||||
#objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'textbox.png', 'medieval', 48, "Options", uwu))
|
||||
objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'textbox.png', 'medieval', 48, "Exit game", quitGame))
|
||||
while running:
|
||||
|
|
|
|||
12
viecher.py
12
viecher.py
|
|
@ -481,16 +481,4 @@ class Fire(Objects):
|
|||
|
||||
def update(self, objects):
|
||||
self.warming(objects)
|
||||
return False
|
||||
|
||||
|
||||
class Portal(Objects):
|
||||
def __init__(self, name, ms, x, y, sprite='portal.png') -> None:
|
||||
super().__init__(name, ms, sprite, x, y)
|
||||
|
||||
def update(self, objects):
|
||||
touches = pg.sprite.spritecollideany(self, objects[0])
|
||||
if touches is not None and isinstance(touches, MainCharacter):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
Loading…
Add table
Reference in a new issue