Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node2D
- var state = 0
- var x = 0
- var y = 0
- var speed = 3
- func _ready():
- set_process(true)
- pass
- func _process(delta):
- update()
- pass
- func _draw():
- draw_rect(Rect2(x,y,10,10),Color(1,0,0))
- if state == 0:
- x = x + speed
- if x > 200-10:
- x = 200 - 10
- state = 1
- if state == 1:
- y = y + speed
- if y > 200 - 10:
- y = 200 - 10
- state = 2
- if state == 2:
- x = x - speed
- if x < 0 :
- x = 0
- state = 3
- if state == 3 :
- y = y - speed
- if y < 0 :
- y = 0
- state = 0
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement