basic skill
This commit is contained in:
parent
36583be9db
commit
24e5cbfea9
11 changed files with 88 additions and 15 deletions
26
sprites/common/bullet/fireball.gd
Normal file
26
sprites/common/bullet/fireball.gd
Normal file
|
@ -0,0 +1,26 @@
|
|||
extends Area2D
|
||||
var velocity: Vector2 = Vector2()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _physics_process(delta):
|
||||
position += velocity * delta
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
#if body.is_in_group("players"):
|
||||
# Global.live = 2
|
||||
#elif body.is_in_group("enemies"):
|
||||
# Global.live = 3
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_screen_exited():
|
||||
queue_free()
|
|
@ -1,15 +1,21 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b2gxwerkgrbp7"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dibpmnnxefgi2"]
|
||||
|
||||
[ext_resource type="Script" path="res://sprites/common/bullet/fireball.gd" id="1_o7kcl"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfqxhmvjstwcd" path="res://sprites/common/bullet/fireball.png" id="1_ues2l"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_tqfch"]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g125y"]
|
||||
size = Vector2(47, 60)
|
||||
|
||||
[node name="Fireball" type="RigidBody2D"]
|
||||
[node name="Fireball" type="Area2D"]
|
||||
script = ExtResource("1_o7kcl")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_ues2l")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0.5, 0)
|
||||
shape = SubResource("RectangleShape2D_tqfch")
|
||||
shape = SubResource("RectangleShape2D_g125y")
|
||||
|
||||
[node name="VisibleOnScreenEnabler2D" type="VisibleOnScreenEnabler2D" parent="."]
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
|
|
|
@ -48,4 +48,4 @@ func _physics_process(delta):
|
|||
anim.play("widle")
|
||||
else:
|
||||
anim.play("sidle")
|
||||
move_and_slide()
|
||||
#move_and_slide()
|
||||
|
|
|
@ -48,4 +48,4 @@ func _physics_process(delta):
|
|||
anim.play("widle")
|
||||
else:
|
||||
anim.play("sidle")
|
||||
move_and_slide()
|
||||
#move_and_slide()
|
||||
|
|
|
@ -7,11 +7,12 @@ var angle = 2
|
|||
var sprite
|
||||
var anim
|
||||
var csprite
|
||||
|
||||
var bpress = false
|
||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
func _ready():
|
||||
add_to_group("players")
|
||||
anim = $AnimationPlayer
|
||||
sprite = $Sprite2D
|
||||
if Global.debug:
|
||||
|
@ -20,7 +21,6 @@ func _ready():
|
|||
else:
|
||||
csprite = Global.cpchar
|
||||
sprite.texture = load(Global.pchars[Global.party[Global.cpchar]])
|
||||
csprite
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
|
@ -66,3 +66,24 @@ func _physics_process(delta):
|
|||
else:
|
||||
anim.play("sidle")
|
||||
move_and_slide()
|
||||
|
||||
func _input(event):
|
||||
if Global.live == 1:
|
||||
if Input.is_action_just_pressed("shoot") && !bpress && Global.live == 1:
|
||||
bpress = true
|
||||
var bullet
|
||||
if Global.debug:
|
||||
bullet = load(Global.pbbullets[Global.dparty[Global.dcpchar]])
|
||||
else:
|
||||
bullet = load(Global.pbbullets[Global.party[Global.cpchar]])
|
||||
var new_bullet = bullet.instantiate()
|
||||
new_bullet.velocity = Vector2(0, -500).rotated(deg_to_rad(angle * 90))
|
||||
var rposition = Vector2(0, -96).rotated(deg_to_rad(angle * 90))
|
||||
if angle == 2:
|
||||
new_bullet.position = Vector2(position.x + rposition.x, position.y + rposition.y + 98)
|
||||
else:
|
||||
new_bullet.position = Vector2(position.x + rposition.x, position.y + rposition.y)
|
||||
if new_bullet.position.x > 0 && new_bullet.position.y > 0 && new_bullet.position.x < 1280 && new_bullet.position.y < 720:
|
||||
get_parent().add_child(new_bullet)
|
||||
elif Input.is_action_just_released("shoot") && bpress:
|
||||
bpress = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue