# Need a person to write Simple Array for me

**URL:** <https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883>\
**Category:** Uncategorized\
**Created:** [August 10, 2004, 12:10am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883 "2004-08-10T00:10:32Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Mike\_D1](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Mike\_D1](https://forum.kirupa.com/u/Mike_D1)\
**Post date:** [August 14, 2004, 2:01am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/21 "2004-08-14T02:01:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mike\_D1](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Mike\_D1](https://forum.kirupa.com/u/Mike_D1)\
**Post date:** [August 14, 2004, 3:23am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/22 "2004-08-14T03:23:45Z")

</div>

[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]

---

<div class="post-metadata">

**Author:** ![Brandon](https://avatars.discourse-cdn.com/v4/letter/b/f08c70/32.png) [@Brandon](https://forum.kirupa.com/u/Brandon)\
**Post date:** [August 15, 2004, 12:58am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/23 "2004-08-15T00:58:49Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![APDesign](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@APDesign](https://forum.kirupa.com/u/APDesign)\
**Post date:** [August 15, 2004, 2:17am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/24 "2004-08-15T02:17:19Z")

</div>

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

Did you try the .fla?

My .fla worked fine for me.

---

<div class="post-metadata">

**Author:** ![Mike\_D1](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Mike\_D1](https://forum.kirupa.com/u/Mike_D1)\
**Post date:** [August 15, 2004, 4:21am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/25 "2004-08-15T04:21:28Z")

</div>

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…)

```auto

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;
   }
  }
 };
}

```

---

<div class="post-metadata">

**Author:** ![APDesign](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@APDesign](https://forum.kirupa.com/u/APDesign)\
**Post date:** [August 15, 2004, 8:04am UTC](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883/26 "2004-08-15T08:04:33Z")

</div>

> [@Mike D](#):
>
> 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…)

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

[Previous page](https://forum.kirupa.com/t/need-a-person-to-write-simple-array-for-me/118883.md?page=1)
