00:00
00:00
Newgrounds Background Image Theme

OPREA just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

isometric map issues, help?

669 Views | 5 Replies
New Topic Respond to this Topic

isometric map issues, help? 2014-03-02 18:23:51


So, i can make a random map of sprites however when i try to attach a map to it it falls apart. Error codes galore. I did do it right a while ago however my computer crashed and now I can't remember how to do it. Any help would be greatly appreciated. Its a loop of two arrays but I just can't get the last line in it right connecting it to the map. Im using as3isolib and man, its driving me crazy. Here is the code for it. I do not know how to link it in proper formatting on here so yeah, I'm a newbie obviously. Thanks for anything you can do.

package AS
{
import as3isolib.display.IsoSprite;
import as3isolib.display.IsoView;
import as3isolib.display.primitive.IsoBox;
import as3isolib.display.scene.IsoGrid;
import as3isolib.display.scene.IsoScene;
import as3isolib.geom.IsoMath;
import as3isolib.geom.Pt;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.KeyboardEvent;

[SWF(width = '800', height = '600', backgroundColor='#FFFFFF', frameRate='30')]

public class Main extends Sprite
{
private static const CELL_SIZE:Number = 50;
private var grid:IsoGrid;
private var scene:IsoScene;
private var view:IsoView;
var char:IsoSprite;

public function Main()

{

char = new IsoSprite();
char.setSize(60,60,60);
char.sprites = [Hero];

//var iso:IsoSprite = new IsoSprite;
//iso.setSize(50,50,50);;
//iso.sprites = [Wall];

grid = new IsoGrid();
grid.cellSize = CELL_SIZE;
grid.setGridSize(8,8,0);

stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDown);

scene = new IsoScene();
scene.addChild(grid);
scene.addChild(char);

/* var myMap:Array = [
[1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1]
[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++)
{
// THIS IS WHERE I AM HAVING ISSUES, ATTACHING IT TO THE MAP. NOT SURE HOW EXACTLY TO DO IT.
iso = new IsoSprite();
if (Math.random() >0.5)
iso.sprites = [Wall];
else
iso.sprites = [Floor];
iso.moveBy(j*50,i*50,0);
scene.addChild(iso);

}
}
scene.render();

view = new IsoView();
view.setSize(800, 600);
view.centerOnPt(new Pt(200,200,0));
view.addScene(scene);
addChild(view);
view.render();
}

Response to isometric map issues, help? 2014-03-02 18:32:47


At 3/2/14 06:23 PM, djoecks wrote: So, i can make a random map of sprites however when i try to attach a map to it it falls apart. Error codes galore.

1) Use the code tags and only post relevant code

2) What errors are you getting? We can't help you unless you tell us what the problem is.

Response to isometric map issues, help? 2014-03-02 19:21:57


At 3/2/14 06:32 PM, MSGhero wrote:
At 3/2/14 06:23 PM, djoecks wrote: So, i can make a random map of sprites however when i try to attach a map to it it falls apart. Error codes galore.
1) Use the code tags and only post relevant code

2) What errors are you getting? We can't help you unless you tell us what the problem is.

I thought I did. Basically connecting the map array to the loop

Response to isometric map issues, help? 2014-03-02 19:47:58


At 3/2/14 07:21 PM, djoecks wrote: I thought I did. Basically connecting the map array to the loop

What errors are you getting?

Response to isometric map issues, help? 2014-03-02 22:53:34


ReferenceError: Error #1069: Property 1 not found on Number and there is no default value.
at AS::Main()

I have an array with 0's and 1,s as the code states above. Just trying to figure out how to call the array from inside the loop

var myMap:Array = [
					[1, 1, 1, 1, 1, 1, 1, 1],
					[1, 0, 0, 0, 0, 0, 0, 1],
					[1, 0, 1, 0, 0, 0, 0, 1],
					[1, 0, 0, 0, 0, 1, 0, 1],
					[1, 0, 0, 0, 0, 0, 0, 1],
					[1, 1, 1, 1, 1, 1, 1, 1]
					[1, 1, 1, 1, 1, 1, 1, 1]
					[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();
						if (myMap[j][i] == 1) {
							iso.sprites = [Wall];
						}
						if (myMap[i][j] == 0) {
							iso.sprites = [Floor];
						scene.addChild(iso);
					 
			}
		}

Response to isometric map issues, help? 2014-03-02 23:40:35


At 3/2/14 10:53 PM, djoecks wrote: ReferenceError: Error #1069: Property 1 not found on Number and there is no default value.
at AS::Main()

I have an array with 0's and 1,s as the code states above. Just trying to figure out how to call the array from inside the loop

Half of your array lines don't have commas, and you switch between using map[j][i] to map[i][j] in the same conditional tree. Some of your braces { } are missing.