I have a randomly generated side-view of a landscape (think of Terraria). It is 2048x768 and it would then be used to create a wall of 1x1x1 cubes.
Box creator
Code:
if(land.lock()) // in order to edit the texture we must first lock it
{
FREPD( x, land.x()) // iterate through all x's
{
// db++; this ran 2048 times, as expected
Int mhy=mhcalcy(x); // calculate max height of y on cur x
// creates the boxes from an earlier declared array of Actor box[2048]
box[x].create(Box(1, 1, 1, Vec(x, mhy, 0)), 0);
land.color(x,mhy,Color(GREEN));
}
}
Problem is, when i launch it and pan around, i get from the first x cube to the supposed last x cube (last i can see) faster than i expected. I then checked it to make sure if there were indeed 2048 cubes (drawn).
Checker
Code:
if(Kb.b(KB_H))
{
Int interval;
interval+=Time.d(); //thanks Driklyn! :)
static Int current;
if(interval>=0.4f)
{
terrain.db++;
Cam.setPosDir(Vec(terrain.box[current++].pos().x,terrain.box[current++].pos().y, terrain.box[current++].pos().z-15));
interval=0;
}
}
After hitting cube ~650, the Cam jumped from looking at the cubes to looking at 0,0 (so there's actually around that much cubes drawn, not 2048). Holding it just for fun, it hit cube 827 and crashed, probably from accessing an element that's out of range.
Any help is appreciated. Thanks!
image of landscape
image of first boxes seen
then it just ends abruptly