diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg index f2032a7..83b190d 100644 --- a/.godot/editor/editor_layout.cfg +++ b/.godot/editor/editor_layout.cfg @@ -16,11 +16,11 @@ dock_5="Inspector,Node,History" [EditorNode] -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"] +open_scenes=["res://test_level001.tscn", "res://Enemies/basic_enemy.tscn", "res://Player/player.tscn", "res://Weapons/shotgun.tscn"] [ScriptEditor] 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"] +open_help=["Area2D", "CharacterBody2D", "Node2D", "RandomNumberGenerator", "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 75559f7..bf819a9 100644 --- a/.godot/editor/filesystem_cache7 +++ b/.godot/editor/filesystem_cache7 @@ -1,10 +1,10 @@ 0b7126e0c6e86d3ec295a72f5aa6e0bd -::res://::1673754772 +::res://::1673759153 README.md::TextFile::-1::1673744149::0::1::::<><>:: -test_level001.tscn::PackedScene::278447013021769396::1673754607::0::1::::<><>::uid://xev8p1td1icx<>uid://d3y4rna66nylu<>uid://c661br4lh30r8 -::res://Enemies/::1673754607 -basic_enemy.gd::GDScript::-1::1673753048::0::1::::<>CharacterBody2D<>:: -basic_enemy.tscn::PackedScene::7014272596353446583::1673754607::0::1::::<><>::res://Enemies/basic_enemy.gd<>uid://ds4uvvrcxoay1 +test_level001.tscn::PackedScene::278447013021769396::1673758831::0::1::::<><>::uid://xev8p1td1icx<>uid://d3y4rna66nylu<>uid://c661br4lh30r8 +::res://Enemies/::1673758831 +basic_enemy.gd::GDScript::-1::1673757641::0::1::::<>CharacterBody2D<>:: +basic_enemy.tscn::PackedScene::7014272596353446583::1673758831::0::1::::<><>::res://Enemies/basic_enemy.gd<>uid://ds4uvvrcxoay1 ::res://Levels/::1673744149 level.tscn::PackedScene::4739050375457527030::1673744149::0::1::::<><>:: ::res://Music/::1673744196 @@ -13,19 +13,21 @@ School_BDClave.ogg::AudioStreamOggVorbis::2352609159460477887::1673744149::16737 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/::1673754607 -player.gd::GDScript::-1::1673753856::0::1::::<>CharacterBody2D<>:: -player.tscn::PackedScene::1623935731621421531::1673754607::0::1::::<><>::res://Player/player.gd<>uid://cmtuq84761y0i<>uid://wkeakqjvu3gg -::res://Projectiles/::1673754624 -basic_projectile.gd::GDScript::-1::1673754606::0::1::::<>Area2D<>:: -basic_projectile.tscn::PackedScene::5856608848916302392::1673754624::0::1::::<><>::res://Projectiles/basic_projectile.gd<>uid://gqotbni355f -::res://Sprites/::1673744680 +::res://Player/::1673758831 +player.gd::GDScript::-1::1673758741::0::1::::<>CharacterBody2D<>:: +player.tscn::PackedScene::1623935731621421531::1673758831::0::1::::<><>::res://Player/player.gd<>uid://cmtuq84761y0i<>uid://wkeakqjvu3gg +::res://Projectiles/::1673757957 +basic_projectile.gd::GDScript::-1::1673757658::0::1::::<>Area2D<>:: +basic_projectile.tscn::PackedScene::5856608848916302392::1673757957::0::1::::<><>::res://Projectiles/basic_projectile.gd<>uid://gqotbni355f +::res://Sprites/::1673758613 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_shotgun.png::CompressedTexture2D::1210666365428533629::1673758421::1673758613::1::::<><>:: placeholder_weapon.png::CompressedTexture2D::7577871081029115281::1673744149::1673744508::1::::<><>:: ::res://TileSets/::1673744149 Tiles Set GameJam.png::CompressedTexture2D::9175886574582270754::1673744149::1673744149::1::::<><>:: -::res://Weapons/::1673754607 -basic_weapon.gd::GDScript::-1::1673754590::0::1::::<>Node2D<>:: -basic_weapon.tscn::PackedScene::5655575360493827386::1673754607::0::1::::<><>::res://Weapons/basic_weapon.gd<>uid://df71outtqfcu0<>uid://cpo8qy3y0fuui +::res://Weapons/::1673759002 +basic_weapon.gd::GDScript::-1::1673757935::0::1::::<>Node2D<>:: +basic_weapon.tscn::PackedScene::5655575360493827386::1673757957::0::1::::<><>::res://Weapons/basic_weapon.gd<>uid://df71outtqfcu0<>uid://cpo8qy3y0fuui +shotgun.tscn::PackedScene::2587411923144706110::1673759002::0::1::::<><>::uid://cmtuq84761y0i<>uid://ripq64urxouv diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index e698932..d1c5792 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -1,6 +1,5 @@ -res://Projectiles/basic_projectile.gd -res://Projectiles/basic_projectile.tscn +res://Weapons/shotgun.tscn res://test_level001.tscn res://Enemies/basic_enemy.tscn res://Player/player.tscn -res://Weapons/basic_weapon.tscn +res://Weapons/basic_weapon.gd diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 7c6f4fc..43ed53e 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -11,8 +11,8 @@ run_reload_scripts=true [recent_files] -scenes=["res://Projectiles/basic_projectile.tscn", "res://Weapons/basic_weapon.tscn", "res://Player/player.tscn", "res://Enemies/basic_enemy.tscn", "res://test_level001.tscn", "res://Enemies/basic_enemie.tscn", "res://player.tscn"] -scripts=["Vector2", "StaticBody2D", "RigidBody2D", "RayCast2D", "Node2D", "CharacterBody2D", "Area2D", "res://Projectiles/basic_projectile.gd", "res://Weapons/basic_weapon.gd", "res://Enemies/basic_enemy.gd"] +scenes=["res://Weapons/shotgun.tscn", "res://Player/player.tscn", "res://Enemies/basic_enemy.tscn", "res://test_level001.tscn", "res://Weapons/basic_weapon.tscn", "res://Projectiles/basic_projectile.tscn", "res://Enemies/basic_enemie.tscn", "res://player.tscn"] +scripts=["Vector2", "StaticBody2D", "RigidBody2D", "RayCast2D", "RandomNumberGenerator", "Node2D", "CharacterBody2D", "Area2D", "res://Weapons/shotgun.gd", "res://Projectiles/basic_projectile.gd"] [script_setup] diff --git a/.godot/editor/recent_dirs b/.godot/editor/recent_dirs index aab7497..2ae928b 100644 --- a/.godot/editor/recent_dirs +++ b/.godot/editor/recent_dirs @@ -1,3 +1,4 @@ +res://Weapons res://Enemies res:// res://Levels diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index 58d9fb1..df570f7 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -3,11 +3,11 @@ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 8, +"column": 36, "folded_lines": [], "h_scroll_position": 0, -"row": 26, -"scroll_position": 0.0, +"row": 40, +"scroll_position": 3.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -17,11 +17,11 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 44, +"column": 24, "folded_lines": [], "h_scroll_position": 0, -"row": 10, -"scroll_position": 8.0, +"row": 7, +"scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -31,10 +31,10 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 25, +"column": 130, "folded_lines": [], "h_scroll_position": 0, -"row": 3, +"row": 27, "scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" @@ -45,10 +45,10 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 32, +"column": 23, "folded_lines": [], "h_scroll_position": 0, -"row": 23, +"row": 2, "scroll_position": 0.0, "selection": false, "syntax_highlighter": "GDScript" diff --git a/.godot/uid_cache.bin b/.godot/uid_cache.bin index 2009faf..89b89fb 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 index 0e4e7fe..9d3082b 100644 --- a/Enemies/basic_enemy.gd +++ b/Enemies/basic_enemy.gd @@ -3,9 +3,9 @@ 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; +@export var HP = 20; +@export var DAMAGE = 34; +@export var COOLDOWN = 2; @onready var raycast = $RayCast2D; @onready var cooldown_timer = $CooldownTimer; diff --git a/Player/player.gd b/Player/player.gd index 60caafb..ad2ba63 100644 --- a/Player/player.gd +++ b/Player/player.gd @@ -1,17 +1,20 @@ extends CharacterBody2D -@export var MAX_SPEED = 600.0; +@export var MAX_SPEED = 400.0; @export var ACCELERATION = 2000.0; @export var FRICTION = 3000.0; -@export var HP = 3; +@export var HP = 100; @export var STARTING_WEAPON : PackedScene; @onready var raycast = $RayCast2D; var current_weapon = null; +var weapons = [null,null,null]; func _ready(): call_deferred("call_set_player"); - current_weapon = STARTING_WEAPON.instantiate(); + weapons[0] = STARTING_WEAPON.instantiate(); + weapons[1] = load("res://Weapons/shotgun.tscn").instantiate(); + current_weapon = weapons[0]; raycast.add_child(current_weapon); func _physics_process(delta): @@ -25,10 +28,20 @@ func _physics_process(delta): if Input.is_action_pressed("shoot"): attack(); + + if Input.is_action_just_pressed("weapon_01"):change_weapon(0); + if Input.is_action_just_pressed("weapon_02"):change_weapon(1); + if Input.is_action_just_pressed("weapon_03"):change_weapon(2); + +func change_weapon(position): + if weapons[position]: + raycast.remove_child(current_weapon); + current_weapon = weapons[position]; + raycast.add_child(current_weapon); func attack(): - if current_weapon: current_weapon.fire(); + if current_weapon: current_weapon.fire(velocity); func take_damage(damage): HP = HP - damage; diff --git a/Projectiles/basic_projectile.gd b/Projectiles/basic_projectile.gd index bd47b9d..e376262 100644 --- a/Projectiles/basic_projectile.gd +++ b/Projectiles/basic_projectile.gd @@ -1,8 +1,8 @@ extends Area2D -@export var DAMAGE = 1; -@export var SPEED = 800; -@export var LIFETIME = 3; +@export var DAMAGE = 10; +@export var SPEED = 700; +@export var LIFETIME = 1; @onready var life_timer = $LifeTimer; @@ -12,14 +12,19 @@ func _process(delta): if velocity != Vector2.ZERO: transform.origin += velocity * delta; -func launch(direction): +func launch(direction, based_velocity): life_timer.start(LIFETIME); - velocity = direction * SPEED; + velocity = based_velocity + direction * SPEED; func _on_life_timer_timeout(): queue_free(); - func _on_body_entered(body): - if body.is_in_group("enemies"): - body.take_damage(DAMAGE); + if body.name != "Player": + if body.is_in_group("enemies"): + body.take_damage(DAMAGE); + explode(); + +func explode(): + #animation and stuff + queue_free(); diff --git a/Projectiles/basic_projectile.tscn b/Projectiles/basic_projectile.tscn index adfb918..2802511 100644 --- a/Projectiles/basic_projectile.tscn +++ b/Projectiles/basic_projectile.tscn @@ -4,13 +4,12 @@ [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) +scale = Vector2(10, 10) texture = ExtResource("1_o7jy1") [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/Sprites/placeholder_shotgun.png b/Sprites/placeholder_shotgun.png new file mode 100644 index 0000000..1bad96d Binary files /dev/null and b/Sprites/placeholder_shotgun.png differ diff --git a/Sprites/placeholder_shotgun.png.import b/Sprites/placeholder_shotgun.png.import new file mode 100644 index 0000000..f27f217 --- /dev/null +++ b/Sprites/placeholder_shotgun.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ripq64urxouv" +path="res://.godot/imported/placeholder_shotgun.png-f2c583770e939587baeb7f4ce07244b6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Sprites/placeholder_shotgun.png" +dest_files=["res://.godot/imported/placeholder_shotgun.png-f2c583770e939587baeb7f4ce07244b6.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/Weapons/basic_weapon.gd b/Weapons/basic_weapon.gd index 25dd4ab..7fa77c8 100644 --- a/Weapons/basic_weapon.gd +++ b/Weapons/basic_weapon.gd @@ -1,23 +1,32 @@ extends Node2D @export var PROJECTILE : PackedScene; +@export var PROJECTILE_AMOUNT = 1; @export var COOLDOWN = .5; -@export var SPREAD = 10; +@export var SPREAD = .2; +@export var RANGE_MOD = 0; @onready var raycast = $RayCast2D; @onready var cooldown_timer = $CooldownTimer; var is_on_cooldown = false; +var rng = RandomNumberGenerator.new(); -func fire(): +func _ready(): + rng.randomize(); + +func fire(wielder_velocity): 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()); + for i in PROJECTILE_AMOUNT: + var current_projectile : Area2D = PROJECTILE.instantiate(); + get_node("/root").add_child(current_projectile); + + current_projectile.transform = raycast.get_global_transform() ; + current_projectile.transform.origin += (get_global_mouse_position() - global_position).normalized() * (rng.randf() * RANGE_MOD); + current_projectile.launch((get_global_mouse_position() - global_position).rotated(rng.randf_range(SPREAD,-SPREAD)).normalized(), wielder_velocity); func _on_cooldown_timer_timeout(): diff --git a/Weapons/shotgun.tscn b/Weapons/shotgun.tscn new file mode 100644 index 0000000..ceab6e5 --- /dev/null +++ b/Weapons/shotgun.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=3 uid="uid://bc4mkctxjnugk"] + +[ext_resource type="PackedScene" uid="uid://cmtuq84761y0i" path="res://Weapons/basic_weapon.tscn" id="1_0nefe"] +[ext_resource type="Texture2D" uid="uid://ripq64urxouv" path="res://Sprites/placeholder_shotgun.png" id="2_r5age"] + +[node name="shotgun" instance=ExtResource("1_0nefe")] +PROJECTILE_AMOUNT = 4 +COOLDOWN = 1.0 +SPREAD = 0.3 +RANGE_MOD = 40 + +[node name="Sprite2D" parent="." index="0"] +position = Vector2(18, 3) +scale = Vector2(1.71875, 1.71875) +texture = ExtResource("2_r5age") diff --git a/test_level001.tscn b/test_level001.tscn index d38183a..c7784bb 100644 --- a/test_level001.tscn +++ b/test_level001.tscn @@ -139,4 +139,22 @@ position = Vector2(67.9902, 68.8737) 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) +position = Vector2(843, 709) + +[node name="BasicEnemy2" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(1555, 856) + +[node name="BasicEnemy3" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(1034, 520) + +[node name="BasicEnemy4" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(774, -108) + +[node name="BasicEnemy5" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(1383, -193) + +[node name="BasicEnemy6" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(948, 660) + +[node name="BasicEnemy7" parent="." instance=ExtResource("3_e1d3p")] +position = Vector2(1322, 618)