View Single Post
  #17  
Old 06-14-2014, 06:52 PM
blackbeltben blackbeltben is offline
Registered User
Join Date: Aug 2011
Posts: 83
blackbeltben is on a distinguished road
Blocking NPCs

I have my tiles working correctly thanks to you two

on Created:
PHP Code:
function isBlocking(tile) {
  
temp.blocktiles = {0,16,1024,1025,1026,1027,1028,1029};
  return (
tile in temp.blocktiles);

And the check:
PHP Code:
 if (!isBlocking(tiles[player.x+1.5,player.y+3])){
   
player.+= 1;
  } 
So if the player is not touching the blocking tiles, the player will fall
(for platformer system)


Now I want to go advanced and make collision with certain NPCs..

So I was wondering if someone could help me write this.


The NPC
PHP Code:
function onCreated(){
 
this.blocking true;
 
setShape(13232);
 
setImg("block.png");


The on Created:
PHP Code:
function isBlocking(tile) {
  
temp.blocktiles = {0,16,1024,1025,1026,1027,1028,1029};
  return (
tile in temp.blocktiles);
  
temp.blocknpc //Check if the temp.npc.blocking == true


The check:
PHP Code:
 if (!isBlocking(tiles[player.x+1.5,player.y+3])){
  if 
/*not colliding with npc that is blocking*/ {
   
player.+= 1;
  }
 } 
Reply With Quote