@@ -17,13 +17,16 @@ function Object:uninit()
17
17
end
18
18
19
19
function Object :init (path )
20
+ print (" Init terrain" , path )
20
21
if not Object .initialized and file_exists (path ) then
21
22
This :initialize ();
23
+ print (" Terrain initialized" );
22
24
local lines = lines_from (path )
23
25
local maxY ;
24
26
local maxX ;
25
27
local sprSize ;
26
28
local load_table = {};
29
+ print (" Lines" , inspect (lines ));
27
30
for i , str in pairs (lines ) do
28
31
if maxY == nil or i > maxY then
29
32
maxY = i ;
@@ -37,12 +40,14 @@ function Object:init(path)
37
40
load_table [i ][j ] = char ;
38
41
end
39
42
end
43
+ print (" Loadtable" , inspect (load_table ));
40
44
local offset = {x = (maxX / 2 ), y = (maxY / 2 )};
41
45
for i , v in pairs (load_table ) do
42
46
Object .elements [i ] = {}
43
47
for j , v2 in pairs (v ) do
44
48
if v2 ~= " " then
45
49
local position = { x = j - 1 , y = i - 1 };
50
+ print (" Loading element" , v2 );
46
51
Object .elements [i ][j ] = blocFunctions [v2 ](position );
47
52
if sprSize == nil then
48
53
sprSize = Object .elements [i ][j ][1 ].getSprSize ();
@@ -51,6 +56,7 @@ function Object:init(path)
51
56
end
52
57
end
53
58
59
+ print (" Setting camera" );
54
60
local pVec = obe .Transform .UnitVector (
55
61
offset .x * sprSize .x ,
56
62
offset .y * sprSize .y
@@ -63,6 +69,7 @@ function Object:init(path)
63
69
local camera = Engine .Scene :getCamera ();
64
70
camera :setPosition (pVec , obe .Transform .Referential .Center );
65
71
camera :scale (pSize , obe .Transform .Referential .Center );
72
+ print (" Terrain done :)" );
66
73
Object .initialized = true ;
67
74
end
68
75
end
0 commit comments