develop #34
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,4 +1,4 @@
|
||||
[submodule "godot-cpp"]
|
||||
path = godot-cpp
|
||||
url = https://github.com/godotengine/godot-cpp
|
||||
branch = 3.4
|
||||
branch = 3.5
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ced274fbe62c07dd9bb6791a77392f4bdc625152
|
||||
Subproject commit 867374da404887337909e8b7b9de5a8acbc47569
|
@ -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
|
||||
|
38
godot/characters/enemies/WalkingEnemy.gd
Normal file
38
godot/characters/enemies/WalkingEnemy.gd
Normal 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()
|
82
godot/characters/enemies/blightwing/Blightwing.gd
Normal file
82
godot/characters/enemies/blightwing/Blightwing.gd
Normal 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
|
55
godot/characters/enemies/blightwing/Blightwing.tscn
Normal file
55
godot/characters/enemies/blightwing/Blightwing.tscn
Normal 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
|
27
godot/characters/enemies/blockface/Blockface.gd
Normal file
27
godot/characters/enemies/blockface/Blockface.gd
Normal 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")
|
40
godot/characters/enemies/blockface/Blockface.tscn
Normal file
40
godot/characters/enemies/blockface/Blockface.tscn
Normal 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 )
|
1
godot/characters/enemies/dreadtooth/Dreadtooth.gd
Normal file
1
godot/characters/enemies/dreadtooth/Dreadtooth.gd
Normal file
@ -0,0 +1 @@
|
||||
extends "res://characters/enemies/WalkingEnemy.gd"
|
55
godot/characters/enemies/dreadtooth/Dreadtooth.tscn
Normal file
55
godot/characters/enemies/dreadtooth/Dreadtooth.tscn
Normal 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
|
35
godot/characters/enemies/gravevine/Gravevine.tscn
Normal file
35
godot/characters/enemies/gravevine/Gravevine.tscn
Normal 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 )
|
1
godot/characters/enemies/shelly/Shelly.gd
Normal file
1
godot/characters/enemies/shelly/Shelly.gd
Normal file
@ -0,0 +1 @@
|
||||
extends "res://characters/enemies/WalkingEnemy.gd"
|
51
godot/characters/enemies/shelly/Shelly.tscn
Normal file
51
godot/characters/enemies/shelly/Shelly.tscn
Normal 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
|
28
godot/characters/enemies/spikeball/Spikeball.tscn
Normal file
28
godot/characters/enemies/spikeball/Spikeball.tscn
Normal 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 )
|
1
godot/characters/enemies/super_shelly/SuperShelly.gd
Normal file
1
godot/characters/enemies/super_shelly/SuperShelly.gd
Normal file
@ -0,0 +1 @@
|
||||
extends "res://characters/enemies/WalkingEnemy.gd"
|
52
godot/characters/enemies/super_shelly/SuperShelly.tscn
Normal file
52
godot/characters/enemies/super_shelly/SuperShelly.tscn
Normal 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
|
@ -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"]
|
||||
|
40
godot/levels/PrototypeEnemies.tmx
Normal file
40
godot/levels/PrototypeEnemies.tmx
Normal 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,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,
|
||||
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>
|
24
godot/levels/PrototypeEnemies.tmx.import
Normal file
24
godot/levels/PrototypeEnemies.tmx.import
Normal 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=""
|
98
godot/levels/PrototypeEnemies.tscn
Normal file
98
godot/levels/PrototypeEnemies.tscn
Normal 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"]
|
@ -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")
|
||||
|
@ -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"]
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
12
godot/monitor/MonitorGUI.gd
Normal file
12
godot/monitor/MonitorGUI.gd
Normal 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
|
@ -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]
|
||||
|
73
godot/shaders/crt/crt.shader
Normal file
73
godot/shaders/crt/crt.shader
Normal 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);
|
||||
}
|
17
godot/shaders/crt/crt.tres
Normal file
17
godot/shaders/crt/crt.tres
Normal 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
|
11
godot/shaders/crt/crt.tscn
Normal file
11
godot/shaders/crt/crt.tscn
Normal 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
|
69
src/Main.cpp
69
src/Main.cpp
@ -9,11 +9,13 @@ void Main::_register_methods()
|
||||
{
|
||||
register_method("_ready", &Main::_ready);
|
||||
register_method("_physics_process", &Main::_physics_process);
|
||||
register_method("_on_monitor_loaded", &Main::_on_monitor_loaded);
|
||||
register_property<Main, String>("game_version", &Main::set_game_version, &Main::get_game_version, String(main::game_version.c_str()));
|
||||
register_property<Main, Ref<PackedScene>>("level", &Main::set_level, &Main::get_level, NULL, GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("PackedScene"));
|
||||
register_property<Main, bool>("full_screen", &Main::set_full_screen, &Main::get_full_screen, main::full_screen);
|
||||
register_property<Main, Vector2>("window_size", &Main::set_window_size, &Main::get_window_size, main::window_size);
|
||||
register_property<Main, int8_t>("launch_screen", &Main::set_launch_screen, &Main::get_launch_screen, main::launch_screen);
|
||||
register_signal<Main>("monitor_loaded");
|
||||
}
|
||||
|
||||
Main::Main()
|
||||
@ -28,6 +30,8 @@ void Main::_init()
|
||||
{
|
||||
_os = OS::get_singleton();
|
||||
_input = Input::get_singleton();
|
||||
_project_settings = ProjectSettings::get_singleton();
|
||||
_resource_loader = ResourceLoader::get_singleton();
|
||||
|
||||
game_version = String(main::game_version.c_str());
|
||||
full_screen = main::full_screen;
|
||||
@ -37,7 +41,24 @@ void Main::_init()
|
||||
|
||||
void Main::_ready()
|
||||
{
|
||||
get_tree()->set_pause(true);
|
||||
auto success = _project_settings->load_resource_pack("monitor.pck");
|
||||
if (success)
|
||||
{
|
||||
// Load monitor from pck
|
||||
Godot::print("Monitor pck found, loading...");
|
||||
load_monitor();
|
||||
}
|
||||
else if (_resource_loader->exists("res://monitor/Monitor.tscn"))
|
||||
{
|
||||
// Load monitor from alai's pck
|
||||
load_monitor();
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is no monitor included
|
||||
_on_monitor_loaded();
|
||||
}
|
||||
|
||||
if (get_full_screen())
|
||||
{
|
||||
_os->set_window_fullscreen(true);
|
||||
@ -50,10 +71,52 @@ void Main::_ready()
|
||||
);
|
||||
}
|
||||
|
||||
if (level != NULL)
|
||||
success = _project_settings->load_resource_pack("crt.pck");
|
||||
if (success)
|
||||
{
|
||||
add_child(level->instance());
|
||||
// Load crt from pck
|
||||
Godot::print("CRT pck found, loading...");
|
||||
Ref<PackedScene> crt_scene = _resource_loader->load("res://shaders/crt/crt.tscn");
|
||||
add_child(crt_scene->instance());
|
||||
}
|
||||
else if (_resource_loader->exists("res://shaders/crt/crt.tscn"))
|
||||
{
|
||||
// Load crt from alai's pck
|
||||
Ref<PackedScene> crt_scene = _resource_loader->load("res://shaders/crt/crt.tscn");
|
||||
add_child(crt_scene->instance());
|
||||
}
|
||||
}
|
||||
|
||||
void Main::_on_monitor_loaded()
|
||||
{
|
||||
if (level != nullptr)
|
||||
{
|
||||
auto level_node = load_level();
|
||||
connect("monitor_loaded", level_node->get_child(0)->find_node("Player", true, false), "_on_monitor_loaded");
|
||||
emit_signal("monitor_loaded");
|
||||
}
|
||||
}
|
||||
|
||||
void Main::load_monitor()
|
||||
{
|
||||
Ref<PackedScene> monitor_scene = _resource_loader->load("res://monitor/Monitor.tscn");
|
||||
add_child(monitor_scene->instance());
|
||||
auto monitor = get_node("Monitor");
|
||||
monitor->connect("monitor_loaded", this, "_on_monitor_loaded");
|
||||
get_tree()->set_pause(true);
|
||||
}
|
||||
|
||||
Node *Main::load_level()
|
||||
{
|
||||
if (level != nullptr)
|
||||
{
|
||||
auto path = level->get_path();
|
||||
auto loaded_level = level->instance();
|
||||
auto level_node = get_node("Level");
|
||||
level_node->add_child(loaded_level);
|
||||
return level_node;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Main::_physics_process(float delta)
|
||||
|
17
src/Main.h
17
src/Main.h
@ -8,6 +8,8 @@
|
||||
#include <Input.hpp>
|
||||
#include <PackedScene.hpp>
|
||||
#include <Ref.hpp>
|
||||
#include <ProjectSettings.hpp>
|
||||
#include <ResourceLoader.hpp>
|
||||
|
||||
/**
|
||||
* @brief This is the godot namespace for all the code included in the library.
|
||||
@ -64,6 +66,16 @@ namespace godot
|
||||
*
|
||||
*/
|
||||
Input *_input;
|
||||
/**
|
||||
* @brief ProjectSettings singleton.
|
||||
*
|
||||
*/
|
||||
ProjectSettings *_project_settings;
|
||||
/**
|
||||
* @brief ResourceLoader singleton.
|
||||
*
|
||||
*/
|
||||
ResourceLoader *_resource_loader;
|
||||
|
||||
/**
|
||||
* @brief The first level to load
|
||||
@ -204,6 +216,11 @@ namespace godot
|
||||
* @return int8_t The launch screen.
|
||||
*/
|
||||
int8_t get_launch_screen();
|
||||
|
||||
void _on_monitor_loaded();
|
||||
|
||||
void load_monitor();
|
||||
Node *load_level();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <SceneTree.hpp>
|
||||
#include <Texture.hpp>
|
||||
#include <Viewport.hpp>
|
||||
#include <RayCast2D.hpp>
|
||||
#include <KinematicCollision2D.hpp>
|
||||
|
||||
using namespace godot;
|
||||
using namespace player;
|
||||
@ -16,9 +18,12 @@ void Player::_register_methods()
|
||||
register_method("_physics_process", &Player::_physics_process);
|
||||
register_method("set_velocity", &Player::set_velocity);
|
||||
register_method("get_velocity", &Player::get_velocity);
|
||||
register_method("_on_player_touched", &Player::_on_player_touched);
|
||||
register_method("_on_monitor_loaded", &Player::_on_monitor_loaded);
|
||||
//register_property<Player, Ref<SpriteFrames>>("sprite_frames", &Player::set_sprite_frames, &Player::get_sprite_frames, Ref<SpriteFrames>(), GODOT_METHOD_RPC_MODE_DISABLED, GODOT_PROPERTY_USAGE_DEFAULT, GODOT_PROPERTY_HINT_RESOURCE_TYPE, String("SpriteFrames"));
|
||||
register_property<Player, float>("speed", &Player::set_speed, &Player::get_speed, player::speed);
|
||||
register_property<Player, float>("jump_force", &Player::set_jump_force, &Player::get_jump_force, player::jump_force);
|
||||
register_property<Player, float>("bounce_force", &Player::set_bounce_force, &Player::get_bounce_force, player::bounce_force);
|
||||
register_property<Player, float>("gravity", &Player::set_gravity, &Player::get_gravity, player::gravity);
|
||||
register_property<Player, float>("run_speed", &Player::set_run_speed, &Player::get_run_speed, player::run_speed);
|
||||
register_property<Player, bool>("double_jump", &Player::set_double_jump, &Player::get_double_jump, player::double_jump);
|
||||
@ -42,6 +47,7 @@ void Player::_init()
|
||||
//sprite_frames = _resource_loader->load(player::sprite_frames);
|
||||
set_speed(player::speed);
|
||||
set_jump_force(player::jump_force);
|
||||
set_bounce_force(player::bounce_force);
|
||||
set_gravity(player::gravity);
|
||||
set_run_speed(player::run_speed);
|
||||
set_double_jump(player::double_jump);
|
||||
@ -72,8 +78,10 @@ void Player::_ready()
|
||||
{
|
||||
WARN_PRINT("Middleground not found!");
|
||||
}
|
||||
}
|
||||
|
||||
auto object_node = get_tree()->get_root()->get_node("Main")->find_node("Monitor");
|
||||
void Player::_on_monitor_loaded() {
|
||||
auto object_node = get_tree()->get_root()->find_node("Monitor", true, false);
|
||||
if (object_node != nullptr)
|
||||
{
|
||||
auto state = get_node("StateMachine")->get_child(0);
|
||||
@ -89,19 +97,66 @@ void Player::_ready()
|
||||
WARN_PRINT("State not found!");
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else
|
||||
{
|
||||
WARN_PRINT("Data not found!");
|
||||
WARN_PRINT("Monitor not found!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Player::_physics_process(float delta)
|
||||
{
|
||||
velocity.y += get_gravity();
|
||||
|
||||
velocity = move_and_slide(velocity, Vector2::UP, true);
|
||||
auto snap_vector = Vector2::ZERO;
|
||||
if (!is_on_floor())
|
||||
{
|
||||
snap_vector = Vector2::DOWN * 20.0;
|
||||
}
|
||||
|
||||
auto platform_detector = get_node<RayCast2D>("PlatformDetector");
|
||||
auto is_on_platform = platform_detector->is_colliding();
|
||||
|
||||
velocity = move_and_slide_with_snap(velocity, snap_vector, Vector2::UP, !is_on_platform, 4, 0.9, false);
|
||||
//velocity = move_and_slide(velocity, Vector2::UP, !is_on_platform);
|
||||
velocity.x = Math::lerp((float) velocity.x, (float) 0, (float) 0.2);
|
||||
|
||||
auto count = get_slide_count();
|
||||
for (int64_t i = 0; i < count; i++)
|
||||
{
|
||||
auto collision = get_slide_collision(i);
|
||||
auto collision_object = collision->get_collider();
|
||||
auto collider = Object::cast_to<Node>(collision_object);
|
||||
if (collider->is_in_group("squashable") && Vector2::UP.dot(collision->get_normal()) > 0.1)
|
||||
{
|
||||
collider->call_deferred("squash");
|
||||
/*auto dup_node = collider->duplicate();
|
||||
auto dup = Object::cast_to<KinematicBody2D>(dup_node);
|
||||
auto dup_pos = dup->get_position();
|
||||
dup_pos.x += 24;
|
||||
dup->set_position(dup_pos);
|
||||
auto enemies = get_tree()->get_root()->get_node("Main")->find_node("Enemies", true, false);
|
||||
if (enemies != nullptr) {
|
||||
enemies->add_child(dup);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_PRINT("Enemies not found!");
|
||||
dup->queue_free();
|
||||
}*/
|
||||
velocity.y = -get_bounce_force();
|
||||
}
|
||||
else if (collider->is_in_group("enemy") && (collider->is_in_group("rideable") && Vector2::DOWN.dot(collision->get_normal()) > 0))
|
||||
{
|
||||
_on_player_touched();
|
||||
}
|
||||
else if (collider->is_in_group("enemy") && !collider->is_in_group("rideable"))
|
||||
{
|
||||
_on_player_touched();
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp the player's position inside the camera's limits
|
||||
auto camera = get_node<Camera2D>("Camera2D");
|
||||
auto position = get_global_position();
|
||||
@ -176,6 +231,16 @@ float Player::get_jump_force()
|
||||
return this->jump_force;
|
||||
}
|
||||
|
||||
void Player::set_bounce_force(float bounce_force)
|
||||
{
|
||||
this->bounce_force = bounce_force;
|
||||
}
|
||||
|
||||
float Player::get_bounce_force()
|
||||
{
|
||||
return this->bounce_force;
|
||||
}
|
||||
|
||||
void Player::set_gravity(float gravity)
|
||||
{
|
||||
this->gravity = gravity;
|
||||
@ -215,3 +280,12 @@ Vector2 Player::get_velocity()
|
||||
{
|
||||
return this->velocity;
|
||||
}
|
||||
|
||||
void Player::_on_player_touched()
|
||||
{
|
||||
auto error = get_tree()->change_scene("res://Main.tscn");
|
||||
if (error != Error::OK)
|
||||
{
|
||||
ERR_PRINT(String().num((int) error) + " Could not load scene!");
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,11 @@ namespace godot
|
||||
*
|
||||
*/
|
||||
const float jump_force = 300.0;
|
||||
/**
|
||||
* @brief The default bounce force applied when bouncing on something.
|
||||
*
|
||||
*/
|
||||
const float bounce_force = 200.0;
|
||||
/**
|
||||
* @brief The default gravity applied to the player.
|
||||
*
|
||||
@ -93,6 +98,11 @@ namespace godot
|
||||
*
|
||||
*/
|
||||
float jump_force;
|
||||
/**
|
||||
* @brief The force applied to the player when bouncing off something.
|
||||
*
|
||||
*/
|
||||
float bounce_force;
|
||||
/**
|
||||
* @brief The gravity applied to the player.
|
||||
*
|
||||
@ -194,6 +204,20 @@ namespace godot
|
||||
*/
|
||||
float get_jump_force();
|
||||
|
||||
/**
|
||||
* @brief Set the bounce force object.
|
||||
*
|
||||
* @param[in] bounce_force The new force applied to the player to make him bounce.
|
||||
*/
|
||||
void set_bounce_force(float bounce_force);
|
||||
|
||||
/**
|
||||
* @brief Get the bounce force object.
|
||||
*
|
||||
* @return float The current force being applied to the player.
|
||||
*/
|
||||
float get_bounce_force();
|
||||
|
||||
/**
|
||||
* @brief Set the gravity object.
|
||||
*
|
||||
@ -250,6 +274,14 @@ namespace godot
|
||||
* @return Vector2 Returns the velocity of the player.
|
||||
*/
|
||||
Vector2 get_velocity();
|
||||
|
||||
/**
|
||||
* @brief This function is called when an enemy touches the player.
|
||||
*
|
||||
*/
|
||||
void _on_player_touched();
|
||||
|
||||
void _on_monitor_loaded();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user