View Single Post
  #8  
Old 02-21-2006, 09:07 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
using my control movement script (movement functions, uploaded on graal.net), I came up with this specifically. Does it just about perfectly, except my movement scripts go exactly to the wall rather than rounding.

PHP Code:
function side_movement() {
  
this.1;
  
this.1;
  for (
i=0i<4i++) {
    if (
keydown(i)) {
      
temp.case_x player.x+vecx(i)*1.5*vecDir(this.speed_factor) - abs(vecy(i))*0.5;
      
temp.case_y player.y+1.5 vecy(i)*1.5*vecDir(this.speed_factor) - abs(vecx(i))*0.5;
      
temp.case_one tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);
      
temp.case_x player.x+vecx(i)*1.5*vecDir(this.speed_factor) + abs(vecy(i))*(5/8);
      
temp.case_y player.y+1.5 vecy(i)*1.5*vecDir(this.speed_factor) + abs(vecx(i))*(5/8);
      
temp.case_two tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;    
    
/* In case I screw this up
      temp.case_x = player.x+1 + vecx(i)*1.5 - abs(vecy(i))*0.5;
      temp.case_y = player.y+1.5 + vecy(i)*1.5 - abs(vecx(i))*0.5;
      temp.case_one = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);
      temp.case_x = player.x+1 + vecx(i)*1.5 + abs(vecy(i))*(5/8);
      temp.case_y = player.y+1.5 + vecy(i)*1.5 + abs(vecx(i))*(5/8);
      temp.case_two = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;
    */
      
if (temp.case_one xor temp.case_two) {
        if (
temp.case_one) {
          
this.offx 1.0 vecx(i)*1.5*vecDir(this.speed_factor) + abs(vecy(i))*0.5;
          
this.offy 1.5 vecy(i)*1.5*vecDir(this.speed_factor) + abs(vecx(i))*0.5;
          
movedx(abs(vecy(i))*this.sidemove_speed,player);
          
movedy(abs(vecx(i))*this.sidemove_speed,player);
        } else {
          
this.offx 1.0 vecx(i)*1.5*vecDir(this.speed_factor) - abs(vecy(i))*0.5;
          
this.offy 1.5 vecy(i)*1.5*vecDir(this.speed_factor) - abs(vecx(i))*0.5;
          
movedx(-abs(vecy(i))*this.sidemove_speed,player);
          
movedy(-abs(vecx(i))*this.sidemove_speed,player);
        }
      }
    }
  }

forgot to say, tilesSwitch would be the function you use for wall detection on an area.

Last edited by jake13jake; 02-22-2006 at 12:24 AM..
Reply With Quote