You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.0 KiB

extends Camera2D
var velocity = Vector2(0, 0)
var mouse_down_pos = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var dir = Vector2(0,0)
if Input.is_key_pressed(KEY_W):
dir.y -= 1
if Input.is_key_pressed(KEY_S):
dir.y += 1
if Input.is_key_pressed(KEY_A):
dir.x -= 1
if Input.is_key_pressed(KEY_D):
dir.x += 1
position += dir * delta * 100
func _input(event):
if event is InputEventMouseButton:
if event.button_index == 1:
if event.pressed:
mouse_down_pos = event.position
else:
var move = mouse_down_pos - event.position
position += move
var zoomf = 0
var nzoom = 0
if event.button_index == 4:
zoomf += 0.1
if event.button_index == 5:
zoomf -= 0.1
nzoom = zoom + Vector2(zoomf, zoomf)
if nzoom.length() != 0 and zoomf != 0:
zoom = nzoom
# print( event.button_index)