1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package main
import (
world "github.com/DegustatorPonos/RuinesOfRafdolon/Components/World"
coreobjects "github.com/DegustatorPonos/RuinesOfRafdolon/CoreObjects"
render "github.com/DegustatorPonos/RuinesOfRafdolon/Render"
settings "github.com/DegustatorPonos/RuinesOfRafdolon/Settings"
rl "github.com/gen2brain/raylib-go/raylib"
)
func main() {
settings.ReadSettings()
// TEMPORARY SECTION
var descriptor = world.Descriptor {
TileSize: rl.Vector2 { X: 32, Y: 32 },
Textures: map[int]string{
0: "assets/tile.png",
1: "assets/water.png",
},
WorldMap: [][]world.TileDescriptor {
[]world.TileDescriptor {
world.TileDescriptor{
TextureId: 0,
},
world.TileDescriptor{
TextureId: 0,
},
},
[]world.TileDescriptor {
world.TileDescriptor{
TextureId: 1,
},
world.TileDescriptor{
TextureId: 1,
},
},
},
}
// var field = CreateWorld(8, 8)
var field = descriptor.GenerateMap()
var manager = coreobjects.InitSceneManager()
render.InitWindow(manager, field)
}
// ==================== TEMPORARY SECTION ====================
var TileSize = rl.Vector2 { X: 32, Y: 32 }
type DefaultTile struct {
Position rl.Vector2
}
func (base *DefaultTile) Init(pos rl.Vector2) {
base.Position = pos
}
func (base *DefaultTile) Update() {
}
func (base *DefaultTile) Draw() {
rl.DrawTexture(world.Texture,
int32(base.Position.X) * int32(TileSize.X),
int32(base.Position.Y) * int32(TileSize.Y),
rl.White)
}
func CreateWorld(x int, y int) world.World {
var tiles = make([][]world.Tile, x)
for i := range tiles {
tiles[i] = make([]world.Tile, y)
for j := range tiles[i] {
tiles[i][j] = &DefaultTile{
Position: rl.Vector2{ X: float32(j), Y: float32(i) },
}
}
}
return world.World {
Tiles: tiles,
}
}
|