live code session jul 15

This commit is contained in:
OddlyTimbot 2024-07-15 21:10:20 -04:00
parent 1fe2c0d703
commit e123f67eae
22 changed files with 593 additions and 42 deletions

View File

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

View File

@ -0,0 +1,175 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-53.4626, -32.546),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 3.7755
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 15.0,
"scale_snap": 10.0,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 1.0,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])

View File

@ -0,0 +1,5 @@
[folding]
node_unfolds=[NodePath("."), PackedStringArray("Transform")]
resource_unfolds=["res://scenes/bullet.tscn::CircleShape2D_1gtqp", PackedStringArray()]
nodes_folded=[]

View File

@ -0,0 +1,175 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-105.112, -79.4505),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 4.23785
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 15.0,
"scale_snap": 10.0,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 1.0,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])

View File

@ -0,0 +1,5 @@
[folding]
node_unfolds=[]
resource_unfolds=["res://scenes/character.tscn::CircleShape2D_ubfw4", PackedStringArray()]
nodes_folded=[]

View File

@ -0,0 +1,4 @@
Node2D
CollisionShape2D
Area2D
RayCast2D

View File

@ -4,7 +4,7 @@ dock_1_selected_tab_idx=0
dock_2_selected_tab_idx=0
dock_3_selected_tab_idx=0
dock_4_selected_tab_idx=0
dock_5_selected_tab_idx=0
dock_5_selected_tab_idx=1
dock_6_selected_tab_idx=0
dock_7_selected_tab_idx=0
dock_8_selected_tab_idx=0
@ -19,24 +19,25 @@ dock_filesystem_split=0
dock_filesystem_display_mode=0
dock_filesystem_file_sort=0
dock_filesystem_file_list_display_mode=1
dock_filesystem_selected_paths=PackedStringArray("res://scripts/CharacterBody2D.gd")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/")
dock_filesystem_selected_paths=PackedStringArray("res://scenes/bullet.tscn")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/")
dock_3="Scene,Import"
dock_4="FileSystem"
dock_5="Inspector,Node,History"
[EditorNode]
open_scenes=PackedStringArray("res://scenes/game.tscn")
current_scene="res://scenes/game.tscn"
open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn")
current_scene="res://scenes/bullet.tscn"
center_split_offset=0
selected_default_debugger_tab_idx=0
selected_main_editor_idx=2
selected_bottom_panel_item=0
[ScriptEditor]
open_scripts=["res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
selected_script="res://scripts/CharacterBody2D.gd"
open_scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
selected_script="res://scripts/bullet.gd"
open_help=[]
script_split_offset=70
list_split_offset=0

View File

@ -1,9 +1,9 @@
ea4bc82a6ad023ab7ee23ee620429895
::res://::1721079768
icon.svg::CompressedTexture2D::9114977118871582245::1721079553::1721079768::1::::<><>::
::res://scenes/::1721079553
game.tscn::PackedScene::1738196330916037717::1721079553::0::1::::<><>::res://scripts/gamecontroller.gd<>res://scripts/CharacterBody2D.gd<>res://scripts/Trigger.gd
::res://scripts/::1721079553
CharacterBody2D.gd::GDScript::-1::1721079553::0::1::::<>CharacterBody2D<>::
gamecontroller.gd::GDScript::-1::1721079553::0::1::::<>Node2D<>::
Trigger.gd::GDScript::-1::1721079553::0::1::::<>Area2D<>::
::res://::1721083613
icon.svg::CompressedTexture2D::9114977118871582245::1721083376::1721083376::1::::<><>::
::res://scenes/::1721083376
game.tscn::PackedScene::1738196330916037717::1721083376::0::1::::<><>::res://scripts/gamecontroller.gd<>res://scripts/CharacterBody2D.gd<>res://scripts/Trigger.gd
::res://scripts/::1721083376
CharacterBody2D.gd::GDScript::-1::1721083376::0::1::::<>CharacterBody2D<>::
gamecontroller.gd::GDScript::-1::1721083376::0::1::::<>Node2D<>::
Trigger.gd::GDScript::-1::1721083376::0::1::::<>Area2D<>::

View File

@ -1,2 +1,5 @@
res://scenes/game.tscn
res://scripts/CharacterBody2D.gd
res://scenes/character.tscn
res://scripts/bullet.gd
res://scenes/bullet.tscn

View File

@ -8,7 +8,7 @@ Anim={
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-165, -110),
"ofs": Vector2(-452.67, -210.078),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
@ -32,7 +32,7 @@ Anim={
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 1.0
"zoom": 0.707107
}
3D={
"fov": 70.01,
@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([])
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])

