Merge branch 'develop' into feature/Coin

# Conflicts:
#	godot/Main.tscn
#	godot/project.godot
This commit is contained in:
2022-08-26 13:54:25 -04:00
33 changed files with 979 additions and 28 deletions

View File

@@ -1,11 +1,12 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Main.gdns" type="Script" id=1]
[ext_resource path="res://levels/Prototype.tscn" type="PackedScene" id=2]
[ext_resource path="res://monitor/Monitor.tscn" type="PackedScene" id=3]
[node name="Main" type="Node"]
pause_mode = 2
script = ExtResource( 1 )
level = ExtResource( 2 )
[node name="Monitor" parent="." instance=ExtResource( 3 )]
[node name="Level" type="Node" parent="."]
pause_mode = 1

View File

@@ -0,0 +1,38 @@
extends KinematicBody2D
signal player_touched
var velocity = Vector2()
export var direction = -1
export var detect_edges = true
export var speed = 25
export var gravity = 9.8
func _ready() -> void:
if direction == 1:
$AnimatedSprite.flip_h = true
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
$FloorChecker.enabled = detect_edges
func _physics_process(_delta: float) -> void:
if is_on_wall() or not $FloorChecker.is_colliding() and is_on_floor() and $FloorChecker.enabled:
direction *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h
$FloorChecker.position.x = $CollisionShape2D.shape.get_extents().x * direction
velocity.y += gravity
velocity.x = speed * direction
velocity = move_and_slide(velocity, Vector2.UP)
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == "Player":
emit_signal("player_touched")
func squash() -> void:
queue_free()

View File

@@ -0,0 +1,82 @@
extends KinematicBody2D
signal player_touched
export var direction = -1
export var speed = 50
export var follow_path = false
var target: Vector2 = Vector2(0, 0)
var target_id = 0
var start_position = Vector2()
func _ready() -> void:
start_position = position
if follow_path:
if $Path.get_child_count() == 0:
follow_path = false
else:
target = $Path.get_child(0).position
if direction == 1:
$AnimatedSprite.flip_h = true
func _physics_process(delta: float) -> void:
if $LeftWallChecker.is_colliding():
wall_checker_collided($LeftWallChecker)
elif $RightWallChecker.is_colliding():
wall_checker_collided($RightWallChecker)
if not follow_path:
var target_position = position
target_position.x *= 2 * direction
position = position.move_toward(target_position, round(speed * delta))
var velocity = get_velocity_towards_target(delta)
var collision = move_and_collide(velocity, true, true, true)
if collision and collision.collider.name != "Player":
var _collision = move_and_collide(velocity)
else:
var velocity = get_velocity_towards_target(delta)
var collision = move_and_collide(velocity, true, true, true)
if collision and collision.collider.name != "Player":
var _collision = move_and_collide(velocity)
else:
position = position.move_toward(start_position + target, round(speed * delta))
if position == start_position + target:
if $Path.get_child_count() - 1 == target_id:
target_id = -1
target = $Path.position
else:
target_id += 1
target = $Path.get_child(target_id).position
if start_position.x + target.x > position.x:
$AnimatedSprite.flip_h = true
elif start_position.x + target.x < position.x:
$AnimatedSprite.flip_h = false
func get_velocity_towards_target(delta: float) -> Vector2:
var velocity = Vector2(0, 0)
if start_position.x + target.x > position.x:
velocity.x = speed * delta
elif start_position.x + target.x < position.x:
velocity.x = -speed * delta
if start_position.y + target.y > position.y:
velocity.y = speed * delta
elif start_position.y + target.y < position.y:
velocity.y = -speed * delta
return velocity
func wall_checker_collided(wall_checker: RayCast2D) -> void:
if wall_checker.get_collider().name == "Player":
emit_signal("player_touched")
direction *= -1
$AnimatedSprite.flip_h = not $AnimatedSprite.flip_h

View File

