Thread: Mirror
View Single Post
  #12  
Old 07-26-2016, 06:40 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko is a jewel in the roughKirko is a jewel in the rough
oops I never posted the code :o

been a while since I made it so I decided to rewrite it just now to shorten it up.
Only problem is that it only shows your character
PHP Code:

//#CLIENTSIDE
function onPlayerEnters() {
  
setshape(1, this.mirror_width * 16, this.mirror_height * 16);
  
showTiles();
  
onTimeOut();
}

function 
onTimeOut() {
  if (
player.x in |thiso.x - 1.5, thiso.x + this.mirror_width - 1.5| && 
      
player.y in |thiso.y + this.mirror_height - 1.5, y + (this.mirror_height * 2) - 2|){ 
    
with (findimg(50)) {
      
x = player.x;
      
y = thiso.y + (thiso.y - playero.y) + thiso.mirror_height + 2.5;
      
layer = 1;
      
      
ani = player.ani.name @ "[" @ player.anistep @ "]";
      
dir = player.dir == 0 ? 2 : player.dir == 2 ? 0 : player.dir;
      
head   = player.head;
      
shield = player.shield;
      for (
temp.i = 0; temp.i < 5; temp.i ++) colors[i] = player.colors[i];
      for (
temp.i = 0; temp.i < 20; temp.i ++) attr[i] = player.attr[i];
    }
  } else
    
hideimg(50);
    
  
setTimer(0.05);
}

function 
showTiles(){
  
temp.mw = this.mirror_width;
  
temp.mh = this.mirror_height;

  
temp.area = temp.mw * temp.mh;
  
temp.y    = this.y + temp.mh - 1;
  
  for(
temp.i = 0; temp.i < temp.area; temp.i ++) {
    
temp.y += (temp.i % temp.mw) == 0 ? 1 : 0;

    
with (findimg(201 + temp.i)) {
      
x = (thiso.x) + ((temp.i % temp.mw) * 1);
      
y = (thiso.y + temp.mh - 1) - (int(temp.i / temp.mh) * 1);
      
      
image = gettileset();
      
partx = TilesToImage(this.level.tiles[x, temp.y])[0];
      
party = TilesToImage(this.level.tiles[x, temp.y])[1];
      
partw = parth = 16;
      
stretchy = -1;
      
layer = 0;
    }
  }
}

//credit to dusty 
function TilesToImage(t) {
  if (
t.type() == 0) {
    
temp.px = (int(t%16)*16)+(int(t/512)*256);
    
temp.py = (int(t/16)*16)%512;
    return {
px,py};
  } else if (
t.type() == 3) {
    
temp.imgarray = new[0];
    for (
temp.i : t) {
      
temp.px = (int(i%16)*16)+(int(i/512)*256);
      
temp.py = (int(i/16)*16)%512;
      
imgarray.add({px,py}); 
    }
    return 
imgarray;
  } else return -
1;
} 
Reply With Quote