View File

@ -1,5 +1,5 @@
[folding]
node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("StaticBody2D"), PackedStringArray("Transform"), NodePath("RigidBody2D"), PackedStringArray("Transform"), NodePath("RigidBody2D/CollisionShape2D"), PackedStringArray("Transform"), NodePath("RigidBody2D/CollisionShape2D2"), PackedStringArray("Transform"), NodePath("groundblock"), PackedStringArray("Transform"), NodePath("groundblock/CollisionShape2D"), PackedStringArray("Transform"), NodePath("groundblock2"), PackedStringArray("Transform"), NodePath("groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock2"), PackedStringArray("Transform"), NodePath("level/groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock3"), PackedStringArray("Transform"), NodePath("level/groundblock3/CollisionShape2D"), PackedStringArray("Transform"), NodePath("CharacterBody2D"), PackedStringArray("Transform", "Collision"), NodePath("Area2D"), PackedStringArray("Transform")]
resource_unfolds=["res://scenes/game.tscn::WorldBoundaryShape2D_3u4a8", PackedStringArray("Resource"), "res://scenes/game.tscn::RectangleShape2D_4vo4d", PackedStringArray("Resource"), "res://scenes/game.tscn::RectangleShape2D_cq7kj", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_ubfw4", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_x8qck", PackedStringArray("Resource")]
node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("StaticBody2D"), PackedStringArray("Transform"), NodePath("RigidBody2D"), PackedStringArray("Transform"), NodePath("RigidBody2D/CollisionShape2D"), PackedStringArray("Transform"), NodePath("RigidBody2D/CollisionShape2D2"), PackedStringArray("Transform"), NodePath("groundblock"), PackedStringArray("Transform"), NodePath("groundblock/CollisionShape2D"), PackedStringArray("Transform"), NodePath("groundblock2"), PackedStringArray("Transform"), NodePath("groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock2"), PackedStringArray("Transform"), NodePath("level/groundblock2/CollisionShape2D"), PackedStringArray("Transform"), NodePath("level/groundblock3"), PackedStringArray("Transform"), NodePath("level/groundblock3/CollisionShape2D"), PackedStringArray("Transform"), NodePath("Area2D"), PackedStringArray("Transform")]
resource_unfolds=["res://scenes/game.tscn::WorldBoundaryShape2D_3u4a8", PackedStringArray("Resource"), "res://scenes/game.tscn::RectangleShape2D_4vo4d", PackedStringArray("Resource"), "res://scenes/game.tscn::RectangleShape2D_cq7kj", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_x8qck", PackedStringArray("Resource")]
nodes_folded=[]

View File

@ -1,17 +1,38 @@
[editor_metadata]
executable_path="/home/timbot/Documents/Software/godot/Godot_v4.2.1-stable_linux.x86_64"
use_advanced_connections=false
[debug_options]
run_live_debug=true
run_reload_scripts=true
run_debug_collisions=true
[recent_files]
scenes=["res://scenes/game.tscn"]
scripts=["res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
scenes=["res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn"]
scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
[linked_properties]
Node2D:scale=true
StaticBody2D:scale=true
CharacterBody2D:scale=true
CollisionShape2D:scale=true
RigidBody2D:scale=true
RayCast2D:scale=true
Area2D:scale=true
[dialog_bounds]
create_new_node=Rect2(510, 190, 900, 700)
project_settings=Rect2(510, 190, 900, 700)
[color_picker]
recent_presets=PackedColorArray(0.616312, 0.404074, 0.899578, 0.42, 0.720388, 0.338613, 0.856219, 0.42)
[script_setup]
last_selected_language="GDScript"

View File

@ -0,0 +1,2 @@
res://scripts
res://scenes

View File

@ -17,10 +17,24 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 6,
"column": 52,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 3,
"row": 47,
"scroll_position": 30.0,
"selection": false,
"syntax_highlighter": "GDScript"
}
[res://scripts/bullet.gd]
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 14,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 13,
"scroll_position": 0.0,
"selection": false,
"syntax_highlighter": "GDScript"

View File

@ -22,3 +22,16 @@ folder_colors={
"res://scenes/": "yellow",
"res://scripts/": "red"
}
[input]
push={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":120,"echo":false,"script":null)
]
}
shoot={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
]
}

