Added level mods and updated sprite imports

This commit is contained in:
Nathan Anderson 2022-08-04 18:05:48 -06:00
parent 417044bfda
commit 7843bf2b8d
19 changed files with 288 additions and 114 deletions

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,35 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=true
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
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -34,7 +34,6 @@ _global_script_class_icons={
config/name="roger"
run/main_scene="res://scenes/stage.tscn"
config/icon="res://icon.png"
[display]

47
scenes/UI.tscn Normal file
View File

@ -0,0 +1,47 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://roger-roger/fonts/8-BIT WONDER.TTF" type="DynamicFontData" id=1]
[ext_resource path="res://scripts/UI.gd" type="Script" id=2]
[ext_resource path="res://roger-roger/ui/music-enabled.png" type="Texture" id=3]
[sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 1 )
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
[node name="GUI" type="Node2D"]
script = ExtResource( 2 )
[node name="MarginContainer" type="MarginContainer" parent="."]
margin_left = 20.0
margin_top = 20.0
margin_right = 1279.0
margin_bottom = 257.0
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
margin_right = 1259.0
margin_bottom = 237.0
[node name="TimeLabel" type="RichTextLabel" parent="MarginContainer/HBoxContainer"]
margin_right = 1227.0
margin_bottom = 237.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 2 )
text = "Time 60"
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"]
margin_left = 1231.0
margin_right = 1259.0
margin_bottom = 237.0
[node name="ToolButton" type="ToolButton" parent="MarginContainer/HBoxContainer/VBoxContainer"]
margin_right = 28.0
margin_bottom = 24.0
toggle_mode = true
icon = ExtResource( 3 )
[node name="GameTimer" type="Timer" parent="."]
[connection signal="toggled" from="MarginContainer/HBoxContainer/VBoxContainer/ToolButton" to="." method="_on_ToolButton_toggled"]

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://roger-roger/tree.png" type="Texture" id=1]
[ext_resource path="res://scripts/decor.gd" type="Script" id=2]
[node name="Tree" type="Node2D"]
[node name="Decor" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
scale = Vector2( 6, 6 )

View File

@ -4,20 +4,19 @@
[ext_resource path="res://roger-roger/chadHouse.png" type="Texture" id=2]
[sub_resource type="CapsuleShape2D" id=3]
radius = 12.2857
height = 2.57142
radius = 12.4286
height = 4.85714
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 86, 63.5 )
[sub_resource type="ConvexPolygonShape2D" id=6]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 3.5, 2 )
[sub_resource type="RectangleShape2D" id=5]
extents = Vector2( 142.5, 73.1641 )
[node name="House" type="Node2D"]
script = ExtResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -125 )
position = Vector2( 7, -125 )
scale = Vector2( 5, 5 )
texture = ExtResource( 2 )
@ -26,19 +25,18 @@ collision_layer = 4
collision_mask = 7
[node name="CollisionShape2D" type="CollisionShape2D" parent="HouseBody"]
position = Vector2( -7, -90 )
position = Vector2( -4.76837e-07, -90 )
scale = Vector2( 7, 7 )
shape = SubResource( 3 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="HouseBody"]
position = Vector2( -6, -49.5 )
shape = SubResource( 4 )
position = Vector2( 0, -49 )
shape = SubResource( 6 )
[node name="DoorBody" type="StaticBody2D" parent="."]
scale = Vector2( 7, 7 )
collision_layer = 4
collision_mask = 2
[node name="DoorArea2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorBody"]
position = Vector2( -0.857143, 1.57143 )
shape = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="DoorArea2D"]
position = Vector2( 0, 36.836 )
shape = SubResource( 5 )
[connection signal="body_entered" from="DoorArea2D" to="." method="_on_DoorArea2D_body_entered"]

View File

