Quote:
Originally Posted by DustyPorViva
Why do
PHP Code:
function onWeaponfired() {
if (player.dir==0) shoot(blahblah crap for direction 0);
if (player.dir==1) shoot(blahblah crap for direction 1);
if (player.dir==2) shoot(blahblah crap for direction 2);
if (player.dir==3) shoot(blahblah crap for direction 3);
}
when you can do
PHP Code:
function onWeaponfired() {
shoot(formulate the angle depending on the direction);
}
?
Sure, the first way works, but it's silly to not try to improve your scripting by finding shorter alternatives. Like I said, it's better practice. There may not be any hard evidence as to why, in terms of efficiency, but you can learn a lot of things by trying to think outside the box and find ways to shorten your code.
|
????????
I never said anything about something like that. If there is a way to make it shorter, fine. I'm saying long doesn't mean bad, which is true. Short doesn't even mean more effiecent, though it can be most of the time.