Thread: Onwall help
View Single Post
  #2  
Old 02-27-2011, 10:04 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
I didn't read everything, sorry. But here are a couple things that seem fishy, and a bit of advice, too.

First, these:
PHP Code:
temp.onwallx = (player.1.5) + temp.movex
temp.onwally = (player.2) - temp.movey
I've already changed those accordingly. You do want to use the center of the player as a base value, right? That's player.x + 1.5 and player.y + 2, not player.x + 1. Keep that in mind.

Also, you can very easily shorten your code right there:
PHP Code:
if(this.kdir == 0){player.dir 2;} 
elseif(
this.kdir == 1){player.dir 3;} 
elseif(
this.kdir == 2){player.dir 0;} 
elseif(
this.kdir == 3){player.dir 1;} 
Can be turned into this:
PHP Code:
player.dir = (this.kdir 2) % 4

And that's basically it. I'm too darn lazy to analyze your problem, sorry I suggest you get rid of the timeout stuff, though. Doing all that thingamajig at the top of doKnockback() every time it's being called seems a bit over the top. Just use a for-loop or something.
Reply With Quote