Help with tile game coding and iso
- djoecks
-
djoecks
- Member since: May. 26, 2013
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
ok, so heres my issue. I am trying to make the level the way I want it. I have been wrecking my brain literally for months figuring out arrays and all that and the as3isolib as well. I have done the tutorials and obviously i have picked up on some things and I understand the for loops and stuff somewhat but for some reason I am having a hard time with it actually working and I know its something I am doing for sure. Problem is I dont know what it is. I have a feeling its getting the map array to function with the isoSprites the right way but I dont know how to do that.
package
{
import as3isolib.display.IsoSprite;
import as3isolib.display.IsoView;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;
import as3isolib.geom.Pt;
import flash.display.Sprite;
[SWF(width="800", height="600", backgroundColor="#000000", frameRate="30")]
public class game extends Sprite
{
private static const CELL_SIZE:Number= 50;
private var grid:IsoGrid;
private var scene:IsoScene;
private var view:IsoView;
public function game()
{
grid = new IsoGrid();
grid.setGridSize(8,8,1);
grid.showOrigin = false;
grid.cellSize = CELL_SIZE;
scene = new IsoScene();
scene.addChild(grid);
var myMap:Array = [
[1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,1,1,],
[1,0,0,0,0,0,1,0,],
[1,0,0,1,0,0,1,0,],
[1,0,0,1,1,1,1,0,],
[1,0,0,0,0,0,0,0,],
[1,1,1,1,1,1,1,1,]
];
var iso:IsoSprite
for(var i:int=0; i<8; i++)
{
for(var j:int=0; j<8; j++)
{
iso = new IsoSprite();
iso.moveBy(j*50, i*50, 0);
iso.sprites[brick,grass];
}
}
scene.render();
view = new IsoView();
view.setSize(800,600);
view.centerOnPt(new Pt(200,200,0));
view.addScene(myMap[j][i]);
addChild(view);
}
}
}
- djoecks
-
djoecks
- Member since: May. 26, 2013
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
I never would have thought trying to make a tile game would be so hard. I am just not getting how the array calls the map array.
- djoecks
-
djoecks
- Member since: May. 26, 2013
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
At 8/3/13 02:29 PM, djoecks wrote: I never would have thought trying to make a tile game would be so hard. I am just not getting how the array calls the map array.
Why are programmers so defensive about showing or teaching someone something? I will never know. I have been stuck on this for months gone through tutorials, read online for hours and still havent found an answer. my code is messed up i know that. I am learning the best I can but still, this one question is setting me back. One simple thing.
- theCodeCat
-
theCodeCat
- Member since: Feb. 24, 2009
- Offline.
-
- Forum Stats
- Member
- Level 04
- Programmer
First off, your post has been up for like an hour, it is way too early to get mad at people for not responding.
Formatted Version of code:
package
{
import as3isolib.display.IsoSprite;
import as3isolib.display.IsoView;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;
import as3isolib.geom.Pt;
import flash.display.Sprite;
[SWF(width="800", height="600", backgroundColor="#000000", frameRate="30")]
public class game extends Sprite
{
private static const CELL_SIZE:Number= 50;
private var grid:IsoGrid;
private var scene:IsoScene;
private var view:IsoView;
public function game()
{
grid = new IsoGrid();
grid.setGridSize(8,8,1);
grid.showOrigin = false;
grid.cellSize = CELL_SIZE;
scene = new IsoScene();
scene.addChild(grid);
var myMap:Array = [
[1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,0,0,],
[1,0,0,0,0,0,1,1,],
[1,0,0,0,0,0,1,0,],
[1,0,0,1,0,0,1,0,],
[1,0,0,1,1,1,1,0,],
[1,0,0,0,0,0,0,0,],
[1,1,1,1,1,1,1,1,]
];
var iso:IsoSprite
for(var i:int=0; i<8; i++)
{
for(var j:int=0; j<8; j++)
{
iso = new IsoSprite();
iso.moveBy(j*50, i*50, 0);
iso.sprites[brick,grass];
}
}
scene.render();
view = new IsoView();
view.setSize(800,600);
view.centerOnPt(new Pt(200,200,0));
view.addScene(myMap[j][i]);
addChild(view);
}
}
}
I don't actually know the as3isolib, so I can't give you detailed advice, however it looks like you declare your myMap array and never really use it.
The only point you reference it is:
view.addScene(myMap[j][i]);
which is weird since you are re-using the integers from the loops.
From the way your loop is set up, 'i' & 'j' should both be 8 at that point, so you are trying to access myMap[8][8] and add it as a scene.
I imagine that the array is meant to be accessed somewhere in double-loop
Maybe take a look at that.
You forgot to use code tags, didn't you?
- djoecks
-
djoecks
- Member since: May. 26, 2013
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
I don't actually know the as3isolib, so I can't give you detailed advice, however it looks like you declare your myMap array and never really use it.
The only point you reference it is:
view.addScene(myMap[j][i]);
which is weird since you are re-using the integers from the loops.
From the way your loop is set up, 'i' & 'j' should both be 8 at that point, so you are trying to access myMap[8][8] and add it as a scene.
I imagine that the array is meant to be accessed somewhere in double-loop
Maybe take a look at that.
I will look into it. I have another one on here as well for the same problem. I am just frustrated and shouldnt take it out on here for my stupidity for not understanding this stuff. THank you for looking at it.