View File

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=3 uid="uid://c5bftwgkssaf2"]
[ext_resource type="Script" path="res://scripts/bullet.gd" id="1_t2eet"]
[sub_resource type="CircleShape2D" id="CircleShape2D_1gtqp"]
radius = 6.0
[node name="Area2D" type="Area2D"]
script = ExtResource("1_t2eet")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_1gtqp")
debug_color = Color(0.721569, 0.337255, 0.854902, 0.419608)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -0,0 +1,28 @@
[gd_scene load_steps=3 format=3 uid="uid://go4yc8hfo1gq"]
[ext_resource type="Script" path="res://scripts/CharacterBody2D.gd" id="1_x87yo"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ubfw4"]
radius = 13.0384
[node name="CharacterBody2D" type="CharacterBody2D"]
position = Vector2(-1, 0)
script = ExtResource("1_x87yo")
JUMP_VELOCITY = -500.0
PUSH_FORCE = 200
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_ubfw4")
[node name="RightRay" type="RayCast2D" parent="."]
target_position = Vector2(25, 0)
[node name="LeftRay" type="RayCast2D" parent="."]
target_position = Vector2(-25, 0)
[node name="MarkerRight" type="Node2D" parent="."]
position = Vector2(16, -6)
[node name="MarkerLeft" type="Node2D" parent="."]
position = Vector2(-16, -6)

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=9 format=3 uid="uid://y083suj12rld"]
[gd_scene load_steps=8 format=3 uid="uid://y083suj12rld"]
[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"]
[ext_resource type="Script" path="res://scripts/CharacterBody2D.gd" id="1_u4sui"]
[ext_resource type="PackedScene" uid="uid://go4yc8hfo1gq" path="res://scenes/character.tscn" id="2_64ccm"]
[ext_resource type="Script" path="res://scripts/Trigger.gd" id="2_nfj1w"]
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_3u4a8"]
@ -12,9 +12,6 @@ size = Vector2(55, 55)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_cq7kj"]
size = Vector2(91, 20)
[sub_resource type="CircleShape2D" id="CircleShape2D_ubfw4"]
radius = 13.0384
[sub_resource type="CircleShape2D" id="CircleShape2D_x8qck"]
radius = 60.2993
@ -28,9 +25,10 @@ metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("WorldBoundaryShape2D_3u4a8")
[node name="RigidBody2D" type="RigidBody2D" parent="."]
position = Vector2(87, 18)
[node name="RigidBody2D" type="RigidBody2D" parent="." groups=["boxes"]]
position = Vector2(139, 35)
rotation = 0.740513
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
position = Vector2(206.535, 208.174)
@ -44,8 +42,25 @@ rotation = -0.555892
shape = SubResource("RectangleShape2D_4vo4d")
debug_color = Color(0.815686, 0.4, 0.207843, 0.419608)
[node name="RigidBody2D2" type="RigidBody2D" parent="." groups=["boxes"]]
position = Vector2(409, -6)
rotation = 0.740513
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D2"]
position = Vector2(206.535, 208.174)
rotation = -0.555892
shape = SubResource("RectangleShape2D_4vo4d")
debug_color = Color(0.815686, 0.4, 0.207843, 0.419608)
[node name="CollisionShape2D2" type="CollisionShape2D" parent="RigidBody2D2"]
position = Vector2(206.535, 208.174)
rotation = -0.555892
shape = SubResource("RectangleShape2D_4vo4d")
debug_color = Color(0.815686, 0.4, 0.207843, 0.419608)
[node name="groundblock" type="StaticBody2D" parent="."]
position = Vector2(124, 357)
position = Vector2(117, 384)
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="groundblock"]
@ -79,13 +94,8 @@ metadata/_edit_group_ = true
position = Vector2(-1.5, 0)
shape = SubResource("RectangleShape2D_cq7kj")
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
position = Vector2(155, 328)
script = ExtResource("1_u4sui")
metadata/_edit_group_ = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
shape = SubResource("CircleShape2D_ubfw4")
[node name="CharacterBody2D" parent="." groups=["player"] instance=ExtResource("2_64ccm")]
PUSH_FORCE = 550
[node name="Area2D" type="Area2D" parent="."]
position = Vector2(260, 352)

