forked from Corderius-College-Amersfoort/play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Corderius-College-Amersfoort:master' into master
- Loading branch information
Showing
12 changed files
with
341 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""This module contains the mouse loop.""" | ||
|
||
from ..callback.callback_helpers import run_callback | ||
from ..callback import callback_manager, CallbackType | ||
|
||
|
||
class MouseState: # pylint: disable=too-few-public-methods | ||
click_happened_this_frame = False # pylint: disable=invalid-name | ||
click_release_happened_this_frame = False # pylint: disable=invalid-name | ||
|
||
|
||
mouse_state = MouseState() | ||
|
||
|
||
def _handle_mouse_loop(): | ||
"""Handle mouse events in the game loop.""" | ||
#################################### | ||
# @mouse.when_clicked callbacks | ||
#################################### | ||
if ( | ||
mouse_state.click_happened_this_frame | ||
and callback_manager.get_callbacks(CallbackType.WHEN_CLICKED) is not None | ||
): | ||
for callback in callback_manager.get_callbacks(CallbackType.WHEN_CLICKED): | ||
run_callback( | ||
callback, | ||
[], | ||
[], | ||
) | ||
|
||
######################################## | ||
# @mouse.when_click_released callbacks | ||
######################################## | ||
if ( | ||
mouse_state.click_release_happened_this_frame | ||
and callback_manager.get_callbacks(CallbackType.WHEN_CLICK_RELEASED) is not None | ||
): | ||
for callback in callback_manager.get_callbacks( | ||
CallbackType.WHEN_CLICK_RELEASED | ||
): | ||
run_callback( | ||
callback, | ||
[], | ||
[], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""This module contains the function that simulates the physics of the game""" | ||
|
||
from ..globals import FRAME_RATE | ||
from ..physics import physics_space, _NUM_SIMULATION_STEPS | ||
from .sprites_loop import _update_sprites | ||
|
||
|
||
def simulate_physics(): | ||
""" | ||
Simulate the physics of the game | ||
""" | ||
# more steps means more accurate simulation, but more processing time | ||
for _ in range(_NUM_SIMULATION_STEPS): | ||
# the smaller the simulation step, the more accurate the simulation | ||
physics_space.step(1 / (FRAME_RATE * _NUM_SIMULATION_STEPS)) | ||
_update_sprites(True) |
Oops, something went wrong.