tilemaps!

This commit is contained in:
zoe 2022-05-01 01:28:31 +02:00
parent f5f66b5918
commit b38a39e127
15 changed files with 146 additions and 6 deletions

View File

@ -0,0 +1,3 @@
source_md5="51a24b88d8d04d41bb08fb37210d0c1a"
dest_md5="9292fede89cc4d9fde79c618d8241bf7"

View File

@ -1,3 +1,3 @@
source_md5="7d76499be9b404817efc9b6091ecd3f7"
dest_md5="a8c8f2f79e2fef0ca5ca5b3b72c995ad"
source_md5="59c9436dc5ea53f2bc3dac38af894dec"
dest_md5="a62e530f259d2076dd7d2e62bc1d97b6"

View File

@ -38,6 +38,41 @@ texture={
"svg/scale": 1.0
}
[input]
camera_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
camera_up={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
camera_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
camera_down={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
zoom_in={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"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":1,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":false,"meta":false,"command":false,"pressed":false,"scancode":61,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
zoom_out={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"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)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":45,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
[physics]
common/enable_pause_aware_picking=true

16
godot/saves.gd Normal file
View File

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# 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):
# pass

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/default.png-3bbe939339db863d2d767f4cc6888a76.stex"
path="res://.import/default.png-13971fa1f37d4ea367b7aa5973d2bb0a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://sprite/tiles/default.png"
dest_files=[ "res://.import/default.png-3bbe939339db863d2d767f4cc6888a76.stex" ]
source_file="res://sprite/tiles/terrain/default.png"
dest_files=[ "res://.import/default.png-13971fa1f37d4ea367b7aa5973d2bb0a.stex" ]
[params]

13
godot/world/terrain.gd Normal file
View File

@ -0,0 +1,13 @@
extends TileMap
var width = 256
var height = 256
# Called when the node enters the scene tree for the first time.
func _ready():
fill()
func fill():
for x in width:
for y in height:
set_cell(x,y,0,false,false,false,Vector2(1,0))

View File

@ -0,0 +1,26 @@
[gd_resource type="TileSet" load_steps=2 format=2]
[ext_resource path="res://sprite/tiles/terrain/default.png" type="Texture" id=1]
[resource]
0/name = "default.png 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 128, 128 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 32, 32 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0

View File

@ -1,3 +1,29 @@
[gd_scene format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://world/terrain/terrain.tres" type="TileSet" id=1]
[ext_resource path="res://world/terrain.gd" type="Script" id=2]
[ext_resource path="res://world/worldcam.gd" type="Script" id=3]
[node name="World" type="Node2D"]
[node name="terrain" type="TileMap" parent="."]
position = Vector2( -2, 0 )
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( -393219, 0, 196609, -393218, 0, 196609, -393217, 0, 196609, -458752, 0, 196609, -458751, 0, 196609, -327683, 0, 196609, -327682, 0, 196609, -327681, 0, 196609, -393216, 0, 196609, -393215, 0, 196609, -393214, 0, 196609, -262147, 0, 196609, -262146, 0, 196609, -262145, 0, 196609, -327680, 0, 196609, -327679, 0, 196609, -327678, 0, 196609, -327677, 0, 196609, -196611, 0, 196609, -196610, 0, 196609, -196609, 0, 131072, -262144, 0, 196609, -262143, 0, 196609, -262142, 0, 196609, -262141, 0, 196609, -262140, 0, 196609, -131075, 0, 196609, -131074, 0, 196609, -131073, 0, 196609, -196608, 0, 196609, -196607, 0, 196609, -196606, 0, 196609, -196605, 0, 196609, -196604, 0, 196609, -196603, 0, 196609, -65539, 0, 196609, -65538, 0, 196609, -65537, 0, 196609, -131072, 0, 196609, -131071, 0, 196609, -131070, 0, 196609, -131069, 0, 196609, -131068, 0, 196609, -131067, 0, 196609, -131066, 0, 196609, -2, 0, 196609, -1, 0, 196609, -65536, 0, 196609, -65535, 0, 196609, -65534, 0, 196609, -65533, 0, 196609, -65532, 0, 196609, -65531, 0, 196609, -65530, 0, 196609, 65534, 0, 196609, 65535, 0, 196609, 0, 0, 196609, 1, 0, 196609, 2, 0, 196609, 3, 0, 196609, 4, 0, 196609, 131070, 0, 196609, 131071, 0, 196609, 65536, 0, 196609, 65537, 0, 196609, 65538, 0, 196609, 65539, 0, 196609, 65540, 0, 196609, 196607, 0, 196609, 131072, 0, 196609, 131073, 0, 196609, 131074, 0, 196609, 131075, 0, 196609, 131076, 0, 196609, 131077, 0, 196609, 196608, 0, 196609, 196609, 0, 196609, 196610, 0, 196609, 196611, 0, 196609, 196612, 0, 196609, 196613, 0, 196609, 262144, 0, 196609, 262145, 0, 196609, 262146, 0, 196609, 262147, 0, 196609, 262148, 0, 196609, 262149, 0, 196609, 327683, 0, 196609, 327684, 0, 196609 )
script = ExtResource( 2 )
[node name="TileMap" type="TileMap" parent="."]
position = Vector2( -2, 0 )
mode = 1
tile_set = ExtResource( 1 )
cell_size = Vector2( 32, 16 )
format = 1
tile_data = PoolIntArray( -196609, 0, 65539, -262144, 0, 65539, -262143, 0, 65539, -196608, 0, 65539, -196607, 0, 65536, -196606, 0, 65536, -196605, 0, 65539, -65537, 0, 65536, -131072, 0, 65536, -131071, 0, 65536, -131070, 0, 65536, -131069, 0, 65536, -131068, 0, 65536, -65536, 0, 65539, -65535, 0, 65539, -65534, 0, 196609, 1, 0, 65539, 2, 0, 2, 65537, 0, 2, 65538, 0, 196609 )
[node name="worldcam" type="Camera2D" parent="."]
current = true
zoom = Vector2( 0.4, 0.4 )
script = ExtResource( 3 )

21
godot/world/worldcam.gd Normal file
View File

@ -0,0 +1,21 @@
extends Camera2D
export var min_zoom = 0.4
export var speed = 200
var zoomlevel = 0.4
func _process(delta):
move_around(delta)
handle_zoom()
func move_around(delta):
var xdirection = Input.get_action_strength("camera_right") - Input.get_action_strength("camera_left")
var ydirection = Input.get_action_strength("camera_down") - Input.get_action_strength("camera_up")
var direction = Vector2(xdirection, ydirection).normalized() * delta * speed * zoom
position = lerp(position, position + direction, 2)
func handle_zoom():
if Input.is_action_just_pressed("zoom_in"):
zoomlevel = clamp(zoomlevel - 0.1, 0.1, 2)
if Input.is_action_just_pressed("zoom_out"):
zoomlevel = clamp(zoomlevel + 0.1, 0.1, 2)
zoom = Vector2(zoomlevel, zoomlevel)

BIN
libresprite/mulfok62-1x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.