Too much stuff
This commit is contained in:
parent
a58e3fa0c8
commit
789bf1e33d
16
KinematicBody2D.gd
Normal file
16
KinematicBody2D.gd
Normal file
|
@ -0,0 +1,16 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# 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
|
27
Skeleton Enemy.gd
Normal file
27
Skeleton Enemy.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var speed = 60
|
||||
var gravity =500
|
||||
const UP = Vector2(0, -1)
|
||||
|
||||
var velocity = Vector2()
|
||||
|
||||
func apply_gravity(delta, modifier = 1):
|
||||
velocity.y += gravity * delta * modifier
|
||||
|
||||
func _physics_process(_delta):
|
||||
if Globals.player != null:
|
||||
if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player":
|
||||
velocity = Vector2(0, 0)
|
||||
elif $RayCast2D2.get_collider() != null && $RayCast2D2.get_collider().has_method("get_type") and $RayCast2D2.get_collider().get_type() == "player":
|
||||
velocity = Vector2(0, 0)
|
||||
else:
|
||||
velocity.x = position.direction_to(Globals.player).normalized().x
|
||||
apply_gravity(_delta)
|
||||
velocity.x *= speed
|
||||
velocity = move_and_slide(velocity, UP)
|
||||
|
||||
if is_on_wall() and is_on_floor():
|
||||
velocity.y = -150
|
||||
|
||||
|
32
Skeleton.gd
Normal file
32
Skeleton.gd
Normal file
|
@ -0,0 +1,32 @@
|
|||
extends RigidBody2D
|
||||
|
||||
var speed = 45
|
||||
var gravity = 500
|
||||
const UP = Vector2(0, -1)
|
||||
var is_grounded
|
||||
var touching_wall = 0
|
||||
|
||||
var velocity = Vector2()
|
||||
|
||||
func apply_gravity(delta, modifier = 1):
|
||||
velocity.y += gravity * delta * modifier
|
||||
|
||||
func _physics_process(_delta):
|
||||
if Globals.player != null:
|
||||
velocity.x = position.direction_to(Globals.player).normalized().x
|
||||
apply_gravity(_delta)
|
||||
velocity = move_and_slide(velocity * speed)
|
||||
|
||||
if is_on_wall():
|
||||
if velocity.x > -1 and velocity.x < 1:
|
||||
velocity.x = 0
|
||||
var was_on_floor = is_on_floor()
|
||||
velocity = move_and_slide(velocity, Vector2.UP)
|
||||
if !was_on_floor and is_on_floor():
|
||||
emit_signal("grounded_updated", is_on_floor())
|
||||
var was_grounded = is_grounded
|
||||
is_grounded = is_on_floor()
|
||||
|
||||
if Vector2.ZERO == velocity:
|
||||
velocity.y = -10
|
||||
|
28
ai/Skeleton Enemy.tscn
Normal file
28
ai/Skeleton Enemy.tscn
Normal file
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Skeleton Enemy.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/unknown.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 5, 7 )
|
||||
|
||||
[node name="Skeleton Enemy" type="KinematicBody2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 3
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="."]
|
||||
enabled = true
|
||||
cast_to = Vector2( -80, 0 )
|
||||
collision_mask = 3
|
||||
|
||||
[node name="RayCast2D2" type="RayCast2D" parent="."]
|
||||
enabled = true
|
||||
cast_to = Vector2( 80, 0 )
|
||||
collision_mask = 3
|
BIN
art/unknown.png
Normal file
BIN
art/unknown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
34
art/unknown.png.import
Normal file
34
art/unknown.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/unknown.png-7a4eff0f343d686ce2bdb9afaa03b634.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://art/unknown.png"
|
||||
dest_files=[ "res://.import/unknown.png-7a4eff0f343d686ce2bdb9afaa03b634.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://script/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://ui/PlayerStats.tscn" type="PackedScene" id=2]
|
||||
|
@ -9,10 +9,6 @@
|
|||
[sub_resource type="OccluderPolygon2D" id=1]
|
||||
polygon = PoolVector2Array( -7, 0, -7, -2, -6, -2, -6, -3, -5, -3, -5, -5, -6, -5, -6, -10, -7, -10, -7, -12, -6, -12, -6, -19, -4, -19, -4, -18, -3, -18, -3, -17, 1, -17, 1, -16, 3, -16, 3, -15, 4, -15, 4, -14, 5, -14, 5, -13, 6, -13, 6, -12, 7, -12, 7, -10, 6, -10, 6, -9, 5, -9, 5, -8, 6, -8, 6, -4, 5, -4, 5, 0, -7, 0 )
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 6.0
|
||||
height = 2.0
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "Idle"
|
||||
length = 0.8
|
||||
|
@ -94,11 +90,6 @@ visible = false
|
|||
position = Vector2( 0, 12 )
|
||||
occluder = SubResource( 1 )
|
||||
|
||||
[node name="WorldCollision" type="CollisionShape2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( 0, -7 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/Idle = SubResource( 3 )
|
||||
anims/Jumping = SubResource( 4 )
|
||||
|
@ -118,5 +109,8 @@ position = Vector2( 0, -7 )
|
|||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hitbox"]
|
||||
visible = false
|
||||
polygon = PoolVector2Array( -6, -12, -6, -5, -7, -5, -7, -3, -6, -3, -6, 2, -5, 2, -5, 4, -6, 4, -6, 5, -7, 5, -7, 7, 5, 7, 5, 3, 6, 3, 6, -1, 5, -1, 5, -2, 6, -2, 6, -3, 7, -3, 7, -5, 6, -5, 6, -6, 5, -6, 5, -7, 4, -7, 4, -8, 3, -8, 3, -9, 1, -9, 1, -10, -3, -10, -3, -11, -4, -11, -4, -12, -6, -12 )
|
||||
polygon = PoolVector2Array( -6, -12, -6, -5, -7, -5, -7, -3, -6, -3, -6, -0.52261, -6, 2, -5, 2, -5, 4, -6, 4, -6, 5, -7, 5, -7, 7, -3.9179, 7, 0.0151539, 7, 5, 7, 5, 5.0024, 5, 3, 6, 3, 6, 0.882053, 6, -1, 5, -1, 5, -2, 6, -2, 6, -3, 7, -3, 7, -5, 6, -5, 6, -6, 5, -6, 5, -7, 4, -7, 4, -8, 3, -8, 3, -9, 1, -9, 1, -10, -3, -10, -3, -11, -4, -11, -4, -12, -6, -12 )
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
|
||||
polygon = PoolVector2Array( 5, 0, 5, -4, 6, -4, 6, -8, 5, -8, 5, -9, 6, -9, 6, -10, 7, -10, 7, -12, 6, -12, 6, -13, 5, -13, 5, -14, 4, -14, 4, -15, 3, -15, 3, -16, 1, -16, 1, -17, -3, -17, -3, -18, -4, -18, -4, -19, -6, -19, -6, -12, -7, -12, -7, -10, -6, -10, -6, -5, -5, -5, -5, -3, -6, -3, -6, -2, -7, -2, -7, 0 )
|
||||
[connection signal="grounded_updated" from="." to="Camera" method="_on_grounded_updated"]
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://script/Projectile.gd" type="Script" id=1]
|
||||
[ext_resource path="res://art/WhiteProjectile.png" type="Texture" id=2]
|
||||
|
@ -6,6 +6,15 @@
|
|||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 4.0
|
||||
|
||||
[sub_resource type="Environment" id=2]
|
||||
background_mode = 4
|
||||
glow_enabled = true
|
||||
glow_intensity = 0.25
|
||||
glow_bloom = 0.15
|
||||
glow_blend_mode = 0
|
||||
glow_hdr_threshold = 3.29
|
||||
glow_bicubic_upscale = true
|
||||
|
||||
[node name="WhiteProjectile" type="KinematicBody2D"]
|
||||
collision_layer = 8
|
||||
collision_mask = 2
|
||||
|
@ -16,3 +25,6 @@ shape = SubResource( 1 )
|
|||
|
||||
[node name="WhiteProjectile" type="Sprite" parent="."]
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( 2 )
|
||||
|
|
|
@ -116,19 +116,13 @@ shoot={
|
|||
]
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
[layer_names]
|
||||
|
||||
2d_render/layer_1="Player"
|
||||
2d_physics/layer_1="Player"
|
||||
2d_render/layer_2="World"
|
||||
2d_physics/layer_2="World"
|
||||
2d_physics/layer_3="Enemy"
|
||||
2d_physics/layer_4="Projectiles"
|
||||
|
||||
>>>>>>> master
|
||||
[rendering]
|
||||
|
||||
quality/driver/fallback_to_gles2=true
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
|
20
script/Skeleton Enemy.gd
Normal file
20
script/Skeleton Enemy.gd
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var speed = 75
|
||||
var gravity = 500
|
||||
const UP = Vector2(0, -1)
|
||||
|
||||
var velocity = Vector2()
|
||||
|
||||
func apply_gravity(delta, modifier = 1):
|
||||
velocity.y += gravity * delta * modifier
|
||||
|
||||
func _physics_process(_delta):
|
||||
if Globals.player != null:
|
||||
velocity.x = position.direction_to(Globals.player).normalized().x
|
||||
apply_gravity(_delta)
|
||||
velocity = move_and_slide(velocity * speed)
|
||||
|
||||
if is_on_wall():
|
||||
velocity.y = -50
|
||||
velocity = move_and_slide(velocity, UP)
|
|
@ -32,6 +32,9 @@ onready var Stats = $Stats
|
|||
onready var health = Stats.health setget set_health, get_health
|
||||
onready var energy = Stats.energy setget set_energy, get_energy
|
||||
|
||||
func get_type():
|
||||
return "player"
|
||||
|
||||
func set_health(value):
|
||||
Stats.set_health(value)
|
||||
|
||||
|
@ -56,7 +59,6 @@ func _physics_process(delta):
|
|||
Globals.player = position
|
||||
emit_signal("grounded_updated", is_on_floor())
|
||||
|
||||
|
||||
func handle_move_input():
|
||||
input_direction = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left"))
|
||||
velocity.x = lerp(velocity.x, speed * input_direction, get_movement_weight())
|
||||
|
|
Loading…
Reference in a new issue