
06-15-2014, 07:18 AM
|
|
Deleted by Darlene159
|
 |
Join Date: Sep 2013
Location: Deleted by Darlene159
Posts: 360
|
|
Quote:
Originally Posted by blackbeltben
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.y += 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(1, 32, 32);
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.y += 1;
}
}
|
something like this?
PHP Code:
function isBlocking(tile) {
temp.blocktiles = {0,16,1024,1025,1026,1027,1028,1029};
return
tiles[player.x + 1.5, player.y + 2] in temp.blocktiles ||
this.checkBlockNPCs()
;
}
function checkBlockNPCs() {
temp.npcs = findareanpcs(player.x + 1.5, player.y + 2, 0.0625, 0.0625);
for (temp.n : 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.
|
|
|
|