Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-02-2012, 10:15 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
Quote:
Originally Posted by Gunderak View Post
PHP Code:
      this.sx2 this.sx;
      
this.sy2 this.sy;
      if (
this.dir == && !onwall(this.sxthis.sy 0.5)) {
        
this.sy -= 0.5;
      }
      if (
this.dir == && !onwall(this.sx 0.5this.sy)) {
        
this.sx -= 0.5;
      }
      if (
this.dir == && !onwall(this.sxthis.sy 0.5)) {
        
this.sy += 0.5;
      }
      if (
this.dir == && !onwall(this.sx 0.5this.sy)) {
        
this.sx += 0.5;
      }
...
    if (
this.dir == && player.this.sy) {
      
player.-= 0.5;
    }
    if (
this.dir == && player.this.sy) {
      
player.+= 0.5;
    }
    if (
this.dir == && player.this.sx) {
      
player.-= 0.5;
    }
    if (
this.dir == && player.this.sx) {
      
player.+= 0.5;
    } 
I always criticise people for this so don't worry you're not alone.
Instead of writing all these seperate statement it's possible to compact them
PHP Code:
for (temp.04i++){
  if (
this.dir == temp.&& !onwall(this.sx vecx(this.dir) * 0.5this.sy vecy(this.dir) * 0.5)){
    
this.sx += vecx(this.dir) * 0.5;
    
this.sy += vecy(this.dir) * 0.5;
  }

Another good trick to remember is if you want to invert your direction instead of touching the direction you can just do vecx(dir)*-1 since I figured you're not so hot with math.

Also callimuc is correct in advising you to use updateboard although in my past the respawn method for those tiles becomes a bit messy which is something to keep in mind. None the less... you're on the right track so far, keep at it
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.