Compare commits
3 commits
3e1f962a7c
...
8162b33c7d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8162b33c7d | ||
|
|
528a8ee453 | ||
| 3aa1fe5a3b |
7 changed files with 67 additions and 36 deletions
16
Scenes/Levels/test.tscn
Normal file
16
Scenes/Levels/test.tscn
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[gd_scene format=4 uid="uid://croa7q6fdkfup"]
|
||||
|
||||
[ext_resource type="TileSet" uid="uid://bxbrytgrtnaie" path="res://Sprites/Tile Sets/main.tres" id="1_4te2q"]
|
||||
[ext_resource type="Script" uid="uid://c1x6111kr1dqa" path="res://Scripts/Levels/test.gd" id="1_q1p36"]
|
||||
[ext_resource type="PackedScene" uid="uid://syx6ov00a585" path="res://Scenes/player.tscn" id="2_q1p36"]
|
||||
|
||||
[node name="Main" type="Node2D" unique_id=441925255]
|
||||
script = ExtResource("1_q1p36")
|
||||
|
||||
[node name="TileMapLayer" type="TileMapLayer" parent="." unique_id=1288252359]
|
||||
position = Vector2(1, 0)
|
||||
tile_map_data = PackedByteArray("AAADAAgAAAAAAAEAAAAEAAgAAAAAAAEAAAAFAAgAAAAAAAEAAAAGAAgAAAAAAAEAAAAHAAgAAAAAAAEAAAALAAgAAAAAAAEAAAALAAUAAAAAAAEAAAALAAYAAAAAAAEAAAALAAcAAAAAAAEAAAALAAQAAAAAAAEAAAACAAQAAAAAAAEAAAACAAUAAAAAAAEAAAACAAYAAAAAAAEAAAACAAcAAAAAAAEAAAACAAgAAAAAAAEAAAAHAAkAAAAAAAEAAAAHAAoAAAAAAAEAAAAHAAsAAAAAAAEAAAAHAAwAAAAAAAEAAAAIAAwAAAAAAAEAAAAJAAwAAAAAAAEAAAAKAAwAAAAAAAEAAAALAAwAAAAAAAEAAAAMAAwAAAAAAAEAAAANAAwAAAAAAAEAAAAOAAwAAAAAAAEAAAAMAAgAAAAAAAEAAAANAAgAAAAAAAEAAAAOAAgAAAAAAAEAAAAPAAwAAAAAAAEAAAAQAAwAAAAAAAEAAAAQAAsAAAAAAAEAAAAQAAoAAAAAAAEAAAAQAAkAAAAAAAEAAAAQAAgAAAAAAAEAAAAPAAgAAAAAAAEAAAAIAAgAAAACAAEAAAAJAAgAAAACAAEAAAAKAAgAAAACAAEAAAAJAAEAAAABAAIAAAA=")
|
||||
tile_set = ExtResource("1_4te2q")
|
||||
|
||||
[node name="Player" parent="." unique_id=791571 instance=ExtResource("2_q1p36")]
|
||||
position = Vector2(56, 119)
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://syx6ov00a585"]
|
||||
[gd_scene format=3 uid="uid://syx6ov00a585"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ohb2t6o7wr1u" path="res://Scripts/player.gd" id="1_cvnsp"]
|
||||
[ext_resource type="Texture2D" uid="uid://btqnhg54e1p66" path="res://Sprites/png/spritesheet.png" id="2_6t5aa"]
|
||||
|
|
@ -9,31 +9,31 @@
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jjgbg"]
|
||||
size = Vector2(16, 16)
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
[node name="Player" type="CharacterBody2D" unique_id=178862163]
|
||||
script = ExtResource("1_cvnsp")
|
||||
|
||||
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
|
||||
[node name="GPUParticles2D" type="GPUParticles2D" parent="." unique_id=1770667535]
|
||||
emitting = false
|
||||
amount = 100
|
||||
lifetime = 3.3699999999999997
|
||||
process_material = ExtResource("2_vgqql")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
[node name="Sprite" type="Sprite2D" parent="." unique_id=2108867379]
|
||||
texture = ExtResource("2_6t5aa")
|
||||
hframes = 3
|
||||
vframes = 3
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=2085434834]
|
||||
shape = SubResource("RectangleShape2D_jjgbg")
|
||||
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=1070217901]
|
||||
rect = Rect2(-8, -8, 16, 16)
|
||||
|
||||
[node name="Camera" type="Camera2D" parent="."]
|
||||
[node name="Camera" type="Camera2D" parent="." unique_id=915178662]
|
||||
top_level = true
|
||||
script = ExtResource("4_vgqql")
|
||||
|
||||
[node name="SceneTransitionRect" parent="." instance=ExtResource("5_fkybt")]
|
||||
[node name="SceneTransitionRect" parent="." unique_id=726492614 instance=ExtResource("5_fkybt")]
|
||||
offset_left = -5000.0
|
||||
offset_top = -5000.0
|
||||
offset_right = 5000.0
|
||||
|
|
|
|||
14
Scripts/Levels/test.gd
Normal file
14
Scripts/Levels/test.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
extends Node2D
|
||||
|
||||
@onready var tile_layer : TileMapLayer = $TileMapLayer
|
||||
|
||||
var startPosX : int = 56
|
||||
var startPosY : int = 120
|
||||
|
||||
var next_level : String = "res://Scenes/main.tscn"
|
||||
|
||||
func event():
|
||||
tile_layer.set_cell(Vector2i(3,7), 0, Vector2i(2,0), 0)
|
||||
tile_layer.erase_cell(Vector2i(8,8))
|
||||
tile_layer.erase_cell(Vector2i(9,8))
|
||||
tile_layer.erase_cell(Vector2i(10,8))
|
||||
1
Scripts/Levels/test.gd.uid
Normal file
1
Scripts/Levels/test.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c1x6111kr1dqa
|
||||
|
|
@ -13,8 +13,14 @@ extends CharacterBody2D
|
|||
|
||||
var move_input : float
|
||||
var dead : bool
|
||||
var tile_map_custom_data = []
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
#Loads in all of the custom tile data from the Tile Map Layer.
|
||||
for i in range(tile_layer.tile_set.get_custom_data_layers_count()):
|
||||
tile_map_custom_data.append(tile_layer.tile_set.get_custom_data_layer_name(i))
|
||||
|
||||
#Triggers fade in animation, and then triggers respawn script.
|
||||
transition_rect.fade_in()
|
||||
respawn()
|
||||
|
|
@ -38,7 +44,7 @@ func _physics_process(delta: float) -> void:
|
|||
velocity.x += al_globals.x_gravity * delta
|
||||
|
||||
#Gravity flip.
|
||||
if Input.is_action_just_pressed("flip") and (is_on_floor() or is_on_ceiling()):
|
||||
if Input.is_action_just_pressed("flip") and (is_on_floor() or is_on_ceiling() or is_on_wall()):
|
||||
al_globals.y_gravity *= -1
|
||||
|
||||
#If the player is moving downwards fast, turn on particles. Otherwise, disable them.
|
||||
|
|
@ -58,30 +64,26 @@ func tilemap_detection() -> void:
|
|||
var tile_coord = tile_layer.local_to_map(tile_layer.to_local(global_position))
|
||||
var tile_data = tile_layer.get_cell_tile_data(tile_coord)
|
||||
|
||||
if not tile_data:
|
||||
return
|
||||
|
||||
#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:
|
||||
|
||||
#Checks for spikes.
|
||||
var spike_data = tile_data.get_custom_data("spike")
|
||||
if spike_data == true:
|
||||
for x in tile_map_custom_data:
|
||||
if tile_data.get_custom_data(x) == true:
|
||||
match x:
|
||||
"spike":
|
||||
death(false)
|
||||
|
||||
#Checks for exits.
|
||||
var exit_data = tile_data.get_custom_data("exit")
|
||||
if exit_data == true:
|
||||
next_level(current_level.next_level) #Pulls next level data from parent Node2D.
|
||||
|
||||
var left_grav_data = tile_data.get_custom_data("left_grav")
|
||||
if left_grav_data:
|
||||
"exit":
|
||||
next_level(current_level.next_level)
|
||||
"event":
|
||||
current_level.event()
|
||||
"left_grav":
|
||||
al_globals.x_gravity = al_globals.gravity * -5
|
||||
|
||||
var right_grav_data = tile_data.get_custom_data("right_grav")
|
||||
if right_grav_data:
|
||||
al_globals.x_gravity = al_globals.gravity * 5
|
||||
|
||||
var canc_grav_data = tile_data.get_custom_data("canc_grav")
|
||||
if canc_grav_data:
|
||||
"right_grav":
|
||||
al_globals.x_gravity = al_globals.gravity * 15
|
||||
"canc_grav":
|
||||
al_globals.x_gravity = 0
|
||||
al_globals.y_gravity = al_globals.gravity
|
||||
|
||||
#Facilitates the death of the player.
|
||||
func death(fallen: bool) -> void:
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@ extends Camera2D
|
|||
|
||||
@export var camera_speed : float = 6.0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta: float) -> void:
|
||||
position.x = lerp(position.x, player.position.x, camera_speed * delta)
|
||||
position.y = lerp(position.y, player.position.y, camera_speed * delta)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue