Compare commits
No commits in common. "58553d00b6c922f939cdd276331e6826aaa42041" and "52602364f30964e25daafd09e20c5fa498209e70" have entirely different histories.
58553d00b6
...
52602364f3
|
@ -1,19 +0,0 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="Shader" id=3]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform bool active = false;
|
||||
uniform vec4 color: hint_color = vec4(1, 1, 1, 1);
|
||||
|
||||
void fragment(){
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
if (active) {
|
||||
COLOR = vec4(COLOR.rgb + color.rgb * color.a, COLOR.a)
|
||||
}
|
||||
}"
|
||||
|
||||
[resource]
|
||||
shader = SubResource( 3 )
|
||||
shader_param/active = false
|
||||
shader_param/color = Color( 1, 1, 1, 1 )
|
|
@ -1,11 +0,0 @@
|
|||
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://res/shaders/outline.tres" type="Shader" id=1]
|
||||
|
||||
[resource]
|
||||
shader = ExtResource( 1 )
|
||||
shader_param/color = Color( 1, 0.870588, 0, 1 )
|
||||
shader_param/width = 1.0
|
||||
shader_param/pattern = 0
|
||||
shader_param/inside = false
|
||||
shader_param/add_margins = true
|
|
@ -9,7 +9,7 @@ extents = Vector2( 4, 3 )
|
|||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 6, 4 )
|
||||
|
||||
[node name="Bat" type="KinematicBody2D" groups=["bat", "enemy"]]
|
||||
[node name="Bat" type="KinematicBody2D" groups=["enemy"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 2
|
||||
script = ExtResource( 2 )
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://src/models/player/sprite.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/models/player/player.gd" type="Script" id=2]
|
||||
[ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 4, 5.5 )
|
||||
|
@ -10,67 +9,10 @@ extents = Vector2( 4, 5.5 )
|
|||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 7, 11 )
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "RESET"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:material:shader_param/color")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:material:shader_param/active")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ false ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "damage"
|
||||
length = 0.9
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:material:shader_param/active")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 2 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ true, false ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:material:shader_param/color")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.15, 0.3, 0.45, 0.6, 0.75, 0.9 ),
|
||||
"transitions": PoolRealArray( 8, 8, 8, 8, 8, 8, 8 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
|
||||
[node name="Player" type="KinematicBody2D" groups=["player"]]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = ExtResource( 3 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
|
@ -83,10 +25,3 @@ shape = SubResource( 1 )
|
|||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyCollision"]
|
||||
position = Vector2( 12, 12 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
autoplay = "RESET"
|
||||
anims/RESET = SubResource( 4 )
|
||||
anims/damage = SubResource( 3 )
|
||||
|
||||
[connection signal="area_entered" from="EnemyCollision" to="." method="area_entered"]
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var outline_material = load("res://res/shaders/outline_material.tres")
|
||||
var speed_multiplier: float = 1.0
|
||||
var invincibility_timer = .0
|
||||
var velocity = Vector2.ZERO
|
||||
var invincible = false
|
||||
var target: EnemyClass
|
||||
var speed_multiplier: float = 1.0
|
||||
var slowed = false
|
||||
var target
|
||||
var speed = 100
|
||||
|
||||
onready var bullet = preload("res://src/models/bullet/Bullet.tscn")
|
||||
|
@ -16,35 +13,13 @@ func _process(_delta):
|
|||
if Input.is_action_just_pressed("shoot"):
|
||||
_shoot()
|
||||
|
||||
|
||||
func get_input():
|
||||
var input_direction = Input.get_vector("left", "right", "up", "down")
|
||||
velocity = input_direction * speed
|
||||
|
||||
func choose_target():
|
||||
var least_dist = 4000
|
||||
var enemy_dist
|
||||
var enemies = get_tree().get_nodes_in_group("enemy")
|
||||
for enemy in enemies:
|
||||
enemy.material = null
|
||||
enemy_dist = global_position.distance_to(enemy.global_position)
|
||||
if enemy_dist < least_dist:
|
||||
least_dist = enemy_dist
|
||||
target = enemy
|
||||
|
||||
func area_entered(area):
|
||||
var parent = area.get_parent()
|
||||
if parent.is_in_group("enemy") and not parent.is_in_group("bat") and not invincible:
|
||||
$AnimationPlayer.play("damage")
|
||||
Global.add_health(-1)
|
||||
invincible = true
|
||||
invincibility_timer = .0
|
||||
|
||||
func _physics_process(delta):
|
||||
func _physics_process(_delta):
|
||||
get_input()
|
||||
|
||||
invincibility_timer += delta
|
||||
|
||||
var areas = $EnemyCollision.get_overlapping_areas()
|
||||
slowed = false
|
||||
for area in areas:
|
||||
|
@ -52,9 +27,6 @@ func _physics_process(delta):
|
|||
slowed = true
|
||||
break
|
||||
|
||||
if invincible and invincibility_timer >= 0.9:
|
||||
invincible = false
|
||||
|
||||
if slowed:
|
||||
speed_multiplier = 0.5
|
||||
else:
|
||||
|
@ -62,7 +34,19 @@ func _physics_process(delta):
|
|||
|
||||
velocity = move_and_slide(velocity * speed_multiplier)
|
||||
choose_target()
|
||||
target.material = outline_material
|
||||
|
||||
const SHADER = preload("res://res/shaders/outline.tres")
|
||||
|
||||
func choose_target():
|
||||
var least_dist = 4000
|
||||
var enemy_dist
|
||||
var enemies = get_tree().get_nodes_in_group("enemy")
|
||||
for enemy in enemies:
|
||||
enemy_dist = global_position.distance_to(enemy.global_position)
|
||||
if enemy_dist < least_dist:
|
||||
least_dist = enemy_dist
|
||||
target = enemy
|
||||
#enemy.set_shader_param("width", 0)
|
||||
|
||||
func _shoot():
|
||||
bullet_instance = bullet.instance()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=2]
|
||||
[gd_scene load_steps=24 format=2]
|
||||
|
||||
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
|
||||
|
@ -15,6 +15,7 @@
|
|||
[ext_resource path="res://src/models/enemies/trash_can/TrashCan.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://res/shaders/outline.tres" type="Shader" id=16]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 10, 60 )
|
||||
|
@ -22,6 +23,30 @@ extents = Vector2( 10, 60 )
|
|||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 140, 10.125 )
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=5]
|
||||
shader = ExtResource( 16 )
|
||||
shader_param/color = Color( 1, 0.870588, 0, 1 )
|
||||
shader_param/width = 1.0
|
||||
shader_param/pattern = 0
|
||||
shader_param/inside = false
|
||||
shader_param/add_margins = true
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=6]
|
||||
shader = ExtResource( 16 )
|
||||
shader_param/color = Color( 1, 0.870588, 0, 1 )
|
||||
shader_param/width = 1.0
|
||||
shader_param/pattern = 0
|
||||
shader_param/inside = false
|
||||
shader_param/add_margins = true
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=7]
|
||||
shader = ExtResource( 16 )
|
||||
shader_param/color = Color( 1, 0.870588, 0, 1 )
|
||||
shader_param/width = 1.0
|
||||
shader_param/pattern = 0
|
||||
shader_param/inside = true
|
||||
shader_param/add_margins = true
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 8
|
||||
font_data = ExtResource( 4 )
|
||||
|
@ -76,13 +101,16 @@ shape = SubResource( 3 )
|
|||
[node name="TrashCan" parent="View/Enemies" instance=ExtResource( 13 )]
|
||||
|
||||
[node name="Bat" parent="View/Enemies" instance=ExtResource( 14 )]
|
||||
material = SubResource( 5 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Bat2" parent="View/Enemies" instance=ExtResource( 14 )]
|
||||
material = SubResource( 6 )
|
||||
position = Vector2( 142, 54 )
|
||||
z_index = 1
|
||||
|
||||
[node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )]
|
||||
material = SubResource( 7 )
|
||||
position = Vector2( 509, 100 )
|
||||
|
||||
[node name="Player" parent="View" instance=ExtResource( 5 )]
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
extends Node
|
||||
|
||||
func _ready():
|
||||
Global.health = 3
|
||||
Global.add_health(0)
|
||||
Global.add_health(1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Node
|
||||
|
||||
func game_start():
|
||||
Global.game_start()
|
||||
get_tree().change_scene_to(Global.GAME_SCENE)
|
||||
|
||||
func game_exit():
|
||||
get_tree().quit(0)
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
extends Node
|
||||
|
||||
var GAME_SCENE = preload("res://src/scenes/game/Game.tscn")
|
||||
var MENU_SCENE = preload("res://src/scenes/menu/Menu.tscn")
|
||||
|
||||
var playing = true
|
||||
var health = 2
|
||||
|
||||
func game_start():
|
||||
playing = true
|
||||
get_tree().change_scene_to(GAME_SCENE)
|
||||
|
||||
func return_to_menu():
|
||||
playing = false
|
||||
get_tree().change_scene_to(MENU_SCENE)
|
||||
|
||||
func add_health(amount):
|
||||
health = clamp(health + amount, 0, 3)
|
||||
get_tree().get_root().get_node("Game/UIWrapper/UI/Health/HealthSprite").frame = health
|
||||
if health == 0:
|
||||
return_to_menu() # TODO endgame
|
||||
pass # TODO endgame
|
||||
|
|
Loading…
Reference in New Issue