While tinkering with the Godot game engine, I came across this piece of code:
class Ball extends KinematicBody2D: func process(delta): if Input.is_action_pressed('ui_right'): velocity.x += 1 move_and_collide(velocity * delta)
I realized I have no idea how I would implement this in any post-OOP language (Rust, Go etc).
I assume the engine’s part looks something like
I can define a trait (interface in Go) with a method
process(), but then I won’t have access to the object’s fields. And I need to be able to modify velocity, position, etc.
There’s currently a discussion about adding fields to traits, but there must be another way.
This is used very often in games, GUI development, etc.