Zigzag
Demonstrates contraining user-specified movement to multiple of 90 degrees.
Input can be a touch, a mouse left-click (emulated), or a directional input action such as an arrow key press or a joystick input.
This is the GDScript code that constrains the movement:
# vector is the Vector2 direction of the unconstrained movement.
# new_vector is the Vector2 direction of the constrained movement.
const HALF_PI: float = PI / 2.0
var new_vector: Vector2 = Vector2.from_angle((roundf(vector.angle() / HALF_PI)) * HALF_PI)
Source files: https://github.com/daveTheOldCoder/zigzag
Status | Released |
Platforms | HTML5 |
Author | DaveTheCoder |
Genre | Educational |
Made with | Godot |
Leave a comment
Log in with itch.io to leave a comment.