View Single Post
  #15  
Old 05-31-2007, 12:40 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by DustyPorViva View Post
Why do
PHP Code:
function onWeaponfired() {
  if (
player.dir==0shoot(blahblah crap for direction 0);
  if (
player.dir==1shoot(blahblah crap for direction 1);
  if (
player.dir==2shoot(blahblah crap for direction 2);
  if (
player.dir==3shoot(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.
__________________
Reply With Quote