Debug, camera work
This commit is contained in:
@@ -29,3 +29,4 @@ func _ready():
|
||||
hex.translate(Y_OFFSET * index.y)
|
||||
add_child(hex)
|
||||
hex.type = tiles.pop_front()
|
||||
hex.index = index
|
||||
|
||||
10
Scripts/Debug.gd
Normal file
10
Scripts/Debug.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
extends Node
|
||||
|
||||
var on = false
|
||||
|
||||
var font
|
||||
|
||||
func _ready():
|
||||
font = DynamicFont.new()
|
||||
font.size = 32
|
||||
font.font_data = load("res://Assets/clacon.ttf")
|
||||
21
Scripts/GameCamera.gd
Normal file
21
Scripts/GameCamera.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
extends Camera2D
|
||||
|
||||
const ZOOM_SPEED = 0.2
|
||||
|
||||
var pan = false
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_released("ui_zoom_in"):
|
||||
zoom -= Vector2.ONE * ZOOM_SPEED
|
||||
elif Input.is_action_just_released("ui_zoom_out"):
|
||||
zoom += Vector2.ONE * ZOOM_SPEED
|
||||
|
||||
if Input.is_action_pressed("ui_pan"):
|
||||
pan = true
|
||||
else:
|
||||
pan = false
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion:
|
||||
if pan:
|
||||
translate(-event.relative * zoom)
|
||||
@@ -18,12 +18,21 @@ const TEXTURE_MAP = {
|
||||
}
|
||||
|
||||
var type = "desert" setget set_type
|
||||
var index = Vector2.ZERO
|
||||
|
||||
func _ready():
|
||||
var sprite = Sprite.new()
|
||||
sprite.texture = TEXTURE_MAP[type]
|
||||
sprite.name = "Img"
|
||||
add_child(sprite)
|
||||
var label = Label.new()
|
||||
label.name = "Lbl"
|
||||
label.add_font_override("font", Debug.font)
|
||||
add_child(label)
|
||||
|
||||
func _process(_delta):
|
||||
if Debug.on:
|
||||
$Lbl.text = "(%+d, %+d)" % [index.x, index.y]
|
||||
|
||||
func set_type(newtype):
|
||||
$Img.texture = TEXTURE_MAP[newtype]
|
||||
|
||||
Reference in New Issue
Block a user