@@ -0,0 +1,55 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[ext_resource path="res://characters/enemies/blightwing/Blightwing.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 144, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 168, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 192, 48, 24, 24 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ) ],
"loop": true,
"name": "fly",
"speed": 6.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 4.5, 5 )
[node name="Blightwing" type="KinematicBody2D" groups=["enemy", "rideable"]]
collision_layer = 8
collision_mask = 11
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 )
animation = "fly"
frame = 3
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 1.66894e-06, 1.5 )
rotation = 1.5708
shape = SubResource( 5 )
[node name="LeftWallChecker" type="RayCast2D" parent="."]
rotation = 1.5708
enabled = true
cast_to = Vector2( 0, 10 )
collision_mask = 11
[node name="RightWallChecker" type="RayCast2D" parent="."]
rotation = -1.5708
enabled = true
cast_to = Vector2( 0, 10 )
collision_mask = 11

View File

@@ -0,0 +1,27 @@
extends KinematicBody2D
signal player_touched
onready var start_position = position
var velocity = Vector2()
export var speed = 50.0
export var fall_speed = 75.0
var return_to_start: bool = false
func _physics_process(delta: float) -> void:
if return_to_start:
position = position.move_toward(start_position, speed * delta)
else:
var collision = move_and_collide(Vector2(0, (position.y + fall_speed) * delta))
if collision:
return_to_start = true
$AnimatedSprite.play("normal")
if collision.collider.name == "Player":
emit_signal("player_touched")
if position.y <= start_position.y:
return_to_start = false
$AnimatedSprite.play("angry")

View File

@@ -0,0 +1,40 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[ext_resource path="res://characters/enemies/blockface/Blockface.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 96, 24, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 120, 24, 24, 24 )
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "normal",
"speed": 5.0
}, {
"frames": [ SubResource( 2 ) ],
"loop": true,
"name": "angry",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 9, 9 )
[node name="Blockface" type="KinematicBody2D" groups=["enemy", "rideable"]]
collision_layer = 8
collision_mask = 11
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 3 )
animation = "normal"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 4 )

View File

@@ -0,0 +1 @@
extends "res://characters/enemies/WalkingEnemy.gd"

View File

@@ -0,0 +1,55 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 192, 24, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 144, 24, 24, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 168, 24, 24, 24 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "hide",
"speed": 5.0
}, {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "walk",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 7.5, 6.5 )
[node name="Dreadtooth" type="KinematicBody2D" groups=["enemy"]]
collision_layer = 8
collision_mask = 11
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 )
animation = "walk"
frame = 1
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( -0.5, 5.5 )
shape = SubResource( 5 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
polygon = PoolVector2Array( 0, -7, 3, -4, 3, -1, -4, -1, -4, -4, -1, -7 )
[node name="FloorChecker" type="RayCast2D" parent="."]
enabled = true
cast_to = Vector2( 0, 20 )
collision_mask = 10

View File

@@ -0,0 +1,35 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 48, 24, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 72, 24, 24, 24 )
[sub_resource type="SpriteFrames" id=3]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 5.5, 7.5 )
[node name="Gravevine" type="KinematicBody2D" groups=["enemy"]]
collision_layer = 8
collision_mask = 11
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 3 )
frame = 1
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( -0.5, 0.5 )
shape = SubResource( 4 )

View File

@@ -0,0 +1 @@
extends "res://characters/enemies/WalkingEnemy.gd"

View File

@@ -0,0 +1,51 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[ext_resource path="res://characters/enemies/shelly/Shelly.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 48, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 0, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 24, 48, 24, 24 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "hide",
"speed": 5.0
}, {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "walk",
"speed": 3.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 7.5, 6.5 )
[node name="Shelly" type="KinematicBody2D" groups=["enemy", "squashable"]]
collision_layer = 8
collision_mask = 11
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 )
animation = "walk"
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 1, 5.5 )
shape = SubResource( 5 )
[node name="FloorChecker" type="RayCast2D" parent="."]
enabled = true
cast_to = Vector2( 0, 20 )
collision_mask = 10

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 192, 0, 24, 24 )
[sub_resource type="SpriteFrames" id=2]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[sub_resource type="CircleShape2D" id=3]
radius = 9.05539
[node name="Spikeball" type="KinematicBody2D" groups=["enemy"]]
collision_layer = 8
collision_mask = 11
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 3 )

View File

