moving towards scene-based
This commit is contained in:
parent
e4355757fb
commit
f2a427916c
9 changed files with 90 additions and 35 deletions
11
level/level_1.tscn
Normal file
11
level/level_1.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://de1snxsqng03d"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c8ywa33v3jq7t" path="res://board.gd" id="1_lx8gb"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bkaa4sl1n2f5w" path="res://piece/wall.tscn" id="2_lx8gb"]
|
||||||
|
|
||||||
|
[node name="Level1" type="Node3D"]
|
||||||
|
script = ExtResource("1_lx8gb")
|
||||||
|
metadata/_custom_type_script = "uid://c8ywa33v3jq7t"
|
||||||
|
|
||||||
|
[node name="Wall" parent="." instance=ExtResource("2_lx8gb")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5, 0, 0.5)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=9 format=3 uid="uid://lrk2whqxl0w0"]
|
[gd_scene load_steps=9 format=3 uid="uid://lrk2whqxl0w0"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c707s0tgd88pg" path="res://main.gd" id="1_ig7tw"]
|
[ext_resource type="Script" uid="uid://c707s0tgd88pg" path="res://main.gd" id="1_ig7tw"]
|
||||||
[ext_resource type="Script" uid="uid://c8ywa33v3jq7t" path="res://board.gd" id="2_0xm2m"]
|
[ext_resource type="PackedScene" uid="uid://de1snxsqng03d" path="res://level/level_1.tscn" id="2_lquwl"]
|
||||||
[ext_resource type="Texture2D" uid="uid://crahyipmcudoy" path="res://ui/undo.png" id="3_lquwl"]
|
[ext_resource type="Texture2D" uid="uid://crahyipmcudoy" path="res://ui/undo.png" id="3_lquwl"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dyj5el5iro1cb" path="res://ui/redo.png" id="4_7mycd"]
|
[ext_resource type="Texture2D" uid="uid://dyj5el5iro1cb" path="res://ui/redo.png" id="4_7mycd"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cbb1q0usxd6ex" path="res://ui/restart.png" id="5_272bh"]
|
[ext_resource type="Texture2D" uid="uid://cbb1q0usxd6ex" path="res://ui/restart.png" id="5_272bh"]
|
||||||
|
|
@ -20,6 +20,8 @@ ambient_light_color = Color(1, 1, 1, 1)
|
||||||
[node name="Main" type="Node3D"]
|
[node name="Main" type="Node3D"]
|
||||||
script = ExtResource("1_ig7tw")
|
script = ExtResource("1_ig7tw")
|
||||||
|
|
||||||
|
[node name="Board" parent="." instance=ExtResource("2_lquwl")]
|
||||||
|
|
||||||
[node name="Camera" type="Camera3D" parent="."]
|
[node name="Camera" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.5, 0)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1.5, 0)
|
||||||
fov = 30.0
|
fov = 30.0
|
||||||
|
|
@ -37,10 +39,6 @@ aabb = AABB(-0.25, 0, -0.25, 2, 2, 2)
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0, 0.25)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.25, 0, 0.25)
|
||||||
aabb = AABB(0, 0, 0, 2, 2, 2)
|
aabb = AABB(0, 0, 0, 2, 2, 2)
|
||||||
|
|
||||||
[node name="Board" type="Node3D" parent="."]
|
|
||||||
script = ExtResource("2_0xm2m")
|
|
||||||
metadata/_custom_type_script = "uid://c8ywa33v3jq7t"
|
|
||||||
|
|
||||||
[node name="UndoButton" type="Button" parent="."]
|
[node name="UndoButton" type="Button" parent="."]
|
||||||
offset_left = -5.0
|
offset_left = -5.0
|
||||||
offset_top = 1.0
|
offset_top = 1.0
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ albedo_color = Color(0.345098, 0.658824, 0.819608, 1)
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
material = SubResource("StandardMaterial3D_tr67r")
|
material = SubResource("StandardMaterial3D_tr67r")
|
||||||
top_radius = 0.25
|
top_radius = 0.35
|
||||||
bottom_radius = 0.3
|
bottom_radius = 0.4
|
||||||
height = 0.1
|
height = 0.1
|
||||||
|
|
|
||||||
53
piece.gd
53
piece.gd
|
|
@ -1,11 +1,11 @@
|
||||||
class_name Piece
|
class_name Piece
|
||||||
extends MeshInstance3D
|
extends MeshInstance3D
|
||||||
|
|
||||||
const WALL = preload("res://model/wall.tres")
|
const BALL = preload("res://piece/ball.tscn")
|
||||||
const GOAL = preload("res://model/goal.tres")
|
const FLOOR_ICE = preload("res://piece/floor_ice.tscn")
|
||||||
const BALL = preload("res://model/ball.tres")
|
const GOAL = preload("res://piece/goal.tscn")
|
||||||
const PLAYER = preload("res://model/player.tres")
|
const PLAYER = preload("res://piece/player.tscn")
|
||||||
const FLOOR_ICE = preload("res://model/floor_ice.tres")
|
const WALL = preload("res://piece/wall.tscn")
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
Wall,
|
Wall,
|
||||||
|
|
@ -15,20 +15,18 @@ enum Type {
|
||||||
FloorIce,
|
FloorIce,
|
||||||
}
|
}
|
||||||
|
|
||||||
# idea: SLOW MO KEY!!!!!!!!!!!!!!!
|
|
||||||
## squares per second
|
## squares per second
|
||||||
@export_range(0.1, 50) var anim_speed := 10.0
|
@export_range(0.1, 50) var anim_speed := 10.0
|
||||||
@export_range(0.1, 50) var anim_speed_slow := 2.0
|
@export_range(0.1, 50) var anim_speed_slow := 2.0
|
||||||
|
|
||||||
## logical position
|
## logical position
|
||||||
@export var lpos: Vector2i:
|
var lpos: Vector2i:
|
||||||
get:
|
get:
|
||||||
return lpos
|
return Vector2i(int(target_pos.x), int(target_pos.z))
|
||||||
set(val):
|
set(val):
|
||||||
lpos = val
|
|
||||||
position = target_pos
|
position = target_pos
|
||||||
start_pos = position
|
start_pos = position
|
||||||
target_pos = Vector3(lpos.x, position.y, lpos.y)
|
target_pos = Vector3(val.x, position.y, val.y)
|
||||||
anim_progress = 0
|
anim_progress = 0
|
||||||
|
|
||||||
## logical velocity
|
## logical velocity
|
||||||
|
|
@ -88,30 +86,22 @@ func undo_push() -> Callable:
|
||||||
lvel = old_vel
|
lvel = old_vel
|
||||||
anim_progress = 1
|
anim_progress = 1
|
||||||
|
|
||||||
static func make(lpos: Vector2i, type: Piece.Type, mesh: Mesh) -> Piece:
|
static func ball(pos: Vector2i) -> Piece:
|
||||||
var piece := Piece.new()
|
return BALL.instantiate().with_lpos(pos)
|
||||||
piece.lpos = lpos
|
|
||||||
piece.mesh = mesh
|
|
||||||
piece.type = type
|
|
||||||
return piece
|
|
||||||
|
|
||||||
static func wall(lpos: Vector2i) -> Piece:
|
static func floor_ice(pos: Vector2i) -> Piece:
|
||||||
return make(lpos, Piece.Type.Wall, WALL)
|
return FLOOR_ICE.instantiate().with_lpos(pos)
|
||||||
|
|
||||||
static func goal(lpos: Vector2i) -> Piece:
|
static func goal(pos: Vector2i) -> Piece:
|
||||||
return make(lpos, Piece.Type.Goal, GOAL)
|
return GOAL.instantiate().with_lpos(pos)
|
||||||
|
|
||||||
static func ball(lpos: Vector2i) -> Piece:
|
static func player(pos: Vector2i) -> Piece:
|
||||||
return make(lpos, Piece.Type.Ball, BALL)
|
return PLAYER.instantiate().with_lpos(pos)
|
||||||
|
|
||||||
static func player(lpos: Vector2i) -> Piece:
|
static func wall(pos: Vector2i) -> Piece:
|
||||||
return make(lpos, Piece.Type.Player, PLAYER)
|
return WALL.instantiate().with_lpos(pos)
|
||||||
|
|
||||||
static func floor_ice(lpos: Vector2i) -> Piece:
|
|
||||||
return make(lpos, Piece.Type.FloorIce, FLOOR_ICE)
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
lpos = lpos
|
|
||||||
anim_progress = 1
|
anim_progress = 1
|
||||||
speedometer = Label3D.new()
|
speedometer = Label3D.new()
|
||||||
speedometer.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
speedometer.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
||||||
|
|
@ -134,3 +124,10 @@ func _process(delta: float) -> void:
|
||||||
anim_progress = min(1, anim_progress + speed*delta)
|
anim_progress = min(1, anim_progress + speed*delta)
|
||||||
position = start_pos.lerp(target_pos, anim_progress)
|
position = start_pos.lerp(target_pos, anim_progress)
|
||||||
speedometer.text = format_vel(lvel)
|
speedometer.text = format_vel(lvel)
|
||||||
|
|
||||||
|
# weird hack only necessary for the soon to be gone text parser
|
||||||
|
func with_lpos(pos: Vector2i) -> Piece:
|
||||||
|
lpos = pos
|
||||||
|
lpos = pos
|
||||||
|
anim_progress = 1
|
||||||
|
return self
|
||||||
|
|
|
||||||
10
piece/ball.tscn
Normal file
10
piece/ball.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bghr6ew34loyb"]
|
||||||
|
|
||||||
|
[ext_resource type="SphereMesh" uid="uid://bxuewsvlsvexw" path="res://model/ball.tres" id="1_qixli"]
|
||||||
|
[ext_resource type="Script" uid="uid://bq3a5hhccxndn" path="res://piece.gd" id="2_c3ygy"]
|
||||||
|
|
||||||
|
[node name="Ball" type="MeshInstance3D"]
|
||||||
|
mesh = ExtResource("1_qixli")
|
||||||
|
script = ExtResource("2_c3ygy")
|
||||||
|
type = 2
|
||||||
|
metadata/_custom_type_script = "uid://bq3a5hhccxndn"
|
||||||
10
piece/floor_ice.tscn
Normal file
10
piece/floor_ice.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cyi67vbw8e0iy"]
|
||||||
|
|
||||||
|
[ext_resource type="QuadMesh" uid="uid://cs4ct3wp7xqeo" path="res://model/floor_ice.tres" id="1_2idvc"]
|
||||||
|
[ext_resource type="Script" uid="uid://bq3a5hhccxndn" path="res://piece.gd" id="2_lpfou"]
|
||||||
|
|
||||||
|
[node name="FloorIce" type="MeshInstance3D"]
|
||||||
|
mesh = ExtResource("1_2idvc")
|
||||||
|
script = ExtResource("2_lpfou")
|
||||||
|
type = 4
|
||||||
|
metadata/_custom_type_script = "uid://bq3a5hhccxndn"
|
||||||
10
piece/goal.tscn
Normal file
10
piece/goal.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://uf8vnylfqal1"]
|
||||||
|
|
||||||
|
[ext_resource type="CylinderMesh" uid="uid://dip4i2st1vn1j" path="res://model/goal.tres" id="1_ek53k"]
|
||||||
|
[ext_resource type="Script" uid="uid://bq3a5hhccxndn" path="res://piece.gd" id="2_nqrds"]
|
||||||
|
|
||||||
|
[node name="Goal" type="MeshInstance3D"]
|
||||||
|
mesh = ExtResource("1_ek53k")
|
||||||
|
script = ExtResource("2_nqrds")
|
||||||
|
type = 1
|
||||||
|
metadata/_custom_type_script = "uid://bq3a5hhccxndn"
|
||||||
10
piece/player.tscn
Normal file
10
piece/player.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cnjmu3qesbndk"]
|
||||||
|
|
||||||
|
[ext_resource type="CapsuleMesh" uid="uid://mjvk342gmemc" path="res://model/player.tres" id="1_3owwe"]
|
||||||
|
[ext_resource type="Script" uid="uid://bq3a5hhccxndn" path="res://piece.gd" id="2_5o3x0"]
|
||||||
|
|
||||||
|
[node name="Player" type="MeshInstance3D"]
|
||||||
|
mesh = ExtResource("1_3owwe")
|
||||||
|
script = ExtResource("2_5o3x0")
|
||||||
|
type = 3
|
||||||
|
metadata/_custom_type_script = "uid://bq3a5hhccxndn"
|
||||||
9
piece/wall.tscn
Normal file
9
piece/wall.tscn
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bkaa4sl1n2f5w"]
|
||||||
|
|
||||||
|
[ext_resource type="BoxMesh" uid="uid://b36l7brqc2lml" path="res://model/wall.tres" id="1_ostjl"]
|
||||||
|
[ext_resource type="Script" uid="uid://bq3a5hhccxndn" path="res://piece.gd" id="2_j8o2k"]
|
||||||
|
|
||||||
|
[node name="Wall" type="MeshInstance3D"]
|
||||||
|
mesh = ExtResource("1_ostjl")
|
||||||
|
script = ExtResource("2_j8o2k")
|
||||||
|
metadata/_custom_type_script = "uid://bq3a5hhccxndn"
|
||||||
Loading…
Reference in a new issue