Compare commits

...

3 Commits

Author SHA1 Message Date
60ee655001 Gonna call it on the camera stuff for now. 2025-04-05 08:05:53 -07:00
ae43827c28 invisible collission shape 2025-04-04 18:43:27 -07:00
c8e9a93ffe Rename camera body, tweak collissions 2025-04-04 18:08:38 -07:00
8 changed files with 54 additions and 20 deletions

View File

@ -1,11 +1,12 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://src/actors/players/playerE/PlayerE.tscn" type="PackedScene" id=1] [ext_resource path="res://src/actors/players/playerE/PlayerE.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=2] [ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=3] [ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4] [ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/camera_control.gd" type="Script" id=5] [ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=5]
[ext_resource path="res://src/game_camera.gd" type="Script" id=6] [ext_resource path="res://src/Camera2D.gd" type="Script" id=6]
[ext_resource path="res://src/Main.gd" type="Script" id=7]
[sub_resource type="Shader" id=2] [sub_resource type="Shader" id=2]
code = "shader_type canvas_item; code = "shader_type canvas_item;
@ -24,6 +25,7 @@ shader_param/cam_offset = Vector2( 0, 0 )
extents = Vector2( 160, 90 ) extents = Vector2( 160, 90 )
[node name="Main" type="Node2D"] [node name="Main" type="Node2D"]
script = ExtResource( 7 )
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."] [node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
@ -50,18 +52,19 @@ position = Vector2( 112, 56 )
[node name="UI_Layer" parent="ViewportContainer/Viewport" instance=ExtResource( 3 )] [node name="UI_Layer" parent="ViewportContainer/Viewport" instance=ExtResource( 3 )]
[node name="KinematicBody2D" type="KinematicBody2D" parent="ViewportContainer/Viewport"] [node name="CameraGuide" type="KinematicBody2D" parent="ViewportContainer/Viewport"]
position = Vector2( 160, 90 ) position = Vector2( 160, 90 )
collision_layer = 0 collision_layer = 0
collision_mask = 256 collision_mask = 256
collision/safe_margin = 0.25
script = ExtResource( 5 ) script = ExtResource( 5 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/KinematicBody2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="ViewportContainer/Viewport/CameraGuide"]
visible = false
shape = SubResource( 1 ) shape = SubResource( 1 )
one_way_collision = true
[node name="Camera2D" type="Camera2D" parent="ViewportContainer/Viewport"] [node name="Camera2D" type="Camera2D" parent="ViewportContainer/Viewport"]
position = Vector2( 160, 90 ) position = Vector2( 160, 90 )
current = true current = true
script = ExtResource( 6 ) script = ExtResource( 6 )
tracking_node_path = NodePath("../KinematicBody2D") tracking_node_path = NodePath("../CameraGuide")

View File

@ -11,6 +11,7 @@ onready var current_music_track :AudioStream
onready var viewport_container = get_node("/root/Main/ViewportContainer") #$ViewportContainer onready var viewport_container = get_node("/root/Main/ViewportContainer") #$ViewportContainer
onready var viewport = get_node("/root/Main/ViewportContainer/Viewport") # $ViewportContainer/Viewport onready var viewport = get_node("/root/Main/ViewportContainer/Viewport") # $ViewportContainer/Viewport
onready var camera_guide :CameraGuide = get_node("/root/Main/ViewportContainer/Viewport/CameraGuide")
func change_music_track(_music_track :AudioStream ): func change_music_track(_music_track :AudioStream ):
if current_music_track != _music_track: if current_music_track != _music_track:
@ -36,9 +37,11 @@ func change_level(_level_name :String, _position_name :String):
#var simultaneous_scene = preload("res://levels/level2.tscn").instance() #var simultaneous_scene = preload("res://levels/level2.tscn").instance()
var new_level = load("res://src/levels/" + _level_name + ".tscn" ).instance() var new_level = load("res://src/levels/" + _level_name + ".tscn" ).instance()
#print (get_tree().get_root().get_children()) #print (get_tree().get_root().get_children())
for l in get_node("/root/Main/ViewportContainer/Viewport").get_children(): for l in get_node("/root/Main/ViewportContainer/Viewport").get_children():
#print (get_node("/root/Main").get_children()) #print (get_node("/root/Main").get_children())
if l is Level: if l is Level:
camera_guide.disable_tracking()
SceneTransition.transition_dissolve("foo") SceneTransition.transition_dissolve("foo")
yield(SceneTransition,"done") yield(SceneTransition,"done")
print(l) print(l)
@ -49,7 +52,10 @@ func change_level(_level_name :String, _position_name :String):
if new_level.entrances.has(_position_name): if new_level.entrances.has(_position_name):
player_start_position = new_level.entrances[_position_name].transform.origin player_start_position = new_level.entrances[_position_name].transform.origin
print (get_node("/root/Main/ViewportContainer/Viewport").get_children()) print (get_node("/root/Main/ViewportContainer/Viewport").get_children())
#get_node("/root/Main/ViewportContainer/Viewport/CameraGuide").global_position = Vector2(160,90)
SceneTransition.reset() SceneTransition.reset()
camera_guide.transform.origin = Vector2(160,90)
camera_guide.enable_tracking()
#get_node("/root/Main").add_child_below_node(SceneTransition,new_level) #get_node("/root/Main").add_child_below_node(SceneTransition,new_level)

