mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-21 23:34:21 +00:00
🔫 Add WIP peashooter
This commit is contained in:
parent
93ed28c68e
commit
dd0b5aa2fe
8 changed files with 112 additions and 32 deletions
|
@ -3,15 +3,17 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cdpn34mdaq545"
|
||||
path="res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.ctex"
|
||||
path.s3tc="res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.etc2.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc", "etc2"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/island_model/texture_1.png"
|
||||
dest_files=["res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.ctex"]
|
||||
dest_files=["res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.s3tc.ctex", "res://.godot/imported/texture_1.png-9fbd3af4843d9622d58b51ee93c19f7f.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
|
|
@ -19,13 +19,14 @@ var player: Player:
|
|||
|
||||
|
||||
var weapons: Array = [
|
||||
load("res://player/onhand/PeaShooter.tscn").instantiate()
|
||||
# load("res://Player/Weapons/Arm.tscn").instantiate(),
|
||||
# load("res://Player/Weapons/ak47.tscn").instantiate(),
|
||||
]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
self._switch_weapon(BaseWeapon.WeaponSlot.THREE)
|
||||
self._switch_weapon(BaseWeapon.WeaponSlot.ONE)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
@ -40,10 +41,10 @@ func _on_player_set(player: Player) -> void:
|
|||
func _input(event: InputEvent) -> void:
|
||||
if Input.is_action_just_pressed("slot1"):
|
||||
_switch_weapon(BaseWeapon.WeaponSlot.ONE)
|
||||
elif Input.is_action_just_pressed("slot2"):
|
||||
_switch_weapon(BaseWeapon.WeaponSlot.TWO)
|
||||
elif Input.is_action_just_pressed("slot3"):
|
||||
_switch_weapon(BaseWeapon.WeaponSlot.THREE)
|
||||
# elif Input.is_action_just_pressed("slot2"):
|
||||
# _switch_weapon(BaseWeapon.WeaponSlot.TWO)
|
||||
# elif Input.is_action_just_pressed("slot3"):
|
||||
# _switch_weapon(BaseWeapon.WeaponSlot.THREE)
|
||||
|
||||
|
||||
func _switch_weapon(slot: BaseWeapon.WeaponSlot):
|
||||
|
|
|
@ -3,7 +3,7 @@ class_name Player
|
|||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
const MOUSE_SENSITIVITY = 2.25
|
||||
const MOUSE_SENSITIVITY = 5 # 2.25
|
||||
|
||||
const MAX_AIR_WISH_SPEED = 20
|
||||
const AIR_ACCELERATE = 100 # Hu/39.97
|
||||
|
@ -21,7 +21,7 @@ const AIR_ACCELERATE = 100 # Hu/39.97
|
|||
get: return OnHand.active_weapon
|
||||
|
||||
# DEBUG NODES
|
||||
@onready var debug_speed_label = $HUD/Speed_Label
|
||||
@onready var ammo_label = $HUD/AmmoLabel
|
||||
|
||||
var last_frame_input_data: PlayerInputData = PlayerInputData.new()
|
||||
var input_data: PlayerInputData = PlayerInputData.new()
|
||||
|
@ -102,7 +102,12 @@ func _physics_process(delta):
|
|||
# delta
|
||||
# ) * 2.5
|
||||
|
||||
debug_speed_label.text = "%0.2f" % current_speed
|
||||
if active_weapon and active_weapon.ammoType != BaseWeapon.AmmoType.NONE:
|
||||
ammo_label.show()
|
||||
if active_weapon is PeaShooter:
|
||||
ammo_label.text = "%d peas left" % active_weapon.remaining
|
||||
else:
|
||||
ammo_label.hide()
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://b5i1sqd88wlle"]
|
||||
[gd_scene load_steps=17 format=3 uid="uid://b5i1sqd88wlle"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/Player.gd" id="1_rujcr"]
|
||||
[ext_resource type="Script" path="res://player/Head.gd" id="2_ohlgu"]
|
||||
[ext_resource type="Script" path="res://player/OnHand.gd" id="3_3rcjl"]
|
||||
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="4_d7ru6"]
|
||||
[ext_resource type="Shader" path="res://player/crosshair.gdshader" id="4_dut1p"]
|
||||
[ext_resource type="Script" path="res://player/SplashController.gd" id="5_wnbq8"]
|
||||
[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="6_xi537"]
|
||||
|
@ -137,7 +138,6 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
|
||||
[node name="CameraViewportContainer" type="SubViewportContainer" parent="Head/Viewport"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -176,7 +176,6 @@ theme = SubResource("Theme_smyke")
|
|||
|
||||
[node name="FPS_Label" type="Label" parent="HUD"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
|
@ -189,7 +188,7 @@ horizontal_alignment = 2
|
|||
script = SubResource("GDScript_iiadi")
|
||||
|
||||
[node name="PointsSpawner" type="Control" parent="HUD"]
|
||||
layout_mode = 1
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
|
@ -199,20 +198,19 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = SubResource("GDScript_5d122")
|
||||
|
||||
[node name="Speed_Label" type="Label" parent="HUD"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -53.0
|
||||
offset_top = 36.0
|
||||
offset_right = 53.0
|
||||
offset_bottom = 71.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
[node name="AmmoLabel" type="Label" parent="HUD"]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -106.0
|
||||
offset_top = -35.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
theme = ExtResource("4_d7ru6")
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "asdfasdf"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
|
@ -220,11 +218,11 @@ vertical_alignment = 1
|
|||
position = Vector2(727, 447)
|
||||
scale = Vector2(7.61, 4.89)
|
||||
copy_mode = 2
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="SubViewportContainer" type="SubViewportContainer" parent="HUD"]
|
||||
visible = false
|
||||
show_behind_parent = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -247,18 +245,19 @@ MainCamera = NodePath("../../../../Head/Viewport/CameraViewportContainer/GameVie
|
|||
|
||||
[node name="Crosshair" type="ColorRect" parent="HUD"]
|
||||
material = SubResource("ShaderMaterial_2p6rt")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="BackBufferCopy" type="BackBufferCopy" parent="HUD"]
|
||||
visible = false
|
||||
y_sort_enabled = true
|
||||
position = Vector2(140, 79)
|
||||
scale = Vector2(1.65, 1)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]
|
||||
|
||||
|
|
|
@ -7,10 +7,16 @@ enum WeaponSlot {
|
|||
THREE
|
||||
}
|
||||
|
||||
enum AmmoType {
|
||||
NONE,
|
||||
SINGLE
|
||||
}
|
||||
|
||||
@export_range(0,1) var MOUSE_MOVEMENT_BOB_AMOUNT := 0.5
|
||||
|
||||
var player: Player
|
||||
var weaponSlot: WeaponSlot = WeaponSlot.ONE
|
||||
var ammoType: AmmoType = AmmoType.NONE
|
||||
var mouse_movement := Vector2.ZERO
|
||||
|
||||
func on_switch_in():
|
46
player/onhand/PeaShooter.gd
Normal file
46
player/onhand/PeaShooter.gd
Normal file
|
@ -0,0 +1,46 @@
|
|||
extends BaseWeapon
|
||||
class_name PeaShooter
|
||||
|
||||
const FIRE_RATE := 0.15
|
||||
var last_fired := 0
|
||||
var remaining := 10
|
||||
|
||||
@onready var ray = $RayCast3D
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
self.weaponSlot = WeaponSlot.ONE
|
||||
self.ammoType = AmmoType.SINGLE
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
var current_time = Time.get_ticks_msec()
|
||||
|
||||
if Input.is_action_just_pressed("fire") and current_time > (last_fired + FIRE_RATE*1000):
|
||||
if remaining > 0:
|
||||
shoot()
|
||||
|
||||
|
||||
func shoot() -> void:
|
||||
last_fired = Time.get_ticks_msec()
|
||||
# audio_player.play()
|
||||
# $AnimationPlayer.seek(0)
|
||||
# $AnimationPlayer.play("shoot")
|
||||
|
||||
if ray.is_colliding():
|
||||
var normal = ray.get_collision_normal() as Vector3
|
||||
var point = ray.get_collision_point() as Vector3
|
||||
var object = ray.get_collider() as Node3D
|
||||
# decalInstance.position = point
|
||||
# object.add_child(decalInstance)
|
||||
else:
|
||||
# We should show a particle fx where the seed bouced off
|
||||
pass
|
||||
|
||||
remaining -= 1
|
10
player/onhand/PeaShooter.tscn
Normal file
10
player/onhand/PeaShooter.tscn
Normal file
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cu53ekfgwammu"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/onhand/PeaShooter.gd" id="1_bl35a"]
|
||||
|
||||
[node name="PeaShooter" type="Node3D"]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
|
||||
script = ExtResource("1_bl35a")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="."]
|
||||
target_position = Vector3(1000, 0, 0)
|
|
@ -12,7 +12,12 @@ _global_script_classes=[{
|
|||
"base": "Node",
|
||||
"class": &"BaseWeapon",
|
||||
"language": &"GDScript",
|
||||
"path": "res://player/BaseWeapon.gd"
|
||||
"path": "res://player/onhand/BaseWeapon.gd"
|
||||
}, {
|
||||
"base": "BaseWeapon",
|
||||
"class": &"PeaShooter",
|
||||
"language": &"GDScript",
|
||||
"path": "res://player/onhand/PeaShooter.gd"
|
||||
}, {
|
||||
"base": "CharacterBody3D",
|
||||
"class": &"Player",
|
||||
|
@ -26,6 +31,7 @@ _global_script_classes=[{
|
|||
}]
|
||||
_global_script_class_icons={
|
||||
"BaseWeapon": "",
|
||||
"PeaShooter": "",
|
||||
"Player": "",
|
||||
"PlayerInputData": ""
|
||||
}
|
||||
|
@ -96,6 +102,11 @@ toggle_torch={
|
|||
"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":70,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
fire={
|
||||
"deadzone": 0.5,
|
||||
"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)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
Loading…
Reference in a new issue