function CreateBullet(hero)
{
var d = GetPersonDirection(hero);
var x = 0, y = 0;
switch(d) {
case "north": y = -1; break;
case "south": y = 1; break;
case "west": y = -1; break;
case "east": y = 1; break;
}
I was studying your code and have 2 questions:
Why is it Y only, that is set-up, I thought with computer co-ordinates, If the top left of the computer screen has co-ordinates of X = 0 and Y = 0 then:
North would be a +Y number
East would be a +X number
South would be a -Y number
West would be a -X number
Also I though we would create the bullet in front of the player so it doesn't check if its been obstructed when its created over the player/hero.
If my player is 16 pixels all round, I'm guessing Sphere checks X and Y positions from the center of the sprite ( I hope so ). So the bullets XY co-ordinates would need to be + or - 8 ( half of 16 ) from the players XY co-ordinates. So the code for the case statements would be.
case "north": y = +8; break;
case "east": x = +8; break;
case "south": y = -8; break;
case "west": x = -8; break;
Or I might be misunderstanding something.
the second question is I noticed the arguments in the bullet.push:
Start_x = GetPersonX(hero) + x*16
Start_y = GetPersonY(hero) + y*16
how did you come to this? I'm a bit confused.