@ -48,8 +48,7 @@ shape = SubResource( 3 )
position = Vector2( 1, -29 )
scale = Vector2( 5, 5 )
frames = SubResource( 1 )
animation = "walk"
frame = 2
animation = "idle"
playing = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://roger-roger/runningSprites/Rogers5.png" type="Texture" id=1]
[ext_resource path="res://roger-roger/runningSprites/Rogers4.png" type="Texture" id=2]
@ -10,6 +10,8 @@
[ext_resource path="res://roger-roger/runningSprites/RogersStart.png" type="Texture" id=8]
[ext_resource path="res://scripts/player.gd" type="Script" id=9]
[ext_resource path="res://roger-roger/mrRogers.png" type="Texture" id=10]
[ext_resource path="res://roger-roger/chevron_pointer.png" type="Texture" id=11]
[ext_resource path="res://scenes/UI.tscn" type="PackedScene" id=12]
[sub_resource type="CapsuleShape2D" id=2]
radius = 13.0
@ -48,3 +50,11 @@ playing = true
[node name="Camera2D" type="Camera2D" parent="."]
current = true
[node name="ChevronSprite" type="Sprite" parent="."]
position = Vector2( 0, -111 )
scale = Vector2( 3, 3 )
texture = ExtResource( 11 )
[node name="GUI" parent="." instance=ExtResource( 12 )]
position = Vector2( -640, -481 )

24
scenes/pop.tscn Normal file
View File

@ -0,0 +1,24 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://roger-roger/effects/pop-4.png" type="Texture" id=1]
[ext_resource path="res://roger-roger/effects/pop-3.png" type="Texture" id=2]
[ext_resource path="res://roger-roger/effects/pop-1.png" type="Texture" id=3]
[ext_resource path="res://roger-roger/effects/pop-2.png" type="Texture" id=4]
[ext_resource path="res://scripts/pop.gd" type="Script" id=5]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 3 ), ExtResource( 4 ), ExtResource( 2 ), ExtResource( 1 ) ],
"loop": true,
"name": "pop",
"speed": 8.0
} ]
[node name="Pop" type="AnimatedSprite"]
position = Vector2( 0, -40 )
scale = Vector2( 7, 7 )
frames = SubResource( 1 )
animation = "pop"
script = ExtResource( 5 )
[connection signal="animation_finished" from="." to="." method="_on_Pop_animation_finished"]

View File

