Scripting and Gameplay
This page is a gameplay workflow map.
For deeper learning, use the focused guides linked here.
Choose Your Task
- Write your first behavior: Scripting Basics
- Handle player input and trigger events: Input, Collisions, and Triggers
- Load the next level or screen: Changing Scenes
- Reuse spawned objects efficiently: Object Pooling
Core Gameplay Loop
- create or update a script
- attach it to a scene object or prefab
- tune serialized fields in inspector
- save scene with
Ctrl+Swhen scene data changed - run
sendama playand validate behavior
Minimal Behavior Example
<?php
use Sendama\Engine\Core\Behaviours\Behaviour;
final class Rotator extends Behaviour
{
public function onUpdate(): void
{
$this->getTransform()->rotateBy(1, 0);
}
}
When To Split Features Across Scripts
Create separate scripts when behaviors have different reasons to change.
Example split:
PlayerMovefor movement inputPlayerWeaponfor shooting and cooldownsPlayerHealthfor life and damage logic
This keeps debugging and balancing much easier.
Next Step
Use Playtesting and Debugging to verify behavior reliably.