@@ -0,0 +1 @@
extends "res://characters/enemies/WalkingEnemy.gd"

View File

@@ -0,0 +1,52 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/characters/characters.png" type="Texture" id=1]
[ext_resource path="res://characters/enemies/super_shelly/SuperShelly.gd" type="Script" id=2]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 120, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 72, 48, 24, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 96, 48, 24, 24 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 1 ) ],
"loop": true,
"name": "hide",
"speed": 5.0
}, {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "walk",
"speed": 3.0
} ]
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 12, 10.5 )
[node name="SuperShelly" type="KinematicBody2D" groups=["enemy", "squashable"]]
collision_layer = 8
collision_mask = 11
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 4 )
animation = "walk"
frame = 1
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, 1.5 )
shape = SubResource( 5 )
[node name="FloorChecker" type="RayCast2D" parent="."]
enabled = true
cast_to = Vector2( 0, 20 )
collision_mask = 10

View File

@@ -13,7 +13,7 @@
extents = Vector2( 7, 12 )
[node name="Player" type="KinematicBody2D"]
collision_mask = 2
collision_mask = 10
script = ExtResource( 5 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
@@ -42,6 +42,12 @@ script = ExtResource( 6 )
[node name="Fall" type="Node" parent="StateMachine"]
script = ExtResource( 7 )
[node name="PlatformDetector" type="RayCast2D" parent="."]
position = Vector2( 12, 0 )
enabled = true
cast_to = Vector2( 0, 32 )
collision_mask = 24
[node name="Sounds" type="Node" parent="."]
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.8" tiledversion="1.8.6" orientation="orthogonal" renderorder="right-down" width="128" height="32" tilewidth="18" tileheight="18" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="../tilesets/tiles.tsx"/>
<layer id="1" name="Middleground" width="128" height="32">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24
</data>
</layer>
</map>

View File

@@ -0,0 +1,24 @@
[remap]
importer="vnen.tiled_importer"
type="PackedScene"
path="res://.import/PrototypeEnemies.tmx-5728a1d35b5e3ba88a2df2406b1cd931.scn"
[deps]
source_file="res://levels/PrototypeEnemies.tmx"
dest_files=[ "res://.import/PrototypeEnemies.tmx-5728a1d35b5e3ba88a2df2406b1cd931.scn" ]
[params]
custom_properties=true
tile_metadata=false
uv_clip=false
y_sort=false
image_flags=0
collision_layer=2
collision_mask=0
embed_internal_images=false
save_tiled_properties=false
add_background=true
post_import_script=""

View File

@@ -0,0 +1,98 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://levels/PrototypeEnemies.tmx" type="PackedScene" id=3]
[ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4]
[ext_resource path="res://characters/enemies/gravevine/Gravevine.tscn" type="PackedScene" id=5]
[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.tscn" type="PackedScene" id=6]
[ext_resource path="res://characters/enemies/super_shelly/SuperShelly.tscn" type="PackedScene" id=7]
[ext_resource path="res://characters/enemies/spikeball/Spikeball.tscn" type="PackedScene" id=8]
[ext_resource path="res://characters/enemies/shelly/Shelly.tscn" type="PackedScene" id=9]
[ext_resource path="res://characters/enemies/blockface/Blockface.tscn" type="PackedScene" id=10]
[ext_resource path="res://characters/enemies/blightwing/Blightwing.tscn" type="PackedScene" id=11]
[node name="PrototypeEnemies" type="Node"]
[node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( 156, 438 )
collision/safe_margin = 0.12
[node name="Camera2D" type="Camera2D" parent="Player"]
current = true
limit_left = 0
limit_top = 0
limit_right = 512
limit_bottom = 288
drag_margin_h_enabled = true
drag_margin_v_enabled = true
__meta__ = {
"_edit_bone_": true
}
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="Player/Camera2D"]
rect = Rect2( 0, 0, 24, 24 )
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]
motion_scale = Vector2( 0.2, 0.1 )
motion_offset = Vector2( 0, -288 )
motion_mirroring = Vector2( 528, 0 )
[node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"]
texture = ExtResource( 4 )
centered = false
[node name="Map" type="Node" parent="."]
[node name="PrototypeEnemies" parent="Map" instance=ExtResource( 3 )]
script = ExtResource( 1 )
[node name="Enemies" type="Node" parent="."]
unique_name_in_owner = true
[node name="Spikeball" parent="Enemies" instance=ExtResource( 8 )]
position = Vector2( 106, 547 )
[node name="Blightwing" parent="Enemies" instance=ExtResource( 11 )]
position = Vector2( 488, 400 )
follow_path = true
[node name="Path" type="Node2D" parent="Enemies/Blightwing"]
[node name="Node2D" type="Node2D" parent="Enemies/Blightwing/Path"]
position = Vector2( 0, 96 )
[node name="Node2D2" type="Node2D" parent="Enemies/Blightwing/Path"]
position = Vector2( -128, 96 )
[node name="Node2D3" type="Node2D" parent="Enemies/Blightwing/Path"]
position = Vector2( -128, 0 )
[node name="Blockface" parent="Enemies" instance=ExtResource( 10 )]
position = Vector2( 206, 404 )
[node name="Dreadtooth" parent="Enemies" instance=ExtResource( 6 )]
position = Vector2( 316, 379 )
[node name="Dreadtooth2" parent="Enemies" instance=ExtResource( 6 )]
position = Vector2( 350, 263 )
direction = 1
detect_edges = false
[node name="Gravevine" parent="Enemies" instance=ExtResource( 5 )]
position = Vector2( 250, 550 )
[node name="Shelly" parent="Enemies" instance=ExtResource( 9 )]
position = Vector2( 247, 439 )
[node name="SuperShelly" parent="Enemies" instance=ExtResource( 7 )]
position = Vector2( 62, 546 )
[connection signal="player_touched" from="Enemies/Blightwing" to="Player" method="_on_player_touched"]
[connection signal="player_touched" from="Enemies/Blockface" to="Player" method="_on_player_touched"]
[connection signal="player_touched" from="Enemies/Dreadtooth" to="Player" method="_on_player_touched"]
[connection signal="player_touched" from="Enemies/Dreadtooth2" to="Player" method="_on_player_touched"]
[connection signal="player_touched" from="Enemies/Shelly" to="Player" method="_on_player_touched"]
[connection signal="player_touched" from="Enemies/SuperShelly" to="Player" method="_on_player_touched"]

View File

@@ -114,6 +114,10 @@ func show_error_message(message: String) -> void:
func _on_PopupDialog_gui_input(event: InputEvent) -> void:
if event.is_pressed():
var popup = get_node("%PopupDialog")
popup.hide()
var popup = get_node("%PopupDialog")
if popup.visible and event.is_pressed():
popup.call_deferred("hide")
func _on_text_entered(_new_text: String) -> void:
call_deferred("_on_Button_pressed")

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://assets/fonts/data/PixelOperator.tres" type="DynamicFontData" id=1]
[ext_resource path="res://assets/fonts/data/PixelOperator-Bold.tres" type="DynamicFontData" id=2]
@@ -7,12 +7,14 @@
[ext_resource path="res://monitor/EnterButton.gd" type="Script" id=5]
[ext_resource path="res://assets/sounds/ui_popup.wav" type="AudioStream" id=6]
[ext_resource path="res://assets/sounds/ui_select.wav" type="AudioStream" id=7]
[ext_resource path="res://monitor/MonitorGUI.gd" type="Script" id=8]
[sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=14]
size = 8
extra_spacing_top = 4
font_data = ExtResource( 1 )
[sub_resource type="StyleBoxFlat" id=13]
@@ -68,6 +70,7 @@ font_data = ExtResource( 2 )
[node name="MonitorGUI" type="CanvasLayer"]
pause_mode = 2
script = ExtResource( 8 )
[node name="ColorRect" type="ColorRect" parent="."]
margin_right = 40.0
@@ -234,9 +237,12 @@ valign = 1
autowrap = true
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Name" to="GUI/Sounds" method="_play_ui_select_sound"]
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Name" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/Sounds" method="_play_ui_select_sound"]
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" method="_on_Rut_text_changed"]
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Email" to="GUI/Sounds" method="_play_ui_select_sound"]
[connection signal="text_entered" from="GUI/VBoxContainer/CenterContainer2/VBoxContainer2/Email" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_text_entered"]
[connection signal="focus_entered" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/Sounds" method="_play_ui_select_sound"]
[connection signal="pressed" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_Button_pressed"]
[connection signal="focus_entered" from="PopupDialog" to="GUI/Sounds" method="_play_popup_sound"]

View File

@@ -1,6 +1,9 @@
extends Node
signal monitor_loaded()
export var monitor_enabled: bool = false
export var development_url: String = "http://localhost:4050/api/v1"
var url_real: String = "https://alai.cromer.cl/api/v1"
@@ -85,7 +88,7 @@ func _ready() -> void:
game["screen_size"] = screen_size
game["game_version"] = game_version
game["won"] = false
game["timestamp"] = OS.get_unix_time()
game["timestamp"] = int(Time.get_unix_time_from_system())
game["frames"] = frames
var err = $HTTPRequest.connect("request_completed", self, "_on_request_completed")
@@ -101,13 +104,14 @@ func _physics_process(_delta: float) -> void:
if monitor_enabled:
if has_node("MonitorGUI") and not $MonitorGUI.visible:
$MonitorGUI.visible = true
emit_signal("monitor_loaded")
if started and not get_tree().paused:
var frame = empty_frame.duplicate(true)
frame["coins"] = coins
frame["points"] = points
frame["fps"] = Engine.get_frames_per_second()
frame["elapsed_time"] = OS.get_ticks_msec() - start_time
frame["elapsed_time"] = Time.get_ticks_msec() - start_time
var frame_objects = objects.duplicate()
frame["objects"] = frame_objects
@@ -122,6 +126,7 @@ func _physics_process(_delta: float) -> void:
start_monitor()
else:
get_tree().paused = false
emit_signal("monitor_loaded")
queue_free()
@@ -129,21 +134,22 @@ func _on_input_validated(validated_player: Dictionary) -> void:
$MonitorGUI.queue_free()
get_tree().paused = false
player = validated_player.duplicate(true)
game["player"] = player
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
if monitor_enabled and started:
if monitor_enabled:
add_object(name, state, position, velocity)
func _object_updated(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
if monitor_enabled and started:
if monitor_enabled:
remove_object(name)
add_object(name, state, position, velocity)
func _object_removed(name: String) -> void:
if monitor_enabled and started:
if monitor_enabled:
remove_object(name)
@@ -151,8 +157,8 @@ func start_monitor() -> void:
frames.clear()
game["level_id"] = 2 # PrototypeR
game["won"] = false
game["timestamp"] = OS.get_unix_time()
start_time = OS.get_ticks_msec()
game["timestamp"] = int(Time.get_unix_time_from_system())
start_time = Time.get_ticks_msec()
started = true
@@ -174,8 +180,8 @@ func add_object(name: String, state: String, position: Vector2, velocity: Vector
func remove_object(name: String) -> void:
for i in range(0, objects.size()):
if objects[i]["name"] == name:
objects.remove(i)
if objects[i]["name"] == name:
objects.remove(i)
func _on_coin_update(amount: int) -> void:

View File

@@ -6,10 +6,9 @@
[node name="Monitor" type="Node"]
pause_mode = 2
script = ExtResource( 1 )
monitor_enabled = true
use_development_url = true
[node name="MonitorGUI" parent="." instance=ExtResource( 3 )]
visible = false
[node name="HTTPRequest" type="HTTPRequest" parent="."]
pause_mode = 2

View File

@@ -0,0 +1,12 @@
extends CanvasLayer
export var default_name = ""
export var default_rut = ""
export var default_email = ""
func _ready() -> void:
get_node("%Name").text = default_name
get_node("%Rut").text = default_rut
get_node("%Email").text = default_email

View File

@@ -19,7 +19,7 @@ config/icon="res://icon.png"
window/size/width=512
window/size/height=288
window/stretch/mode="viewport"
window/stretch/mode="2d"
window/stretch/aspect="keep"
[editor]
@@ -101,6 +101,8 @@ Send={
2d_physics/layer_1="Player"
2d_physics/layer_2="Tiles"
2d_physics/layer_3="Collectables"
2d_physics/layer_4="Enemies"
2d_physics/layer_5="Platforms"
2d_physics/layer_6="End Level"
[physics]

View File

@@ -0,0 +1,73 @@
shader_type canvas_item;
const float PI = 3.14159;
uniform vec2 resolution = vec2(1024.0, 576.0);
uniform bool show_curve = false;
uniform bool show_vignette = false;
uniform bool show_horizontal_scan_lines = true;
uniform bool show_vertical_scan_lines = false;
uniform bool gray_scale = false;
uniform float curvature_x_amount : hint_range(3.0, 15.0, 0.01) = 6.0;
uniform float curvature_y_amount : hint_range(3.0, 15.0, 0.01) = 6.0;
uniform vec4 corner_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float vignette_size : hint_range(1, 300, 0.1) = 4.0;
uniform float vignette_opacity : hint_range(0.0, 1.0, 0.01) = 1.0;
const float brightness = 3.0;
vec2 uv_curve(vec2 uv) {
if (show_curve) {
uv = uv * 2.0 - 1.0;
vec2 offset = abs(uv.yx) / vec2(curvature_x_amount, curvature_y_amount);
uv = uv + uv * offset * offset;
uv = uv * 0.5 + 0.5;
}
return uv;
}
void fragment() {
vec2 screen_uv = uv_curve(SCREEN_UV);
vec3 color = texture(SCREEN_TEXTURE, screen_uv).rgb;
if (show_horizontal_scan_lines || show_vertical_scan_lines) {
color.r = texture(SCREEN_TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x * 0.0), 0.0).r;
color.g = texture(SCREEN_TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x * 0.0), 0.0).g;
color.b = texture(SCREEN_TEXTURE, uv_curve(SCREEN_UV) + vec2(SCREEN_PIXEL_SIZE.x * 0.0), 0.0).b;
}
if (show_vignette) {
float vignette = UV.x * UV.y * (1.0 - UV.x) * (1.0 - UV.y);
vignette = clamp(pow((resolution.x / vignette_size) * vignette, vignette_opacity), 0.0, 1.0);
color *= vignette;
}
if (show_horizontal_scan_lines) {
float s = sin(uv_curve(SCREEN_UV).y * resolution.y / 2.0 * PI);
s = (s * 0.5 + 0.5) * 0.9 + 0.1;
vec4 scan_line = vec4(vec3(pow(s, 0.25)), 1.0);
color *= scan_line.rgb;
}
if (show_vertical_scan_lines) {
float s = sin(uv_curve(SCREEN_UV).x * resolution.x / 2.0 * PI);
s = (s * 0.5 + 0.5) * 0.9 + 0.1;
vec4 scan_line = vec4(vec3(pow(s, 0.25)), 1.0);
color *= scan_line.rgb;
}
if (show_curve) {
if (screen_uv.x < 0.0 || screen_uv.x > 1.0 || screen_uv.y < 0.0 || screen_uv.y > 1.0) {
color = corner_color.rgb;
}
}
if (gray_scale) {
float avg = (color.r + color.g + color.b) / brightness;
color = vec3(avg);
}
COLOR = vec4(color, 1.0);
}

View File

@@ -0,0 +1,17 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[ext_resource path="res://shaders/crt/crt.shader" type="Shader" id=1]
[resource]
shader = ExtResource( 1 )
shader_param/resolution = Vector2( 1280, 720 )
shader_param/show_curve = false
shader_param/show_vignette = false
shader_param/show_horizontal_scan_lines = true
shader_param/show_vertical_scan_lines = false
shader_param/gray_scale = false
shader_param/curvature_x_amount = 6.0
shader_param/curvature_y_amount = 6.0
shader_param/corner_color = Color( 0, 0, 0, 1 )
shader_param/vignette_size = 4.0
shader_param/vignette_opacity = 1.0

View File

@@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://shaders/crt/crt.tres" type="Material" id=1]
[node name="CRT" type="CanvasLayer"]
[node name="ColorRect" type="ColorRect" parent="."]
material = ExtResource( 1 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2