Thread: NPC Troubles :(
View Single Post
  #9  
Old 01-05-2005, 01:30 AM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
Well, first off, it's a lot more effiecient:
PHP Code:
this.= (keydown(3) - keydown(1));
this.= (keydown(2) - keydown(0));
playerx += this.this.speed;
playery += this.this.speed
PHP Code:
for (direction 0direction 4direction ++) {
  
playerx += keydown(direction) * vecx(direction) * this.speed;
  
playery += keydown(direction) * vecy(direction) * this.speed;

Basically here, you're saying "Go by there! Then by here! ... ...", where they can cancel out... 5 right + 5 left = 0 movement. Thus, if you press the right and left movement, you would't move at all... It would prevent calculating one side, then calculating the next.

Other then that, the rest doesn't change much at all...Other then you declared a variable where I didn't. And I used tokenize. Differant ways to proceed.
Reply With Quote