systeme pour avoir plusieurs armes et un shotgun thingy
This commit is contained in:
parent
1d5435b0b5
commit
96581c5f60
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
res://Weapons
|
||||
res://Enemies
|
||||
res://
|
||||
res://Levels
|
||||
|
@ -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"
|
||||
|
Binary file not shown.
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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="."]
|
||||
|
BIN
Sprites/placeholder_shotgun.png
Normal file
BIN
Sprites/placeholder_shotgun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
34
Sprites/placeholder_shotgun.png.import
Normal file
34
Sprites/placeholder_shotgun.png.import
Normal file
@ -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
|
@ -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():
|
||||
|
15
Weapons/shotgun.tscn
Normal file
15
Weapons/shotgun.tscn
Normal file
@ -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")
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user