Debug, camera work
This commit is contained in:
parent
8e3bdab601
commit
63690ca3ed
BIN
Assets/clacon.ttf
Normal file
BIN
Assets/clacon.ttf
Normal file
Binary file not shown.
14
Main.tscn
14
Main.tscn
@ -1,14 +1,18 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://Prefabs/StdBoard.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Prefabs/StdExtBoard.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Main.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Scripts/GameCamera.gd" type="Script" id=3]
|
||||
[ext_resource path="res://Prefabs/StdExtBoard.tscn" type="PackedScene" id=4]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="StdBoard" parent="." instance=ExtResource( 1 )]
|
||||
|
||||
[node name="StdExtBoard" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
current = true
|
||||
zoom = Vector2( 2, 2 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="StdExtBoard" parent="." instance=ExtResource( 4 )]
|
||||
|
@ -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]
|
||||
|
@ -30,10 +30,32 @@ config/name="Hexland"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
Debug="*res://Scripts/Debug.gd"
|
||||
|
||||
[gui]
|
||||
|
||||
common/drop_mouse_on_gui_input_disabled=true
|
||||
|
||||
[input]
|
||||
|
||||
ui_zoom_in={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_zoom_out={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_pan={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":3,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
Loading…
Reference in New Issue
Block a user