mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-25 14:14:19 +00:00
⚙️ ability to shoot
This commit is contained in:
parent
f8ea6ebf0d
commit
711be6a85c
9 changed files with 74 additions and 15 deletions
|
@ -8,6 +8,11 @@
|
||||||
|
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
|
_global_script_classes=[ ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="LD50"
|
config/name="LD50"
|
||||||
|
@ -27,32 +32,37 @@ window/size/resizable=false
|
||||||
|
|
||||||
player_move_up={
|
player_move_up={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
player_move_down={
|
player_move_down={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
player_move_left={
|
player_move_left={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
player_move_right={
|
player_move_right={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
shoot={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
19
src/entities/Bullet.tscn
Normal file
19
src/entities/Bullet.tscn
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/mechanics/White.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://src/entities/behaviours/BulletMovement.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
[node name="Bullet" type="KinematicBody2D"]
|
||||||
|
|
||||||
|
[node name="BulletMovement" type="Node" parent="."]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
scale = Vector2( 1, 0.5 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
disabled = true
|
19
src/entities/behaviours/BulletMovement.gd
Normal file
19
src/entities/behaviours/BulletMovement.gd
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
onready var target: KinematicBody2D = get_parent()
|
||||||
|
onready var angle: float = deg2rad(target.get_rotation_degrees())
|
||||||
|
export var movement_per_second: float = 96.0
|
||||||
|
|
||||||
|
var direction : Vector2 = Vector2(0,0)
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
direction = Vector2.ZERO
|
||||||
|
|
||||||
|
direction += sin(angle) * Vector2.DOWN
|
||||||
|
direction += cos(angle) * Vector2.RIGHT
|
||||||
|
|
||||||
|
if direction.length() > 1:
|
||||||
|
direction.normalized()
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
var _motion: Vector2 = target.move_and_slide(direction * movement_per_second)
|
17
src/entities/behaviours/BulletSpawn.gd
Normal file
17
src/entities/behaviours/BulletSpawn.gd
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
extends Position2D
|
||||||
|
|
||||||
|
# Items
|
||||||
|
onready var bullet = preload("res://src/entities/Bullet.tscn")
|
||||||
|
onready var spawner = get_node("/root/Game/PhaseOne/PhaseOneContainer/Player")
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
if Input.is_action_just_pressed("shoot"):
|
||||||
|
_on_Click()
|
||||||
|
|
||||||
|
func _on_Click():
|
||||||
|
var newBullet = bullet.instance()
|
||||||
|
newBullet.set_position(spawner.position)
|
||||||
|
var bulletRotation = rad2deg(newBullet.get_angle_to(get_global_mouse_position()))
|
||||||
|
newBullet.set_rotation_degrees(bulletRotation)
|
||||||
|
add_child(newBullet)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=12 format=2]
|
[gd_scene load_steps=10 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://src/mechanics/Background.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://src/mechanics/Darkness.tscn" type="PackedScene" id=2]
|
||||||
|
@ -7,9 +7,7 @@
|
||||||
[ext_resource path="res://src/entities/Enemy.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/entities/Enemy.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://src/levels/Game.gd" type="Script" id=6]
|
[ext_resource path="res://src/levels/Game.gd" type="Script" id=6]
|
||||||
[ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7]
|
[ext_resource path="res://src/ui/TimeSurvived.tscn" type="PackedScene" id=7]
|
||||||
[ext_resource path="res://src/music/BaseChoir.mp3" type="AudioStream" id=8]
|
[ext_resource path="res://src/entities/behaviours/BulletSpawn.gd" type="Script" id=8]
|
||||||
[ext_resource path="res://src/music/BaseDrum.mp3" type="AudioStream" id=9]
|
|
||||||
[ext_resource path="res://src/music/BaseBell.mp3" type="AudioStream" id=10]
|
|
||||||
[ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11]
|
[ext_resource path="res://src/levels/PhaseOneMusic.gd" type="Script" id=11]
|
||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
|
@ -23,17 +21,14 @@ script = ExtResource( 11 )
|
||||||
fire_path = NodePath("../PhaseOneContainer/Fire")
|
fire_path = NodePath("../PhaseOneContainer/Fire")
|
||||||
|
|
||||||
[node name="Bell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Bell" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 10 )
|
|
||||||
volume_db = -80.0
|
volume_db = -80.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
[node name="Choir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Choir" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 8 )
|
|
||||||
volume_db = -80.0
|
volume_db = -80.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
[node name="Drum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
[node name="Drum" type="AudioStreamPlayer" parent="PhaseOne/PhaseOneMusic"]
|
||||||
stream = ExtResource( 9 )
|
|
||||||
volume_db = -80.0
|
volume_db = -80.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
|
|
||||||
|
@ -55,6 +50,9 @@ position = Vector2( 755, 508 )
|
||||||
position = Vector2( 493, 305 )
|
position = Vector2( 493, 305 )
|
||||||
intensity = 0.3
|
intensity = 0.3
|
||||||
|
|
||||||
|
[node name="Position2D" type="Position2D" parent="PhaseOne/PhaseOneContainer"]
|
||||||
|
script = ExtResource( 8 )
|
||||||
|
|
||||||
[node name="UserInterface" type="CanvasLayer" parent="."]
|
[node name="UserInterface" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="UserIntefaceContainer" type="Panel" parent="UserInterface"]
|
[node name="UserIntefaceContainer" type="Panel" parent="UserInterface"]
|
||||||
|
|
|
@ -28,7 +28,6 @@ process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
process/HDR_as_SRGB=false
|
||||||
process/invert_color=false
|
process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=true
|
||||||
|
|
|
@ -28,7 +28,6 @@ process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
process/HDR_as_SRGB=false
|
||||||
process/invert_color=false
|
process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=true
|
||||||
|
|
|
@ -28,7 +28,6 @@ process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
process/HDR_as_SRGB=false
|
||||||
process/invert_color=false
|
process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=true
|
||||||
|
|
|
@ -28,7 +28,6 @@ process/fix_alpha_border=true
|
||||||
process/premult_alpha=false
|
process/premult_alpha=false
|
||||||
process/HDR_as_SRGB=false
|
process/HDR_as_SRGB=false
|
||||||
process/invert_color=false
|
process/invert_color=false
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
stream=false
|
||||||
size_limit=0
|
size_limit=0
|
||||||
detect_3d=true
|
detect_3d=true
|
||||||
|
|
Loading…
Reference in a new issue