initial project with first movements
This commit is contained in:
commit
77a13eb2c8
|
@ -0,0 +1,11 @@
|
|||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
|
@ -0,0 +1,12 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
|
||||
# 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
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://tileset_edit.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://Player.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="Grid" type="TileMap"]
|
||||
mode = 2
|
||||
tile_set = ExtResource( 1 )
|
||||
cell_custom_transform = Transform2D( 120, 0, -38, 82, 0, 0 )
|
||||
cell_y_sort = true
|
||||
format = 1
|
||||
tile_data = PoolIntArray( 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 65536, 0, 0, 65537, 0, 0, 65538, 0, 0, 65539, 0, 0, 65540, 0, 0, 65541, 0, 0, 65542, 0, 0, 65543, 0, 0, 131072, 0, 0, 131073, 0, 0, 131074, 0, 0, 131075, 0, 0, 131076, 0, 0, 131077, 0, 0, 131078, 0, 0, 131079, 0, 0, 196608, 0, 0, 196609, 0, 0, 196610, 0, 0, 196611, 0, 0, 196612, 0, 0, 196613, 0, 0, 196614, 0, 0, 196615, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 0, 0, 262147, 0, 0, 262148, 0, 0, 262149, 0, 0, 262150, 0, 0, 262151, 0, 0, 327680, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 327687, 0, 0, 393216, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 393223, 0, 0 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||
position = Vector2( 445, 205 )
|
||||
z_index = 1
|
||||
speed = 20
|
||||
tile_position = Vector2( 4, 2 )
|
||||
grid_path = NodePath("..")
|
|
@ -0,0 +1,81 @@
|
|||
tool
|
||||
extends Area2D
|
||||
|
||||
|
||||
export var speed = 1
|
||||
|
||||
export var tile_position := Vector2(0,0)
|
||||
export(NodePath) var grid_path
|
||||
|
||||
onready var grid = get_node(grid_path) as TileMap
|
||||
|
||||
class Movement:
|
||||
var action: String
|
||||
var direction: Vector2
|
||||
var animation: String
|
||||
|
||||
func _init(_action, _direction, _animation):
|
||||
action = _action
|
||||
direction = _direction
|
||||
animation = _animation
|
||||
|
||||
var movements = [
|
||||
Movement.new("ui_right", Vector2.RIGHT, "right"),
|
||||
Movement.new("ui_left", Vector2.LEFT, "left"),
|
||||
Movement.new("ui_up", Vector2.UP, "back"),
|
||||
Movement.new("ui_down", Vector2.DOWN, "front")
|
||||
]
|
||||
|
||||
var movement_queue = []
|
||||
var current_target = null
|
||||
onready var sprite = $AnimatedSprite as AnimatedSprite
|
||||
|
||||
func _process(delta):
|
||||
|
||||
|
||||
if Engine.editor_hint:
|
||||
|
||||
|
||||
if grid == null and not grid_path == "":
|
||||
|
||||
grid = get_node(grid_path) as TileMap
|
||||
|
||||
if grid != null:
|
||||
|
||||
tile_position.x = round(tile_position.x)
|
||||
tile_position.y = round(tile_position.y)
|
||||
|
||||
update_position()
|
||||
|
||||
else:
|
||||
|
||||
for movement in movements:
|
||||
if Input.is_action_just_pressed(movement.action):
|
||||
movement_queue.push_back(movement)
|
||||
|
||||
update_animation()
|
||||
|
||||
if not movement_queue.empty():
|
||||
|
||||
var current_movement : Movement = movement_queue.front()
|
||||
|
||||
if current_target == null:
|
||||
current_target = tile_position + current_movement.direction
|
||||
|
||||
tile_position += current_movement.direction * delta * speed
|
||||
|
||||
var remaining = current_target - tile_position
|
||||
|
||||
if remaining.dot(current_movement.direction) <= 0:
|
||||
tile_position = current_target
|
||||
current_target = null
|
||||
movement_queue.pop_front()
|
||||
|
||||
update_position()
|
||||
|
||||
|
||||
func update_position():
|
||||
position = grid.cell_custom_transform * (tile_position + Vector2.ONE / 2 )
|
||||
|
||||
func update_animation():
|
||||
sprite.animation = sprite.animation if movement_queue.empty() else movement_queue.front().animation
|
|
@ -0,0 +1,66 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://character.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Player.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 112, 210 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 224, 0, 112, 210 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 112, 0, 112, 210 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=6]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 336, 0, 112, 210 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 3 ) ],
|
||||
"loop": true,
|
||||
"name": "left",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 4 ) ],
|
||||
"loop": true,
|
||||
"name": "right",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 5 ) ],
|
||||
"loop": true,
|
||||
"name": "front",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 6 ) ],
|
||||
"loop": true,
|
||||
"name": "back",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 32.0
|
||||
height = 0.0
|
||||
|
||||
[node name="Player" type="Area2D"]
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
}
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 0, -96 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "front"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 0, -16 )
|
||||
shape = SubResource( 2 )
|
|
@ -0,0 +1,3 @@
|
|||
[gd_scene format=2]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/character.png-7a996d3b758d22c506b76a7c15391284.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://character.png"
|
||||
dest_files=[ "res://.import/character.png-7a996d3b758d22c506b76a7c15391284.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
Binary file not shown.
After Width: | Height: | Size: 665 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/floor_tiles.png-2b1a208298485d861b2a6e00e3280c84.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://floor_tiles.png"
|
||||
dest_files=[ "res://.import/floor_tiles.png-2b1a208298485d861b2a6e00e3280c84.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -0,0 +1,26 @@
|
|||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="CleaningEnby"
|
||||
run/main_scene="res://Grid.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
quality/driver/driver_name="GLES2"
|
||||
vram_compression/import_etc=true
|
||||
vram_compression/import_etc2=false
|
||||
environment/default_environment="res://default_env.tres"
|
|
@ -0,0 +1,19 @@
|
|||
[gd_resource type="TileSet" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://floor_tiles.png" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
0/name = "floor_tiles.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 30, 50, 160, 120 )
|
||||
0/tile_mode = 0
|
||||
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
|
Loading…
Reference in New Issue