diff --git a/.godot/editor/create_recent.Node b/.godot/editor/create_recent.Node index cd4ddbb..40a375f 100644 --- a/.godot/editor/create_recent.Node +++ b/.godot/editor/create_recent.Node @@ -1,10 +1,14 @@ +Timer +Area2D StaticBody2D +RigidBody2D +RayCast2D CollisionShape2D +Sprite2D +AnimatedSprite2D CharacterBody2D CollisionPolygon2D -Area2D AudioStreamPlayer AudioStreamPlayer2D AudioListener2D TileMap -AnimatedSprite2D diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg index 7d87251..f2032a7 100644 --- a/.godot/editor/editor_layout.cfg +++ b/.godot/editor/editor_layout.cfg @@ -7,7 +7,7 @@ dock_filesystem_file_list_display_mode=1 dock_split_2=0 dock_split_3=0 dock_hsplit_1=0 -dock_hsplit_2=309 +dock_hsplit_2=411 dock_hsplit_3=-353 dock_hsplit_4=0 dock_3="Scene,Import" @@ -16,11 +16,11 @@ dock_5="Inspector,Node,History" [EditorNode] -open_scenes=["res://test_level001.tscn", "res://Player/player.tscn"] +open_scenes=["res://test_level001.tscn", "res://Enemies/basic_enemy.tscn", "res://Player/player.tscn", "res://Weapons/basic_weapon.tscn", "res://Projectiles/basic_projectile.tscn"] [ScriptEditor] -open_scripts=["res://Player/player.gd"] -open_help=["CharacterBody2D", "Vector2"] +open_scripts=["res://Enemies/basic_enemy.gd", "res://Projectiles/basic_projectile.gd", "res://Weapons/basic_weapon.gd", "res://Player/player.gd"] +open_help=["Area2D", "CharacterBody2D", "Node2D", "RayCast2D", "RigidBody2D", "StaticBody2D", "Vector2"] script_split_offset=70 list_split_offset=0 diff --git a/.godot/editor/filesystem_cache7 b/.godot/editor/filesystem_cache7 index b5e24ad..f6dde0b 100644 --- a/.godot/editor/filesystem_cache7 +++ b/.godot/editor/filesystem_cache7 @@ -1,25 +1,29 @@ 0b7126e0c6e86d3ec295a72f5aa6e0bd -::res://::1673734830 -README.md::TextFile::-1::1673712834::0::1::::<><>:: -test_level001.tscn::PackedScene::278447013021769396::1673734812::0::1::::<><>::uid://b62h0w8gjm6tj<>uid://d3y4rna66nylu -::res://Levels/::1673726687 -level.tscn::PackedScene::4739050375457527030::1673726687::0::1::::<><>:: -::res://Music/::1673734693 -School_Bass.ogg::AudioStreamOggVorbis::8337090337929631753::1673734497::1673734693::1::::<><>:: -School_BDClave.ogg::AudioStreamOggVorbis::2352609159460477887::1673734497::1673734693::1::::<><>:: -School_Brass.ogg::AudioStreamOggVorbis::8423202159412100063::1673734497::1673734693::1::::<><>:: -School_Flute.ogg::AudioStreamOggVorbis::6100788483817358773::1673734497::1673734693::1::::<><>:: -School_Snare.ogg::AudioStreamOggVorbis::6764331197145035365::1673734497::1673734693::1::::<><>:: -::res://Player/::1673734812 -player.gd::GDScript::-1::1673734812::0::1::::<>CharacterBody2D<>:: -player.tscn::PackedScene::4618483906406103163::1673733616::0::1::::<><>::res://Player/player.gd<>uid://wkeakqjvu3gg -::res://Player/Projectiles/::1673734122 -basic_projectile.tscn::PackedScene::5856608848916302392::1673734122::0::1::::<><>:: -::res://Player/Weapons/::1673734452 -basic_weapon.tscn::PackedScene::5655575360493827386::1673734452::0::1::::<><>:: -::res://Sprites/::1673734432 -dingo_jam_mc_front_64.png::CompressedTexture2D::1565041755936548690::1673732299::1673732300::1::::<><>:: -pew.png::CompressedTexture2D::7577871081029115281::1673734362::1673734427::1::::<><>:: -projectile.png::CompressedTexture2D::13383739614235193::1673734403::1673734432::1::::<><>:: -::res://TileSets/::1673734812 -Tiles Set GameJam.png::CompressedTexture2D::9175886574582270754::1673734812::1673734812::1::::<><>:: +::res://::1673747350 +README.md::TextFile::-1::1673744149::0::1::::<><>:: +test_level001.tscn::PackedScene::278447013021769396::1673747296::0::1::::<><>::uid://xev8p1td1icx<>uid://d3y4rna66nylu<>uid://c661br4lh30r8 +::res://Enemies/::1673747296 +basic_enemy.gd::GDScript::-1::1673746722::0::1::::<>CharacterBody2D<>:: +basic_enemy.tscn::PackedScene::7014272596353446583::1673747296::0::1::::<><>::res://Enemies/basic_enemy.gd<>uid://ds4uvvrcxoay1 +::res://Levels/::1673744149 +level.tscn::PackedScene::4739050375457527030::1673744149::0::1::::<><>:: +::res://Music/::1673744196 +School_Bass.ogg::AudioStreamOggVorbis::8337090337929631753::1673744149::1673744196::1::::<><>:: +School_BDClave.ogg::AudioStreamOggVorbis::2352609159460477887::1673744149::1673744196::1::::<><>:: +School_Brass.ogg::AudioStreamOggVorbis::8423202159412100063::1673744149::1673744196::1::::<><>:: +School_Flute.ogg::AudioStreamOggVorbis::6100788483817358773::1673744149::1673744196::1::::<><>:: +School_Snare.ogg::AudioStreamOggVorbis::6764331197145035365::1673744149::1673744196::1::::<><>:: +::res://Player/::1673747350 +player.gd::GDScript::-1::1673746568::0::1::::<>CharacterBody2D<>:: +player.tscn::PackedScene::1623935731621421531::1673747296::0::1::::<><>::res://Player/player.gd<>uid://wkeakqjvu3gg +::res://Player/Weapons/::1673744149 +basic_weapon.tscn::PackedScene::5655575360493827386::1673744149::0::1::::<><>:: +::res://Projectiles/::1673744149 +basic_projectile.tscn::PackedScene::5856608848916302392::1673744149::0::1::::<><>:: +::res://Sprites/::1673744680 +placeholder_enemy.png::CompressedTexture2D::8483781162333137450::1673744660::1673744680::1::::<><>:: +placeholder_player.png::CompressedTexture2D::1565041755936548690::1673744149::1673744500::1::::<><>:: +placeholder_projectile.png::CompressedTexture2D::13383739614235193::1673744149::1673744515::1::::<><>:: +placeholder_weapon.png::CompressedTexture2D::7577871081029115281::1673744149::1673744508::1::::<><>:: +::res://TileSets/::1673744149 +Tiles Set GameJam.png::CompressedTexture2D::9175886574582270754::1673744149::1673744149::1::::<><>:: diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index 9b7db25..4d26e77 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -1,2 +1,9 @@ res://test_level001.tscn res://Player/player.tscn +res://Enemies/basic_enemy.tscn +res://Weapons/basic_weapon.tscn +res://Projectiles/basic_projectile.tscn +res://Enemies/basic_enemy.gd +res://Player/player.gd +res://Weapons/basic_weapon.gd +res://Projectiles/basic_projectile.gd diff --git a/.godot/editor/player.tscn-editstate-d267b47f7e81a3258979164d56d0d9c2.cfg b/.godot/editor/player.tscn-editstate-d267b47f7e81a3258979164d56d0d9c2.cfg index 683625d..6721ade 100644 --- a/.godot/editor/player.tscn-editstate-d267b47f7e81a3258979164d56d0d9c2.cfg +++ b/.godot/editor/player.tscn-editstate-d267b47f7e81a3258979164d56d0d9c2.cfg @@ -8,7 +8,7 @@ Anim={ "grid_snap_active": false, "grid_step": Vector2(8, 8), "grid_visibility": 1, -"ofs": Vector2(-834.444, -392.346), +"ofs": Vector2(-701.364, -383.398), "primary_grid_steps": 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": 0.707107 +"zoom": 1.0 } 3D={ "fov": 70.01, diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 7569532..a9ba87f 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -1,6 +1,6 @@ [editor_metadata] -executable_path="C:/Godot_v4.0-beta12_mono_win64/Godot_v4.0-beta12_mono_win64/Godot_v4.0-beta12_mono_win64.exe" +executable_path="/home/medenos/Downloads/Godot_v4.0-beta12_mono_linux_x86_64/Godot_v4.0-beta12_mono_linux.x86_64" tile_source_sort=0 use_advanced_connections=false @@ -11,8 +11,8 @@ run_reload_scripts=true [recent_files] -scenes=["res://Player/player.tscn", "res://test_level001.tscn", "res://player.tscn"] -scripts=["Vector2", "CharacterBody2D", "res://player.gd"] +scenes=["res://Projectiles/basic_projectile.tscn", "res://Enemies/basic_enemy.tscn", "res://Weapons/basic_weapon.tscn", "res://Player/player.tscn", "res://test_level001.tscn", "res://Enemies/basic_enemie.tscn", "res://player.tscn"] +scripts=["RayCast2D", "Node2D", "Area2D", "StaticBody2D", "RigidBody2D", "res://Projectiles/basic_projectile.gd", "res://Weapons/basic_weapon.gd", "Vector2", "CharacterBody2D", "res://Enemies/basic_enemy.gd"] [script_setup] @@ -20,7 +20,7 @@ last_selected_language="GDScript" [dialog_bounds] -project_settings=Rect2(510, 238, 900, 700) +project_settings=Rect2(3715, 147, 900, 700) [color_picker] diff --git a/.godot/editor/recent_dirs b/.godot/editor/recent_dirs index 1b075e9..aab7497 100644 --- a/.godot/editor/recent_dirs +++ b/.godot/editor/recent_dirs @@ -1,2 +1,3 @@ +res://Enemies res:// res://Levels diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index 3179c93..b7f09e1 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -3,11 +3,53 @@ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 0, +"column": 8, "folded_lines": [], "h_scroll_position": 0, -"row": 35, -"scroll_position": 13.0, +"row": 26, +"scroll_position": 5.0, +"selection": false, +"syntax_highlighter": "GDScript" +} + +[res://Enemies/basic_enemy.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 44, +"folded_lines": [], +"h_scroll_position": 0, +"row": 10, +"scroll_position": 0.0, +"selection": false, +"syntax_highlighter": "GDScript" +} + +[res://Weapons/basic_weapon.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 25, +"folded_lines": [], +"h_scroll_position": 0, +"row": 3, +"scroll_position": 0.0, +"selection": false, +"syntax_highlighter": "GDScript" +} + +[res://Projectiles/basic_projectile.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 23, +"folded_lines": [], +"h_scroll_position": 0, +"row": 3, +"scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" } diff --git a/.godot/editor/test_level001.tscn-editstate-4b15d5b2c95b81f0d5516148b6f1d415.cfg b/.godot/editor/test_level001.tscn-editstate-4b15d5b2c95b81f0d5516148b6f1d415.cfg index 44bd210..a8d5f26 100644 --- a/.godot/editor/test_level001.tscn-editstate-4b15d5b2c95b81f0d5516148b6f1d415.cfg +++ b/.godot/editor/test_level001.tscn-editstate-4b15d5b2c95b81f0d5516148b6f1d415.cfg @@ -8,7 +8,7 @@ Anim={ "grid_snap_active": false, "grid_step": Vector2(8, 8), "grid_visibility": 1, -"ofs": Vector2(-497.438, -331.178), +"ofs": Vector2(-835.537, -590.651), "primary_grid_steps": 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": 0.374577 +"zoom": 0.629961 } 3D={ "fov": 70.01, diff --git a/.godot/uid_cache.bin b/.godot/uid_cache.bin index f819e84..e272c08 100644 Binary files a/.godot/uid_cache.bin and b/.godot/uid_cache.bin differ diff --git a/Enemies/basic_enemy.gd b/Enemies/basic_enemy.gd new file mode 100644 index 0000000..0e4e7fe --- /dev/null +++ b/Enemies/basic_enemy.gd @@ -0,0 +1,52 @@ +extends CharacterBody2D + +@export var MAX_SPEED = 300.0; +@export var ACCELERATION = 1000.0; +@export var FRICTION = 1500.0; +@export var HP = 1; +@export var DAMAGE = 1; +@export var COOLDOWN = 1; + +@onready var raycast = $RayCast2D; +@onready var cooldown_timer = $CooldownTimer; + +var player = null; +var is_on_cooldown = false; + +func _ready(): + add_to_group("enemies"); + +func _physics_process(delta): + if player == null: + return + + var vec_to_player = player.global_position - global_position; + vec_to_player = vec_to_player.normalized(); + raycast.rotation = atan2(vec_to_player.y,vec_to_player.x); + velocity = velocity.move_toward(vec_to_player * MAX_SPEED,ACCELERATION*delta); + move_and_slide(); + + if raycast.is_colliding(): + var coll = raycast.get_collider(); + if coll.name == "Player": + attack(coll); + +func attack(collider): + if !is_on_cooldown: + is_on_cooldown = true; + cooldown_timer.start(COOLDOWN); + collider.take_damage(DAMAGE); + +func take_damage(damage): + HP = HP - damage; + if HP <= 0: + kill(); + +func kill(): + queue_free(); + +func set_player(p): + player = p; + +func _on_cooldown_timer_timeout(): + is_on_cooldown = false; diff --git a/Enemies/basic_enemy.tscn b/Enemies/basic_enemy.tscn new file mode 100644 index 0000000..3b52baa --- /dev/null +++ b/Enemies/basic_enemy.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=5 format=3 uid="uid://c661br4lh30r8"] + +[ext_resource type="Script" path="res://Enemies/basic_enemy.gd" id="1_5vi5k"] +[ext_resource type="Texture2D" uid="uid://ds4uvvrcxoay1" path="res://Sprites/placeholder_enemy.png" id="1_o8nfm"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_efc6w"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_o8nfm") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_47nt3"] +size = Vector2(41, 64) + +[node name="BasicEnemy" type="CharacterBody2D"] +script = ExtResource("1_5vi5k") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +frames = SubResource("SpriteFrames_efc6w") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(0.5, 0) +shape = SubResource("RectangleShape2D_47nt3") + +[node name="RayCast2D" type="RayCast2D" parent="."] +target_position = Vector2(35, 0) + +[node name="Line2D" type="Line2D" parent="RayCast2D"] +points = PackedVector2Array(0, 0, 35, 0) +width = 5.0 +default_color = Color(1, 0, 0, 0.392157) + +[node name="CooldownTimer" type="Timer" parent="."] + +[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"] diff --git a/Player/Projectiles/basic_projectile.tscn b/Player/Projectiles/basic_projectile.tscn deleted file mode 100644 index 284067f..0000000 --- a/Player/Projectiles/basic_projectile.tscn +++ /dev/null @@ -1,3 +0,0 @@ -[gd_scene format=3 uid="uid://cpo8qy3y0fuui"] - -[node name="basic_projectile" type="Node2D"] diff --git a/Player/Weapons/basic_weapon.tscn b/Player/Weapons/basic_weapon.tscn deleted file mode 100644 index 2f99b85..0000000 --- a/Player/Weapons/basic_weapon.tscn +++ /dev/null @@ -1,5 +0,0 @@ -[gd_scene format=3 uid="uid://cmtuq84761y0i"] - -[node name="basic_weapon" type="Node2D"] - -[node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/Player/player.gd b/Player/player.gd index abe6a84..60caafb 100644 --- a/Player/player.gd +++ b/Player/player.gd @@ -3,8 +3,16 @@ extends CharacterBody2D @export var MAX_SPEED = 600.0; @export var ACCELERATION = 2000.0; @export var FRICTION = 3000.0; +@export var HP = 3; +@export var STARTING_WEAPON : PackedScene; @onready var raycast = $RayCast2D; +var current_weapon = null; + +func _ready(): + call_deferred("call_set_player"); + current_weapon = STARTING_WEAPON.instantiate(); + raycast.add_child(current_weapon); func _physics_process(delta): var input_vector = get_input_vector(); @@ -14,6 +22,21 @@ func _physics_process(delta): var look_vec = get_global_mouse_position() - global_position; raycast.rotation = atan2(look_vec.y,look_vec.x); + + if Input.is_action_pressed("shoot"): + attack(); + + +func attack(): + if current_weapon: current_weapon.fire(); + +func take_damage(damage): + HP = HP - damage; + if HP <= 0: + kill(); + +func kill(): + get_tree().reload_current_scene(); func get_input_vector(): var input_vector = Vector2.ZERO; @@ -30,6 +53,8 @@ func apply_friction(input_vector,delta): if(input_vector == Vector2.ZERO): velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta); +func call_set_player(): + get_tree().call_group("enemies", "set_player",self); func _on_area_2d_area_entered(area): $"../School_Snare".volume_db(-6); diff --git a/Player/player.tscn b/Player/player.tscn index 97274bc..213a5fd 100644 --- a/Player/player.tscn +++ b/Player/player.tscn @@ -1,13 +1,14 @@ -[gd_scene load_steps=5 format=3 uid="uid://b62h0w8gjm6tj"] +[gd_scene load_steps=6 format=3 uid="uid://xev8p1td1icx"] [ext_resource type="Script" path="res://Player/player.gd" id="1_mbyc2"] -[ext_resource type="Texture2D" uid="uid://wkeakqjvu3gg" path="res://Sprites/dingo_jam_mc_front_64.png" id="2_ae25p"] +[ext_resource type="PackedScene" uid="uid://cmtuq84761y0i" path="res://Weapons/basic_weapon.tscn" id="2_bo475"] +[ext_resource type="Texture2D" uid="uid://wkeakqjvu3gg" path="res://Sprites/placeholder_player.png" id="2_bqbmq"] [sub_resource type="SpriteFrames" id="SpriteFrames_mqbrd"] animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("2_ae25p") +"texture": ExtResource("2_bqbmq") }], "loop": true, "name": &"default", @@ -15,10 +16,11 @@ animations = [{ }] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ng5bv"] -size = Vector2(64, 64) +size = Vector2(40, 64) [node name="Player" type="CharacterBody2D"] script = ExtResource("1_mbyc2") +STARTING_WEAPON = ExtResource("2_bo475") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] frames = SubResource("SpriteFrames_mqbrd") @@ -33,6 +35,7 @@ current = true target_position = Vector2(2000, 0) [node name="Line2D" type="Line2D" parent="RayCast2D"] +visible = false points = PackedVector2Array(0, 0, 2000, 0) width = 5.0 default_color = Color(1, 0, 0, 0.392157) diff --git a/Projectiles/basic_projectile.gd b/Projectiles/basic_projectile.gd new file mode 100644 index 0000000..931385b --- /dev/null +++ b/Projectiles/basic_projectile.gd @@ -0,0 +1,20 @@ +extends Area2D + +@export var DAMAGE = 1; +@export var SPEED = 800; +@export var LIFETIME = 3; + +@onready var life_timer = $LifeTimer; + +var velocity = Vector2.ZERO; + +func _process(delta): + if velocity != Vector2.ZERO: + transform.origin += velocity * delta; + +func launch(direction): + life_timer.start(LIFETIME); + velocity = direction * SPEED; + +func _on_life_timer_timeout(): + queue_free(); diff --git a/Projectiles/basic_projectile.tscn b/Projectiles/basic_projectile.tscn new file mode 100644 index 0000000..dbf5e25 --- /dev/null +++ b/Projectiles/basic_projectile.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=4 format=3 uid="uid://cpo8qy3y0fuui"] + +[ext_resource type="Script" path="res://Projectiles/basic_projectile.gd" id="1_l2kyf"] +[ext_resource type="Texture2D" uid="uid://gqotbni355f" path="res://Sprites/placeholder_projectile.png" id="1_o7jy1"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_pp7ve"] +size = Vector2(10, 10) + +[node name="basic_projectile" type="Area2D"] +script = ExtResource("1_l2kyf") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(5, 5) +texture = ExtResource("1_o7jy1") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_pp7ve") + +[node name="LifeTimer" type="Timer" parent="."] + +[connection signal="timeout" from="LifeTimer" to="." method="_on_life_timer_timeout"] diff --git a/Sprites/placeholder_enemie.xcf b/Sprites/placeholder_enemie.xcf new file mode 100644 index 0000000..f2e8914 Binary files /dev/null and b/Sprites/placeholder_enemie.xcf differ diff --git a/Sprites/placeholder_enemy.png b/Sprites/placeholder_enemy.png new file mode 100644 index 0000000..cb73f07 Binary files /dev/null and b/Sprites/placeholder_enemy.png differ diff --git a/Sprites/placeholder_enemy.png.import b/Sprites/placeholder_enemy.png.import new file mode 100644 index 0000000..4ac7706 --- /dev/null +++ b/Sprites/placeholder_enemy.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ds4uvvrcxoay1" +path="res://.godot/imported/placeholder_enemy.png-d631bd7922b121775dedcf976041c79a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/placeholder_enemy.png" +dest_files=["res://.godot/imported/placeholder_enemy.png-d631bd7922b121775dedcf976041c79a.ctex"] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Sprites/dingo_jam_mc_front_64.png b/Sprites/placeholder_player.png similarity index 100% rename from Sprites/dingo_jam_mc_front_64.png rename to Sprites/placeholder_player.png diff --git a/Sprites/dingo_jam_mc_front_64.png.import b/Sprites/placeholder_player.png.import similarity index 68% rename from Sprites/dingo_jam_mc_front_64.png.import rename to Sprites/placeholder_player.png.import index ca0c5fa..ec1b8b6 100644 --- a/Sprites/dingo_jam_mc_front_64.png.import +++ b/Sprites/placeholder_player.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://wkeakqjvu3gg" -path="res://.godot/imported/dingo_jam_mc_front_64.png-601093cfabf1ebe5f72150684b2fcd7e.ctex" +path="res://.godot/imported/placeholder_player.png-64f3e50b58f57e0a665d775e13e1f7dc.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Sprites/dingo_jam_mc_front_64.png" -dest_files=["res://.godot/imported/dingo_jam_mc_front_64.png-601093cfabf1ebe5f72150684b2fcd7e.ctex"] +source_file="res://Sprites/placeholder_player.png" +dest_files=["res://.godot/imported/placeholder_player.png-64f3e50b58f57e0a665d775e13e1f7dc.ctex"] [params] diff --git a/Sprites/projectile.png b/Sprites/placeholder_projectile.png similarity index 100% rename from Sprites/projectile.png rename to Sprites/placeholder_projectile.png diff --git a/Sprites/projectile.png.import b/Sprites/placeholder_projectile.png.import similarity index 68% rename from Sprites/projectile.png.import rename to Sprites/placeholder_projectile.png.import index 1319534..05a7581 100644 --- a/Sprites/projectile.png.import +++ b/Sprites/placeholder_projectile.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://gqotbni355f" -path="res://.godot/imported/projectile.png-eff5302beb46bc9a9106ccfb67813440.ctex" +path="res://.godot/imported/placeholder_projectile.png-b7f99271bb5a0233cb6b30e50461f459.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Sprites/projectile.png" -dest_files=["res://.godot/imported/projectile.png-eff5302beb46bc9a9106ccfb67813440.ctex"] +source_file="res://Sprites/placeholder_projectile.png" +dest_files=["res://.godot/imported/placeholder_projectile.png-b7f99271bb5a0233cb6b30e50461f459.ctex"] [params] diff --git a/Sprites/pew.png b/Sprites/placeholder_weapon.png similarity index 100% rename from Sprites/pew.png rename to Sprites/placeholder_weapon.png diff --git a/Sprites/pew.png.import b/Sprites/placeholder_weapon.png.import similarity index 69% rename from Sprites/pew.png.import rename to Sprites/placeholder_weapon.png.import index a05e57a..a3b7713 100644 --- a/Sprites/pew.png.import +++ b/Sprites/placeholder_weapon.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://df71outtqfcu0" -path="res://.godot/imported/pew.png-3aab10d741cd8f2cd98a8407fc89f0cc.ctex" +path="res://.godot/imported/placeholder_weapon.png-154a5d8679016d3a845bf640635bfcb2.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Sprites/pew.png" -dest_files=["res://.godot/imported/pew.png-3aab10d741cd8f2cd98a8407fc89f0cc.ctex"] +source_file="res://Sprites/placeholder_weapon.png" +dest_files=["res://.godot/imported/placeholder_weapon.png-154a5d8679016d3a845bf640635bfcb2.ctex"] [params] diff --git a/Weapons/basic_weapon.gd b/Weapons/basic_weapon.gd new file mode 100644 index 0000000..25dd4ab --- /dev/null +++ b/Weapons/basic_weapon.gd @@ -0,0 +1,24 @@ +extends Node2D + +@export var PROJECTILE : PackedScene; +@export var COOLDOWN = .5; +@export var SPREAD = 10; + +@onready var raycast = $RayCast2D; +@onready var cooldown_timer = $CooldownTimer; + +var is_on_cooldown = false; + +func fire(): + if !is_on_cooldown: + is_on_cooldown = true; + cooldown_timer.start(COOLDOWN); + var current_projectile : Area2D = PROJECTILE.instantiate(); + get_node("/root").add_child(current_projectile); + + current_projectile.transform = raycast.get_global_transform() + current_projectile.launch((get_global_mouse_position() - global_position).normalized()); + + +func _on_cooldown_timer_timeout(): + is_on_cooldown = false; diff --git a/Weapons/basic_weapon.tscn b/Weapons/basic_weapon.tscn new file mode 100644 index 0000000..5086cb1 --- /dev/null +++ b/Weapons/basic_weapon.tscn @@ -0,0 +1,22 @@ +[gd_scene load_steps=4 format=3 uid="uid://cmtuq84761y0i"] + +[ext_resource type="Script" path="res://Weapons/basic_weapon.gd" id="1_cser3"] +[ext_resource type="Texture2D" uid="uid://df71outtqfcu0" path="res://Sprites/placeholder_weapon.png" id="1_k30lm"] +[ext_resource type="PackedScene" uid="uid://cpo8qy3y0fuui" path="res://Projectiles/basic_projectile.tscn" id="2_fbg12"] + +[node name="basic_weapon" type="Node2D"] +script = ExtResource("1_cser3") +PROJECTILE = ExtResource("2_fbg12") + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(20, 0) +scale = Vector2(2, 2) +texture = ExtResource("1_k30lm") + +[node name="RayCast2D" type="RayCast2D" parent="."] +position = Vector2(44, 0) +target_position = Vector2(50, 0) + +[node name="CooldownTimer" type="Timer" parent="."] + +[connection signal="timeout" from="CooldownTimer" to="." method="_on_cooldown_timer_timeout"] diff --git a/project.godot b/project.godot index 7b705df..56889de 100644 --- a/project.godot +++ b/project.godot @@ -54,6 +54,21 @@ shoot={ "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null) ] } +weapon_01={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"unicode":0,"echo":false,"script":null) +] +} +weapon_02={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"unicode":0,"echo":false,"script":null) +] +} +weapon_03={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"unicode":0,"echo":false,"script":null) +] +} [rendering] diff --git a/test_level001.tscn b/test_level001.tscn index 4003b24..d38183a 100644 --- a/test_level001.tscn +++ b/test_level001.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://d748m0x7o1nc"] +[gd_scene load_steps=6 format=3 uid="uid://d748m0x7o1nc"] -[ext_resource type="PackedScene" uid="uid://b62h0w8gjm6tj" path="res://Player/player.tscn" id="1_51g8b"] +[ext_resource type="PackedScene" uid="uid://xev8p1td1icx" path="res://Player/player.tscn" id="1_51g8b"] [ext_resource type="Texture2D" uid="uid://d3y4rna66nylu" path="res://TileSets/Tiles Set GameJam.png" id="2_xwre6"] +[ext_resource type="PackedScene" uid="uid://c661br4lh30r8" path="res://Enemies/basic_enemy.tscn" id="3_e1d3p"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_aemot"] resource_name = "Test" @@ -136,3 +137,6 @@ position = Vector2(67.9902, 68.8737) [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"] polygon = PackedVector2Array(409, 497, 687, 497, 687, 367, 1681, 367, 1683, 639, 1967, 643, 1963, 85, 415, 85) + +[node name="BasicEnemy" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(846, 494)