View File

@ -24,6 +24,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://lib/classes/audiostreamplayer_state_receiver.gd" "path": "res://lib/classes/audiostreamplayer_state_receiver.gd"
}, { }, {
"base": "KinematicBody2D",
"class": "CameraGuide",
"language": "GDScript",
"path": "res://src/classes/camera_guide.gd"
}, {
"base": "", "base": "",
"class": "GitAPI", "class": "GitAPI",
"language": "NativeScript", "language": "NativeScript",
@ -118,6 +123,7 @@ _global_script_class_icons={
"Actor": "", "Actor": "",
"AnimatedSprite_StateReceiver": "", "AnimatedSprite_StateReceiver": "",
"AudioStreamPlayer_StateReceiver": "", "AudioStreamPlayer_StateReceiver": "",
"CameraGuide": "",
"GitAPI": "", "GitAPI": "",
"HealthComponent": "", "HealthComponent": "",
"HealthPickup": "", "HealthPickup": "",

View File

@ -1,21 +1,15 @@
[gd_resource type="SpriteFrames" load_steps=6 format=2] [gd_resource type="SpriteFrames" load_steps=5 format=2]
[ext_resource path="res://assets/quick_health.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1] [sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 15, 13 ) region = Rect2( 0, 0, 15, 13 )
[sub_resource type="AtlasTexture" id=2] [sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 15, 0, 15, 13 ) region = Rect2( 15, 0, 15, 13 )
[sub_resource type="AtlasTexture" id=3] [sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 30, 0, 15, 13 ) region = Rect2( 30, 0, 15, 13 )
[sub_resource type="AtlasTexture" id=4] [sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 45, 0, 15, 13 ) region = Rect2( 45, 0, 15, 13 )
[resource] [resource]

17
src/Main.gd Normal file
View File

@ -0,0 +1,17 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
export var starting_level: PackedScene
# 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

View File

@ -1,3 +1,4 @@
class_name CameraGuide
extends KinematicBody2D extends KinematicBody2D
@ -7,11 +8,19 @@ extends KinematicBody2D
var game_size := Vector2(320,180) var game_size := Vector2(320,180)
onready var window_scale :float = (OS.window_size / game_size).x onready var window_scale :float = (OS.window_size / game_size).x
var _is_tracking :bool = true
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
func enable_tracking() -> void:
##TODO: add extra collission checks here to make sure we aren't stuck maybe?
_is_tracking = true
func disable_tracking() -> void:
_is_tracking = false
var flip_tracker = 0.0 var flip_tracker = 0.0
var stuck_check: bool var stuck_check: bool
func _physics_process(delta): func _physics_process(delta):

View File

@ -20,7 +20,6 @@ extents = Vector2( 8, 40 )
points = PoolVector2Array( 20, 20, 0.326027, 20, 0.326027, 0.605103, 20, 0.605103 ) points = PoolVector2Array( 20, 20, 0.326027, 20, 0.326027, 0.605103, 20, 0.605103 )
[sub_resource type="TileSet" id=4] [sub_resource type="TileSet" id=4]
resource_name = "NoCam"
0/name = "no_cam_tile.png 0" 0/name = "no_cam_tile.png 0"
0/texture = ExtResource( 6 ) 0/texture = ExtResource( 6 )
0/tex_offset = Vector2( 0, 0 ) 0/tex_offset = Vector2( 0, 0 )
@ -63,15 +62,15 @@ position = Vector2( 80, 131 )
damage_amount = 10 damage_amount = 10
[node name="ColorRect" type="ColorRect" parent="Hitbox_Component" index="0"] [node name="ColorRect" type="ColorRect" parent="Hitbox_Component" index="0"]
margin_left = 263.0 margin_left = 266.0
margin_top = 115.0 margin_top = 90.0
margin_right = 273.0 margin_right = 276.0
margin_bottom = 124.0 margin_bottom = 99.0
color = Color( 1, 0, 0, 1 ) color = Color( 1, 0, 0, 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="1"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="1"]
modulate = Color( 1, 0, 0, 1 ) modulate = Color( 1, 0, 0, 1 )
position = Vector2( 268, 119 ) position = Vector2( 271, 94 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="LevelTransition" parent="." index="5" instance=ExtResource( 4 )] [node name="LevelTransition" parent="." index="5" instance=ExtResource( 4 )]