Added in exit and event sprites in tilemap. Added in custom data in TileMapLayer for them, and created Level 1.
This commit is contained in:
parent
f36522f1a8
commit
b3cfee5121
8 changed files with 70 additions and 29 deletions
15
Scenes/Levels/level_1.tscn
Normal file
15
Scenes/Levels/level_1.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
[gd_scene load_steps=4 format=4 uid="uid://c6aveiahox475"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bdoa8j4vedy8" path="res://Scripts/Levels/level_1.gd" id="1_3mqfk"]
|
||||||
|
[ext_resource type="TileSet" uid="uid://bxbrytgrtnaie" path="res://Sprites/Tile Sets/main.tres" id="2_iixi8"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://syx6ov00a585" path="res://Scenes/player.tscn" id="3_cyadu"]
|
||||||
|
|
||||||
|
[node name="Main" type="Node2D"]
|
||||||
|
script = ExtResource("1_3mqfk")
|
||||||
|
|
||||||
|
[node name="TileMapLayer" type="TileMapLayer" parent="."]
|
||||||
|
tile_map_data = PackedByteArray("AAABAAwAAAAAAAEAAAACAAwAAAAAAAEAAAADAAwAAAAAAAEAAAAEAAwAAAAAAAEAAAAFAAwAAAAAAAEAAAAGAAwAAAAAAAEAAAAHAAwAAAAAAAEAAAAIAAwAAAAAAAEAAAAJAAwAAAAAAAEAAAAKAAwAAAAAAAEAAAALAAwAAAAAAAEAAAAMAAwAAAAAAAEAAAANAAwAAAAAAAEAAAAOAAwAAAAAAAEAAAAPAAwAAAAAAAEAAAAQAAwAAAAAAAEAAAARAAwAAAAAAAEAAAASAAwAAAAAAAEAAAATAAwAAAAAAAEAAAAUAAwAAAAAAAEAAAAVAAwAAAAAAAEAAAAWAAwAAAAAAAEAAAAXAAwAAAAAAAEAAAAYAAwAAAAAAAEAAAAYAAsAAAACAAAAAAA=")
|
||||||
|
tile_set = ExtResource("2_iixi8")
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource("3_cyadu")]
|
||||||
|
position = Vector2(24, 184)
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -19,8 +19,8 @@ process_material = ExtResource("2_vgqql")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource("2_6t5aa")
|
texture = ExtResource("2_6t5aa")
|
||||||
hframes = 2
|
hframes = 3
|
||||||
vframes = 2
|
vframes = 3
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_jjgbg")
|
shape = SubResource("RectangleShape2D_jjgbg")
|
||||||
|
|
|
||||||
6
Scripts/Levels/level_1.gd
Normal file
6
Scripts/Levels/level_1.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
var startPosX : int = 24
|
||||||
|
var startPosY : int = 184
|
||||||
|
|
||||||
|
var next_level : String = "res://Scenes/main.tscn"
|
||||||
1
Scripts/Levels/level_1.gd.uid
Normal file
1
Scripts/Levels/level_1.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bdoa8j4vedy8
|
||||||
|
|
@ -17,8 +17,6 @@ func _ready() -> void:
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
print(velocity.y)
|
|
||||||
|
|
||||||
if dead == false:
|
if dead == false:
|
||||||
#Horizontal movement.
|
#Horizontal movement.
|
||||||
move_input = Input.get_axis("move_left", "move_right")
|
move_input = Input.get_axis("move_left", "move_right")
|
||||||
|
|
@ -39,9 +37,9 @@ func _physics_process(delta: float) -> void:
|
||||||
particles.emitting = false
|
particles.emitting = false
|
||||||
|
|
||||||
move_and_slide() #Allow physics control.
|
move_and_slide() #Allow physics control.
|
||||||
spike_detection() #Checks for tiles with the "Spike" custom data enabled.
|
tilemap_detection() #Checks for tiles with the "Spike" custom data enabled.
|
||||||
|
|
||||||
func spike_detection() -> void:
|
func tilemap_detection() -> void:
|
||||||
#Adapted from Godot forum post.
|
#Adapted from Godot forum post.
|
||||||
|
|
||||||
#Get current tile, and then put the data from it into a variable.
|
#Get current tile, and then put the data from it into a variable.
|
||||||
|
|
@ -50,10 +48,17 @@ func spike_detection() -> void:
|
||||||
|
|
||||||
#If it has data, check for it. If it has the "spike" custom data, ensure the gravity is set back to normal, and then reset the level.
|
#If it has data, check for it. If it has the "spike" custom data, ensure the gravity is set back to normal, and then reset the level.
|
||||||
if tile_data:
|
if tile_data:
|
||||||
var custom_data = tile_data.get_custom_data("spike")
|
|
||||||
if custom_data == true:
|
#Checks for spikes.
|
||||||
|
var spike_data = tile_data.get_custom_data("spike")
|
||||||
|
if spike_data == true:
|
||||||
death(false)
|
death(false)
|
||||||
|
|
||||||
|
#Checks for exits.
|
||||||
|
var exit_data = tile_data.get_custom_data("exit")
|
||||||
|
if exit_data == true:
|
||||||
|
get_tree().change_scene_to_file(level.next_level) #Pulls next level data from parent Node2D.
|
||||||
|
|
||||||
func death(fallen: bool) -> void:
|
func death(fallen: bool) -> void:
|
||||||
dead = true
|
dead = true
|
||||||
if !fallen:
|
if !fallen:
|
||||||
|
|
|
||||||
30
Sprites/Tile Sets/main.tres
Normal file
30
Sprites/Tile Sets/main.tres
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
[gd_resource type="TileSet" load_steps=3 format=3 uid="uid://bxbrytgrtnaie"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://btqnhg54e1p66" path="res://Sprites/png/spritesheet.png" id="1_tl1wk"]
|
||||||
|
|
||||||
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_bo1nx"]
|
||||||
|
texture = ExtResource("1_tl1wk")
|
||||||
|
0:0/0 = 0
|
||||||
|
0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
|
1:0/0 = 0
|
||||||
|
0:1/0 = 0
|
||||||
|
0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
|
||||||
|
1:1/0 = 0
|
||||||
|
1:1/0/custom_data_0 = true
|
||||||
|
0:2/0 = 0
|
||||||
|
1:2/0 = 0
|
||||||
|
2:2/0 = 0
|
||||||
|
2:1/0 = 0
|
||||||
|
2:1/0/custom_data_2 = true
|
||||||
|
2:0/0 = 0
|
||||||
|
2:0/0/custom_data_1 = true
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
physics_layer_0/collision_layer = 1
|
||||||
|
custom_data_layer_0/name = "spike"
|
||||||
|
custom_data_layer_0/type = 1
|
||||||
|
custom_data_layer_1/name = "exit"
|
||||||
|
custom_data_layer_1/type = 1
|
||||||
|
custom_data_layer_2/name = "event"
|
||||||
|
custom_data_layer_2/type = 1
|
||||||
|
sources/0 = SubResource("TileSetAtlasSource_bo1nx")
|
||||||
BIN
Sprites/png/spritesheet.png
(Stored with Git LFS)
BIN
Sprites/png/spritesheet.png
(Stored with Git LFS)
Binary file not shown.
Loading…
Add table
Reference in a new issue