Skip to content

Instantly share code, notes, and snippets.

@arcticmatt
Last active March 28, 2020 20:01
Show Gist options
  • Save arcticmatt/999c2d2f3dbbf620ad057914d16e851f to your computer and use it in GitHub Desktop.
Save arcticmatt/999c2d2f3dbbf620ad057914d16e851f to your computer and use it in GitHub Desktop.
extends Sprite
const VELOCITY: float = -1.5
var g_texture_width: float = 0
func _ready():
g_texture_width = texture.get_size().x * scale.x
func _process(delta: float) -> void:
position.x += VELOCITY
_attempt_reposition()
func _attempt_reposition() -> void:
if position.x < -g_texture_width:
# Don't just reset position to texture width, otherwise there will be a gap
position.x += 2 * g_texture_width
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment