summaryrefslogtreecommitdiff
path: root/engine/Dynamic/Descriptors/World.go
diff options
context:
space:
mode:
Diffstat (limited to 'engine/Dynamic/Descriptors/World.go')
-rw-r--r--engine/Dynamic/Descriptors/World.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/engine/Dynamic/Descriptors/World.go b/engine/Dynamic/Descriptors/World.go
index 5116a0d..25e52ef 100644
--- a/engine/Dynamic/Descriptors/World.go
+++ b/engine/Dynamic/Descriptors/World.go
@@ -1,6 +1,9 @@
package descriptors
-import rl "github.com/gen2brain/raylib-go/raylib"
+import (
+ components "github.com/DegustatorPonos/RuinesOfRafdolon/Components"
+ rl "github.com/gen2brain/raylib-go/raylib"
+)
type WorldDescriptor struct {
Name string
@@ -26,3 +29,30 @@ type FloorPiece struct {
Position rl.Vector2
Texture string
}
+
+// Transforms the world descriptor into the game world
+func (base WorldDescriptor) Parse() components.World {
+ var outp = components.World {
+ Name: base.Name,
+ Floor: make([]components.FloorTile, 0, len(base.FloorMap)),
+
+ Camera: &rl.Camera2D{
+ Offset: rl.Vector2 {X: 0, Y: 0},
+ Target: rl.Vector2 {X: 0, Y: 0},
+ Rotation: 0,
+ Zoom: 1,
+ },
+ }
+ for _, v := range base.FloorMap {
+ var texture, textureErr = components.Resources.Textures.GetTextureByName(v.Texture)
+ if textureErr != nil {
+ continue
+ }
+ var new = components.FloorTile {
+ Position: v.Position,
+ Texture: texture,
+ }
+ outp.Floor = append(outp.Floor, new)
+ }
+ return outp
+}