mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
exploration test
This commit is contained in:
parent
fc37670deb
commit
16b67778a9
10 changed files with 167 additions and 13 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 623 B |
BIN
media/image/dither1.png
Normal file
BIN
media/image/dither1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 307 B |
BIN
media/image/glove.png
Normal file
BIN
media/image/glove.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 129 B |
BIN
media/image/lift.png
Normal file
BIN
media/image/lift.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 B |
|
|
@ -49,6 +49,11 @@ _global_script_classes=[ {
|
|||
"language": "GDScript",
|
||||
"path": "res://src/actor/Passthrough.gd"
|
||||
}, {
|
||||
"base": "Actor",
|
||||
"class": "Powerup",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/actor/powerup/Powerup.gd"
|
||||
}, {
|
||||
"base": "Node2D",
|
||||
"class": "Stage",
|
||||
"language": "GDScript",
|
||||
|
|
@ -78,6 +83,7 @@ _global_script_class_icons={
|
|||
"EditorTheme": "",
|
||||
"Exit": "",
|
||||
"Passthrough": "",
|
||||
"Powerup": "",
|
||||
"Stage": "",
|
||||
"Switch": "",
|
||||
"SwitchBlock": "",
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ var scene_box = preload("res://src/actor/Box.tscn")
|
|||
var scene_explosion = preload("res://src/fx/Explosion.tscn")
|
||||
var scene_explosion2 = preload("res://src/fx/Explosion2.tscn")
|
||||
|
||||
# powerups
|
||||
var is_powerup_push := false
|
||||
var is_powerup_lift := false
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if Engine.editor_hint:
|
||||
|
|
@ -87,6 +92,10 @@ func _process(delta):
|
|||
if is_pickup:
|
||||
pass
|
||||
|
||||
# collect powerup
|
||||
for a in check_area_actors("powerup"):
|
||||
collect_powerup(a)
|
||||
|
||||
# open door
|
||||
if btn.p("up"):
|
||||
for a in check_area_actors("door"):
|
||||
|
|
@ -149,7 +158,7 @@ func _process(delta):
|
|||
is_jump = false
|
||||
|
||||
# box pickup / throw
|
||||
if btn.p("action"):
|
||||
if is_powerup_lift and btn.p("action"):
|
||||
if is_pickup:
|
||||
if btn.d("down"):
|
||||
box_release(speed_drop.x * dir, speed_drop.y)
|
||||
|
|
@ -166,10 +175,9 @@ func _process(delta):
|
|||
box_pickup(0, 1)
|
||||
else:
|
||||
box_pickup(dir * 4, 0)
|
||||
|
||||
|
||||
# push box
|
||||
if is_on_floor and move_get_dist().x != 0 and not is_pickup:
|
||||
if is_powerup_push and is_on_floor and move_get_dist().x != 0 and not is_pickup:
|
||||
for a in check_area_actors("box", position.x + dir):
|
||||
a.push(dir)
|
||||
# slow movement when pushing
|
||||
|
|
@ -178,6 +186,14 @@ func _process(delta):
|
|||
move_x(dir)
|
||||
break
|
||||
|
||||
func collect_powerup(arg : Actor):
|
||||
match arg.powerup_name:
|
||||
"push":
|
||||
is_powerup_push = true
|
||||
"lift":
|
||||
is_powerup_lift = true
|
||||
arg.collect()
|
||||
|
||||
func box_release(sx := 0.0, sy := 0.0):
|
||||
is_pickup = false
|
||||
pickup_box.speed = Vector2(sx, sy)
|
||||
|
|
|
|||
12
src/actor/powerup/Powerup.gd
Normal file
12
src/actor/powerup/Powerup.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
tool
|
||||
extends Actor
|
||||
class_name Powerup
|
||||
|
||||
export var powerup_name = "push"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func collect():
|
||||
queue_free()
|
||||
15
src/actor/powerup/PowerupLift.tscn
Normal file
15
src/actor/powerup/PowerupLift.tscn
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://media/image/lift.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/actor/powerup/Powerup.gd" type="Script" id=2]
|
||||
|
||||
[node name="PowerupLift" type="Node2D" groups=[
|
||||
"actor",
|
||||
"powerup",
|
||||
]]
|
||||
script = ExtResource( 2 )
|
||||
powerup_name = "lift"
|
||||
|
||||
[node name="lift" type="Sprite" parent="."]
|
||||
position = Vector2( 4, 4 )
|
||||
texture = ExtResource( 1 )
|
||||
14
src/actor/powerup/PowerupPush.tscn
Normal file
14
src/actor/powerup/PowerupPush.tscn
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://media/image/glove.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/actor/powerup/Powerup.gd" type="Script" id=2]
|
||||
|
||||
[node name="PowerupPush" type="Node2D" groups=[
|
||||
"actor",
|
||||
"powerup",
|
||||
]]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="glove" type="Sprite" parent="."]
|
||||
position = Vector2( 4, 4 )
|
||||
texture = ExtResource( 1 )
|
||||
111
src/map/A01.tscn
111
src/map/A01.tscn
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue