Last active
March 28, 2020 20:01
-
-
Save arcticmatt/999c2d2f3dbbf620ad057914d16e851f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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