Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################################################
- #Copyright (C) 2022 Kris Occhipinti
- #https://filmsbykris.com
- #This program is free software: you can redistribute it and/or modify
- #it under the terms of the GNU General Public License as published by
- #the Free Software Foundation, either version 3 of the License, or
- #(at your option) any later version.
- #This program is distributed in the hope that it will be useful,
- #but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- #GNU General Public License for more details.
- #You should have received a copy of the GNU General Public License
- #along with this program. If not, see <http://www.gnu.org/licenses/>.
- ######################################################################
- extends Sprite
- var direction = Vector2()
- export var speed = 500
- export var player_id = 0
- func _process(delta):
- move(delta)
- func _input(event):
- if event.device != player_id:
- return
- var x = 0
- var y = 0
- if Input.is_action_pressed("player_right"):
- x += 1
- elif Input.is_action_pressed("player_left"):
- x -= 1
- if Input.is_action_pressed("player_up"):
- y -= 1
- elif Input.is_action_pressed("player_down"):
- y += 1
- direction= Vector2(x,y)
- func move(delta):
- position += direction * speed * delta
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement