View Single Post
  #18  
Old 06-15-2014, 07:18 AM
Jakov_the_Jakovasaur Jakov_the_Jakovasaur is offline
Deleted by Darlene159
Jakov_the_Jakovasaur's Avatar
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 360
Jakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud ofJakov_the_Jakovasaur has much to be proud of
Quote:
Originally Posted by blackbeltben View Post
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;
  }
 } 
something like this?

PHP Code:
function isBlocking(tile) {
  
temp.blocktiles = {0,16,1024,1025,1026,1027,1028,1029};
  return
    
tiles[player.1.5player.2in temp.blocktiles ||
    
this.checkBlockNPCs()
  ;
}

function 
checkBlockNPCs() {

  
temp.npcs findareanpcs(player.1.5player.20.06250.0625);

  for (
temp.temp.npcs
    if (
temp.n.blocking)
      return 
true;

  return 
false;

but then im not sure its a good idea to be checking just a single pixel for collisions, graal movement usually checks the width of the players body (2 tiles or 32 pixels)
__________________
This signature has been deleted by Darlene159.
Reply With Quote