Untitled
unknown
plain_text
9 months ago
2.4 kB
5
Indexable
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 22.11.2024
@author: haida
"""
import dae_progfa_lib as pfe
from dae_progfa_lib import ShapeMode, MouseButton
from dae_progfa_lib import MouseButton
import math
from dae_progfa_lib.progfa_image import ProgfaImage
from pygame.math import Vector2
# Create an instance of ProgfaEngine and set window size (width, height):
engine = pfe.ProgfaEngine(800, 600)
# Set the frame rate to x frames per second:
engine.set_fps(60)
list_frames = []
frame_amount = 4
#VARIEBles
current_frame = 1
timer = 0
max_timer = 20
def setup():
"""
Only executed ONCE (at the start); use to load files and initialize.
"""
for i in range(frame_amount):
list_frames.append(engine.load_image(f"Resources/crewmates/green{i+1}.png"))
print(list_frames)
pass
def render():
"""
This function is being executed over and over, as fast as the frame rate. Use to draw (not update).
"""
engine.background_color = 1,1,1
draw_crewmate(current_frame)
pass
def draw_crewmate(frame: int = 0):
"""
Draws a crewmate image based on frame
:return:
"""
list_frames[frame].draw(0,0)
img: ProgfaImage = list_frames[frame]
img.draw(0,0)
#DEBUG
engine.set_font_size(20)
engine.color = 0,0,0
engine.draw_text(str(frame),20 ,20)
def evaluate():
"""
This function is being executed over and over, as fast as the frame rate. Use to update (not draw).
"""
global current_frame,timer, max_timer
timer += 1
if timer >= max_timer:
current_frame += 1
current_frame %= len(list_frames)
timer = 0
pass
def mouse_pressed_event(mouse_x: int, mouse_y: int, mouse_button: MouseButton):
"""
This function is only executed once each time a mouse button was pressed!
"""
pass
def key_up_event(key: str):
"""
This function is only executed once each time a key was released!
Special keys have more than 1 character, for example ESCAPE, BACKSPACE, ENTER, ...
"""
pass
# Engine stuff; best not to mess with this:
engine._setup = setup
engine._evaluate = evaluate
engine._render = render
engine._mouse_pressed_event = mouse_pressed_event
engine._key_up_event = key_up_event
# Start the game loop:
engine.play()
Editor is loading...
Leave a Comment