Need a person to write Simple Array for me

I changed some of the code you had used Brandon. I removed the stutter from the walking script by using _root.onEnterFrame instead of onClipEvent(KeyDown). Also I increased the frame rate to 30 and reduced the distance the world moves every frame to 2. This creates a smoother animation. Check the attachment to see and test the code.

[color=blue]||[/color] is the same as [color=blue]or[/color], but it is preferred because sometime in the future, [color=blue]or[/color] will not be recognized by the Flash player. This is the same thing with [color=blue]&&[/color] and [color=blue]and[/color][color=black].[/color]

Ya somethings wrong with the code becuase if you tested it and tried to run “down” into one of the 0 degree trees you wern’t able to move right. and then the unit gets stuck all the time and thats just annoying for the person playing the game. it seems to do it wen i use that code but when i use the code the other way it works fine. So you might want to retest this code by testing it. Ya i did take your advise and i changed the speed to 24 to make it more smooth.
"note: the shorter code isn’t always the best code."
And thanks to you all for helping me out. (just to tell you this game is set up like a game boy game you go around and hit space and talk to people and do little quests.)

Wait, my code didn’t work??!?! It seemed to work for me :frowning:

Did you try the .fla?

My .fla worked fine for me.

Brandon, whose code are you saying didn’t work properly? The fla I posted works fine for me. Here’s my code in case it has changed (I did add a speed variable…)


onClipEvent (load) {
 numTrees = 7;
 checkTrees = function () {
  for (var tr = 1; tr<numTrees+1; tr++) {
   if (this, hitTest(_root.world["T"+tr])) {
	return 1;
   }
  }
 };
 numObjects = 5;
 checkObjects = function () {
  for (var obj = 1; obj<numObjects+1; obj++) {
   if (this, hitTest(_root.world["B"+obj])) {
	return 1;
   }
  }
 };
 speed = 2;
}
onClipEvent (enterFrame) {
 _root.onEnterFrame = function() {
  if (key.isDown(key.LEFT)) {
   _root.World._x += speed;
   _root.Unit._rotation = 270;
   if (checkTrees() || checkObjects()) {
	_root.World._x -= speed;
   }
  } else if (key.isDown(key.RIGHT)) {
   _root.World._x -= speed;
   _root.Unit._rotation = 90;
   if (checkTrees() || checkObjects()) {
	_root.World._x += speed;
   }
  } else if (key.isDown(key.UP)) {
   _root.World._y += speed;
   _root.Unit._rotation = 0;
   if (checkTrees() || checkObjects()) {
	_root.World._y -= speed;
   }
  } else if (key.isDown(key.DOWN)) {
   _root.World._y -= speed;
   _root.Unit._rotation = 180;
   if (checkTrees() || checkObjects()) {
	_root.World._y += speed;
   }
  }
 };
}



I haven’t tested this code, but my code works and I’m pretty darn shure that if(checkTrees()||checkObjects()){ works, lol.