Skip to content

Commit

Permalink
[REFACTOR] Rename draw() to update().
Browse files Browse the repository at this point in the history
[REFACTOR] Move engine files to separate engine folder for abstraction.
  • Loading branch information
nickname2002 committed Jul 2, 2023
1 parent 8d82d8a commit 51eaaab
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 9 deletions.
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions engine.py → engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jorcademy as jc

# Set app icon
pygame_icon = pygame.image.load('assets/jc_icon.png')
pygame_icon = pygame.image.load('./assets/icons/jc_icon.png')
pygame.display.set_icon(pygame_icon)

# Init user setup
Expand All @@ -20,7 +20,7 @@
# Render objects in draw buffer
def render_objects_on_screen() -> None:
for obj in jc.draw_buffer:
obj.draw(screen)
obj.update(screen)


# === Keyboard input === #
Expand Down Expand Up @@ -142,7 +142,7 @@ def handle_mouse_input(event_args: pygame.event):
screen.fill(jc.background_color)

# Render game
game.draw()
game.update()
render_objects_on_screen()

# flip() the display to put your work on screen
Expand Down
4 changes: 2 additions & 2 deletions jorcademy.py → engine/jorcademy.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def title(t: str) -> None:

# Change app icon
def icon(name: str) -> None:
app_icon = pygame.image.load("assets/" + name)
app_icon = pygame.image.load("./assets/" + name)
pygame.display.set_icon(app_icon)


Expand Down Expand Up @@ -104,7 +104,7 @@ def load_sound(path: str):

# Play audio
def play_sound(audio_obj: Audio):
sound = pygame.mixer.Sound("assets/" + audio_obj.filepath)
sound = pygame.mixer.Sound("./assets/" + audio_obj.filepath)
if not pygame.mixer.Channel(audio_obj.channel).get_busy():
pygame.mixer.Channel(audio_obj.channel).play(sound)

Expand Down
File renamed without changes.
5 changes: 1 addition & 4 deletions game.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from jorcademy import *


def setup() -> None:
pass


def draw() -> None:
def update() -> None:
pass

0 comments on commit 51eaaab

Please sign in to comment.