Thread: Snake
View Single Post
  #6  
Old 04-03-2009, 11:45 PM
Damix2 Damix2 is offline
RED SQUARE CLUB
Join Date: Nov 2003
Location: NY-what's better?
Posts: 3,577
Damix2 will become famous soon enough
Quote:
Originally Posted by fragman85 View Post
I just slipped throught it, but here some small tips:

Instead of:

if(blabla == 0) you can use if (!blabla)

Oh and also, instead of:

PHP Code:
      if (keydown(1)) { 
       
this.dir 1
      } 
      if (
keydown(2)) { 
       
this.dir 2
      } 
      if (
keydown(3)) { 
       
this.dir 3
      } 
      if (
keydown(0)) { 
       
this.dir 4
      } 
you can use:

PHP Code:
for (i=0i<4i++) {
  if (
keydown(i)) {
    
this.dir i;
  }

Ahh, thanks, I'll do that next time.

Quote:
Originally Posted by xXziroXx View Post
Instead of doing...

PHP Code:
this.on 1
this.on 0
... I'd suggest doing ...

PHP Code:
this.on true
this.on false
It just looks cleaner to me.
Guess that one is preference, I've always used 0 and 1s instead of booleans where I could. Though it is noted and I appreciate the reply.
__________________
Reply With Quote