@ -12,7 +12,7 @@
[ext_resource path="res://roger-roger/tilemap/StreetVerticalRight.png" type="Texture" id=10]
[ext_resource path="res://roger-roger/tilemap/grass1.png" type="Texture" id=11]
[ext_resource path="res://roger-roger/tilemap/justRoad.png" type="Texture" id=12]
[ext_resource path="res://scenes/tree.tscn" type="PackedScene" id=13]
[ext_resource path="res://scenes/decor.tscn" type="PackedScene" id=13]
[sub_resource type="ConvexPolygonShape2D" id=3]
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
@ -139,6 +139,7 @@ tile_data = PoolIntArray( -13, 7, 0, -12, 7, 0, -11, 3, 0, -10, 1, 0, -9, 0, 0,
[node name="Tree" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( 412.655, 542.278 )
SPRITE_ASSET = "tree"
[node name="Tree2" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( 862.175, 801.526 )
@ -148,6 +149,7 @@ position = Vector2( 1506.73, 1272.45 )
[node name="Tree4" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( 1045.31, 479.251 )
SPRITE_ASSET = "lamppos"
[node name="Tree5" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -64.6703, 908.108 )
@ -159,22 +161,34 @@ position = Vector2( -68.0338, 1333.6 )
position = Vector2( 935.996, 1365.56 )
[node name="Trolley" parent="YSort" instance=ExtResource( 4 )]
position = Vector2( 111.946, -51.4683 )
position = Vector2( 116.441, -118.892 )
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( 521.375, 114 )
[node name="House" parent="YSort" instance=ExtResource( 3 )]
[node name="House1" parent="YSort" instance=ExtResource( 3 )]
position = Vector2( 1972.13, 1965.82 )
[node name="Neighbor" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 760.201, 407.292 )
[node name="House2" parent="YSort" instance=ExtResource( 3 )]
position = Vector2( 1079.23, 1518.43 )
[node name="House3" parent="YSort" instance=ExtResource( 3 )]
position = Vector2( -210.104, 1038.94 )
[node name="House4" parent="YSort" instance=ExtResource( 3 )]
position = Vector2( 1471.88, 482.054 )
[node name="Neighbor1" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 1561.16, 1687.12 )
[node name="Neighbor2" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 521.578, 319.171 )
position = Vector2( 487.675, 1641.38 )
[node name="Neighbor3" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 477.85, 707.714 )
position = Vector2( -23.5379, 746.218 )
[node name="Neighbor4" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -324.858, 684.091 )
position = Vector2( 985.045, 718.4 )
[node name="Decor" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( 1353.08, 1162.06 )

View File

@ -34,3 +34,4 @@ position = Vector2( 0, -2.25 )
shape = SubResource( 3 )
[connection signal="body_entered" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_entered"]
[connection signal="body_exited" from="TrolleySeatArea" to="." method="_on_TrolleySeatArea_body_exited"]

18
scripts/UI.gd Normal file
View File

@ -0,0 +1,18 @@
extends Node2D
onready var time_label := $MarginContainer/HBoxContainer/TimeLabel
onready var game_timer := $GameTimer
func start_timer(seconds: int) -> void:
game_timer.start(seconds)
func _ready() -> void:
start_timer(60)
func _process(delta: float) -> void:
var time = int(game_timer.get_time_left())
time_label.text = "Time %s" % time
func _on_ToolButton_toggled(button_pressed: bool) -> void:
print(button_pressed)

15
scripts/decor.gd Normal file
View File

@ -0,0 +1,15 @@
extends Node2D
onready var sprite := $Sprite
const SpriteAsset = {bush1 = "bush1", bush2 = "bush2", tree = "tree", lamppost = "lamppost"}
export var SPRITE_ASSET := SpriteAsset.bush1
func _ready() -> void:
if SPRITE_ASSET in SpriteAsset:
sprite.texture = load("res://roger-roger/%s.png" % SPRITE_ASSET)
else:
print("ERROR - Provided Sprite asset is either not defined or misspelled: %s FIXME %s" % [SPRITE_ASSET, self.name])
sprite.texture = load("res://roger-roger/%s.png" % SpriteAsset.bush1)

View File

@ -1,6 +1,18 @@
extends Node2D
onready var sprite = $Sprite
onready var door_area = $DoorArea2D
signal come_home
var id : int
func _ready() -> void:
sprite.set_modulate(Color(1.0, 0.0, 0.0))
id = int(self.name[-1])
func _on_DoorArea2D_body_entered(body: Node) -> void:
if body is Neighbor:
if body.id == id:
emit_signal("come_home")

View File

@ -2,11 +2,12 @@ extends KinematicBody2D
class_name Neighbor
signal neighbor_following_roger
signal found_home(id)
onready var roger_area := $RogerArea2D
onready var sprite := $AnimatedSprite
onready var wander_timer := $WanderTimer
onready var chevron_sprite := $ChevronSprite
export var MAX_SPEED := 225
export var ACCELERATION := 1000
@ -17,13 +18,20 @@ var neighbor_velocity := Vector2.ZERO
var leader: KinematicBody2D
var follower: KinematicBody2D
var rng := RandomNumberGenerator.new()
var is_wandering := false
var wander_direction := Vector2.ZERO
var matching_house_node : Node2D
var house_position := Vector2.ZERO
var house_direction := Vector2.ZERO
var id : int
var pop_effect_scene = preload("res://scenes/pop.tscn")
enum State {
MOVE,
WANDER,
IDLE
IDLE,
GO_HOME,
FOUND_HOME
}
func reset_leads() -> void:
@ -33,26 +41,31 @@ func reset_leads() -> void:
follower = null
func _ready() -> void:
sprite.set_modulate(Color(.5,0,0))
id = int(self.name[-1])
rng.set_seed(id)
matching_house_node = get_parent().get_node("House%s" % id)
matching_house_node.connect("come_home", self, "_on_house_come_home")
func _physics_process(delta: float) -> void:
house_position = matching_house_node.global_position
house_direction = (house_position - global_position).normalized()
match state:
State.MOVE:
move_state(delta)
_move_state(delta)
State.WANDER:
wander_state(delta)
_wander_state(delta)
State.IDLE:
idle_state(delta)
_idle_state(delta)
State.GO_HOME:
_go_home_state(delta)
func move_state(delta: float) -> void:
# var player := get_parent().get_node("Player") as Player
# leader.follower = self
func _move_state(delta: float) -> void:
if leader == null:
state = State.IDLE
return
var result_vector := leader.global_position - global_position
if result_vector.length() > 100:
move_neighbor(result_vector)
_move_neighbor(result_vector)
else:
state = State.IDLE
if result_vector.length() > 250:
@ -63,32 +76,15 @@ func move_state(delta: float) -> void:
follower = null
state = State.IDLE
func wander_state(delta: float) -> void:
func _wander_state(delta: float) -> void:
if leader != null:
state = State.MOVE
return
move_neighbor(wander_direction, true)
_move_neighbor(wander_direction, true)
func move_neighbor(direction_vector: Vector2, is_wander: bool = false) -> void:
sprite.play("run") if not is_wander else sprite.play("walk")
var move_vector := Vector2(direction_vector).normalized()
if move_vector.x < 0 and not sprite.flip_h:
sprite.flip_h = true
elif move_vector.x > 0 and sprite.flip_h:
sprite.flip_h = false
if move_vector != Vector2.ZERO:
var velocity := move_vector * MAX_SPEED if not is_wander else move_vector * MAX_SPEED / 3
neighbor_velocity = neighbor_velocity.move_toward(velocity, ACCELERATION * get_physics_process_delta_time())
else:
neighbor_velocity = neighbor_velocity.move_toward(Vector2.ZERO, FRICTION * get_physics_process_delta_time())
neighbor_velocity = move_and_slide(neighbor_velocity)
func idle_state(delta: float) -> void:
func _idle_state(delta: float) -> void:
if wander_timer.is_stopped():
wander_timer.start(rng.randf_range(0, 1.5))
wander_timer.start(rng.randf_range(1.8, 6.5))
sprite.play("idle")
for body in roger_area.get_overlapping_bodies():
if body.is_class("KinematicBody2D") and not body is Trolley and leader == null and body.follower == null and body.leader != null:
@ -97,31 +93,63 @@ func idle_state(delta: float) -> void:
if leader != null:
state = State.MOVE
func _go_home_state(delta: float) -> void:
_move_neighbor(house_direction, true)
# print((house_position - global_position).length())
if ((house_position - global_position).length() < 30):
emit_signal("found_home", id)
queue_free()
func _move_neighbor(direction_vector: Vector2, is_walk: bool = false) -> void:
sprite.play("run") if not is_walk else sprite.play("walk")
var move_vector := Vector2(direction_vector).normalized()
if move_vector.x < 0 and not sprite.flip_h:
sprite.flip_h = true
elif move_vector.x > 0 and sprite.flip_h:
sprite.flip_h = false
if move_vector != Vector2.ZERO:
var velocity := move_vector * MAX_SPEED if not is_walk else move_vector * MAX_SPEED / 3
neighbor_velocity = neighbor_velocity.move_toward(velocity, ACCELERATION * get_physics_process_delta_time())
else:
neighbor_velocity = neighbor_velocity.move_toward(Vector2.ZERO, FRICTION * get_physics_process_delta_time())
neighbor_velocity = move_and_slide(neighbor_velocity)
func _on_RogerArea2D_body_entered(body: Node) -> void:
if body != self and leader == null:
if body is Player and body.follower == null:
body.follower = self
leader = body
elif body.is_class("KinematicBody2D") and not body is Trolley and body.follower == null:
print('Got neighbor body')
if body.leader != null:
print('Following the leader')
leader = body
leader.follower = self
func _on_WanderTimer_timeout() -> void:
if state == State.IDLE:
print('wander timer done')
var rand_x = rng.randf_range(-1.0, 1.0)
var rand_y = rng.randf_range(-1.0, 1.0)
var wander_time = rng.randf_range(1.0, 1.5)
var wander_time = rng.randf_range(0.3, 1.2)
state = State.WANDER
wander_direction = Vector2(rand_x, rand_y)
wander_timer.start(wander_time)
elif state == State.WANDER:
print('Done wandering')
var wait_time = rng.randf_range(1.0, 5.5)
var wait_time = rng.randf_range(1.8, 6.5)
state = State.IDLE
wander_timer.start(wait_time)
elif state == State.FOUND_HOME:
state = State.GO_HOME
func _on_house_come_home() -> void:
sprite.play("idle")
wander_timer.start(0.5)
var instance = pop_effect_scene.instance()
get_parent().add_child(instance)
instance.global_position = Vector2(global_position.x, global_position.y - 50)
if follower == null:
leader.follower = null
else:
leader.follower = follower
follower.leader = leader
state = State.FOUND_HOME

View File

@ -9,8 +9,10 @@ export var FRICTION := 2000
var player_velocity = Vector2.ZERO
var state = State.IDLE
var follower : KinematicBody2D
var leader := self
onready var sprite := $AnimatedSprite
onready var chevron_sprite := $ChevronSprite
enum State {
MOVE,
@ -21,11 +23,14 @@ enum State {
func _physics_process(delta: float) -> void:
match state:
State.MOVE:
move_state(delta)
_move_state(delta)
State.IDLE:
idle_state(delta)
_idle_state(delta)
chevron_sprite.visible = follower != null
if follower != null:
chevron_sprite.rotation_degrees = rad2deg((follower.house_position - global_position).angle()) - 90
func move_state(delta: float) -> void:
func _move_state(delta: float) -> void:
var input_vector := Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
@ -47,7 +52,7 @@ func move_state(delta: float) -> void:
if player_velocity == Vector2.ZERO:
state = State.IDLE
func idle_state(delta: float) -> void:
func _idle_state(delta: float) -> void:
if Input.is_action_just_pressed("ui_up") or Input.is_action_just_pressed("ui_down") or Input.is_action_just_pressed("ui_left") or Input.is_action_just_pressed("ui_right"):
sprite.set_animation("run")
state = State.MOVE

7
scripts/pop.gd Normal file
View File

@ -0,0 +1,7 @@
extends AnimatedSprite
func _ready() -> void:
play()
func _on_Pop_animation_finished() -> void:
queue_free()

View File

@ -1,2 +1,25 @@
extends Node2D
var helped_neighbors := []
var total_neighbors := 0
onready var trolley = $YSort/Trolley as Trolley
func _ready() -> void:
trolley.connect("rogers_left_trolley", self, "_on_rogers_left_trolley")
for node in get_node("YSort").get_children():
if 'Neighbor' in node.name:
var err = node.connect("found_home", self, "_on_neighbor_found_home")
total_neighbors += 1
func _on_rogers_left_trolley() -> void:
pass
func _on_neighbor_found_home(id: int) -> void:
print('You helped a neighbor')
helped_neighbors.append(id)
if len(helped_neighbors) == total_neighbors:
trolley.set_trolley_open(true)

View File

@ -2,6 +2,8 @@ extends KinematicBody2D
class_name Trolley
signal rogers_left_trolley()
export var TIME = 60
onready var trolley_closed_shape = $TrolleyClosedShape
export var MAX_VELOCITY = .3
@ -10,7 +12,7 @@ var velocity := Vector2.ZERO
var has_roger := false
func _ready() -> void:
trolley_closed_shape.set_deferred("disabled", true)
set_trolley_open(true)
func _physics_process(delta: float) -> void:
velocity.x = move_toward(velocity.x, MAX_VELOCITY, delta if not has_roger else delta * 10)
@ -22,8 +24,8 @@ func _physics_process(delta: float) -> void:
MAX_VELOCITY = 10
collider.move_and_collide(velocity * 3)
func set_trolley_open(trolley_open: bool) -> void:
trolley_closed_shape.set_deferred("disabled", trolley_open)
func _on_TrolleySeatArea_body_entered(body: Node) -> void:
if body is Player:
@ -31,3 +33,8 @@ func _on_TrolleySeatArea_body_entered(body: Node) -> void:
print('closing trolley')
trolley_closed_shape.set_deferred("disabled", false)
func _on_TrolleySeatArea_body_exited(body: Node) -> void:
if body is Player:
emit_signal("rogers_left_trolley")