View File

@ -1,8 +1,22 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -300.0
@export var SPEED = 300.0
@export var JUMP_VELOCITY = -300.0
@export var BUMP_FORCE = 80.0
@export var PUSH_FORCE = 750
@onready var right_ray = $RightRay
@onready var left_ray = $LeftRay
@onready var marker_right = $MarkerRight
@onready var marker_left = $MarkerLeft
var faceLeft = false
var pushLeftEnabled = false
var pushRightEnabled = false
var pushTarget
var bullet = preload("res://scenes/bullet.tscn")
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
@ -15,13 +29,62 @@ func _physics_process(delta):
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Hand force push (melee attack)
if Input.is_action_just_pressed("push") && pushRightEnabled && faceLeft == false:
print("I should force push")
pushTarget.apply_central_impulse(Vector2(1,0) * PUSH_FORCE * 10)
pushRightEnabled = false
if Input.is_action_just_pressed("push") && pushLeftEnabled:
pushTarget.apply_central_impulse(Vector2(-1,0) * PUSH_FORCE * 10)
pushLeftEnabled = false
if Input.is_action_just_pressed("shoot"):
#make a bullet
var myBullet = bullet.instantiate()
#set bullet speed?
#put the bullet at the Marker
owner.add_child(myBullet)
myBullet.transform = marker_right.global_transform
pass
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction <0:
faceLeft = true
if direction >0:
faceLeft = false
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
if right_ray.is_colliding():
print("right ray is colliding")
var collider = right_ray.get_collider()
#what did we hit?
if collider is Node:
if collider.is_in_group("boxes"):
print("This is a pushable box")
pushRightEnabled = true
pushTarget = collider
else:
pushRightEnabled = false
if left_ray.is_colliding():
print("left ray is colliding")
var collider = left_ray.get_collider()
if collider is Node:
if collider.is_in_group("boxes"):
pushLeftEnabled = true
pushTarget = collider
else:
pushLeftEnabled = false
#loop through the collisions
for i in get_slide_collision_count():
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal()* BUMP_FORCE)

View File

@ -0,0 +1,14 @@
extends Area2D
var speed = 750
func setSpeed(speedVal):
speed = speedVal
func _physics_process(delta):
position += transform.x * speed * delta
func _on_body_entered(body):
print("bullet hit something")
if not body.is_in_group("player"):
queue_free()