Hey all, back again. 

I'm doing a remake of centipede, and am looking for suggestion on the
mouse tracking routine (in as3).

The enivronment:  The player is of course at the bottom of the screen, and
can only move up a specific distance.  He may be blocked by mushrooms in
this area as well.

Speficially, I have two ways of player motion with the mouse I've tried
and neither one is 100% accurate:

1) Set the player graphic equal to the mouse reading:


   thePlayer.x = this.mouseX;
   thePlayer.y = this.mouseY;

   This is the same as thePlayer.startDrag(), just chose to go this route.
   Player tracks the mouse motion perfectly this way of course.
   Then the code checks for mushroom collision, which stops the player
   motion.

   The issue I'm having is, whenever the player comes in contact with
   a mushroom in the lower player movement area, it's supposed to stop
   dead, forcing the player to move around it.  With this method though,
   it stops for a second, but then skips over the mushroom once the mouse
   moves past it.  Likewise, it creates a "sticking" at the upper, lower
   right, and left boundries since it sits there until the mouse enters
   back in to the "player zone".

2) Record previous mouse motion in x and y, and compare it to current.  If
   its moving right, move the player right 1 place.  Mouse moving left,
   moving player left one space, etc.:

   if (previousMouseX < this.mouseX)
   {
        thePlayer.x += playerSpeed;
   }
   else
   {
        thePlayer.x -= playerSpeed;
   }

   And similar for y direction.  Now, this code works perfect with the
   mushroom obstruction dectection.  But I'm having the opposite issue
   from the first code: The mouse tracking makes it harder to move in a 
   straight line, and the mouse moves out of the stage very quickly,
   being out of proportion to the rate of the player motion.  Upping the
   playerSpeed of course doesn't help, that just makes the player graphic
   jump around to quick.

If anyone on this list that's played around with these types of issues
before has an suggestions, I'd greatly appreciate it.



Marty
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to