View Single Post
  #14  
Old 05-31-2007, 04:53 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote