-
Notifications
You must be signed in to change notification settings - Fork 0
Supporting gameplay components
The collider system in our game template allows you to handle collisions between game objects efficiently. This is essential for implementing game mechanics such as player-environment interactions, enemy detection, and more.
We've integrated the collider system into our game using the SlitherZenith game engine. Here's a brief overview of how to use the collider system in our template:
from slitherzenith import *
from components.support.settings import *
from components.timer.timer_manager import *
from components.gameObject.collision.Collider import Collider
from components.gameObject.gameObject import GameObject
# Initialize game-object 1
g1 = GameObject(100, 100, 50, 50)
c1 = Collider(g1)
# Initialize game-object 2
g2 = GameObject(200, 100, 50, 50)
c2 = Collider(g2)
def setup() -> None:
pass
def update() -> None:
# Update collider positions
c1.update()
c2.update()
# Check for collision
if c1.collides_with(c2):
return
# Move game-object 2
g2.x -= 50 * delta_time
def draw() -> None:
rect((255, 0, 0), g1.x, g1.y, g1.width, g1.height)
rect((0, 255, 0), g2.x, g2.y, g2.width, g2.height)
In this code, we first initialize two game objects (g1 and g2) and create colliders (c1 and c2) for them. The update function is responsible for updating the collider positions and checking for collisions. If a collision is detected using the collides_with method, you can handle it accordingly in your game logic.
Feel free to incorporate this collider system into your game template to manage collisions between game objects and create interactive and dynamic game experiences.
The timer system in our game template allows you to schedule and manage timers, which can be useful for implementing time-based game mechanics, animations, or other time-sensitive events.
We've integrated the timer system into our game using the SlitherZenith game engine. Here's a brief overview of how to use the timer system in our template:
from slitherzenith import *
from components.support.settings import *
from components.timer.timer_manager import *
def setup() -> None:
# Add a timer named "test" with a duration of 1.0 second
add_timer("test", 1.0)
# Start the "test" timer
get_timer("test").start()
def update() -> None:
# Check if the "test" timer has finished
if get_timer("test").finished:
print("Timer Finished!")
else:
print("Timer Not Finished!")
def draw() -> None:
pass
In the setup function, we create a timer named "test" with a duration of 1.0 second using the add_timer function and then start it with start. In the update function, we check if the timer has finished, and if it has, we print "Timer Finished!".
You can customize the timer's name, duration, and behavior to suit your specific game requirements. Feel free to incorporate this timer system into your game template to handle time-sensitive actions and events.