Page 1 of 1

actor retrieval using getactor(x,y)

PostPosted: Thu May 26, 2011 3:36 pm
by sonicfire
hi folks! have a little problem here:

Code: Select all
Actor *chk;
if (CollisionFree("Event Actor", x-32, y))
    {
        moveLeft=1;
        count=0;
        canMove=0;
    } else {
        chk = getactor(x-32,y);
        if (chk->isground==1)
        {
            moveLeft=1;
            count=0;
            canMove=0;
           


the part where it doesn´t work is:
chk = getactor(x-32,y);
if (chk->isground==1)


basically from the player´s position i wanna "look for" an actor / an actor´s (clone´s) variable.
so that i can move my player if that particular actor has the variable "isground" set to one.
however, i have the feeling it doesnt retrieve or "get" the actor at all. no matter what i do nothing happens.
is there any mistake in there? am i not supposed to use getactor this way?

any help REALLY appreciated!! thanks!! :D

Re: actor retrieval using getactor(x,y)

PostPosted: Thu May 26, 2011 3:53 pm
by sonicfire
...could it be that i need to use getclone rather than getactor? but how can i get a clone at position xyz?

Re: actor retrieval using getactor(x,y)

PostPosted: Thu May 26, 2011 7:09 pm
by jimmynewguy
maybe this will help you, I pretty much assumed you were making an grid based rpg (rouge like) game. Hope I was right :lol: It makes a random map (leaving ones only 3 "squares" away from the player open so you're guaranteed some movement). Green is grass and brown is dirt, black is a wall. If it's black the isground variable will be zero.

Code: Select all
Actor * chk = getactor(player.x-32, player.y);


That should fix your original code if this isn't what you were looking for too. And change the else part..

Code: Select all
chk = getactor(x-32,y);//no need for this
        if (chk->isground==1)
        {
            moveLeft=1;
            count=0;
            canMove=0;


Hope I did some good!
example.zip
Basic
(8.69 KiB) Downloaded 217 times


EDIT: This is probably a more confusing version, but it allows movement in diagonals between corners of the wall (see picture).

Re: actor retrieval using getactor(x,y)

PostPosted: Fri May 27, 2011 3:53 pm
by sonicfire
thanks! i will have a look! :)

Re: actor retrieval using getactor(x,y)

PostPosted: Sat May 28, 2011 7:16 am
by sonicfire
thanks so much!
Code: Select all
if (CollisionFree("Event Actor", x-32, y))
x -= 32;
else
{
x -= 32 * (chk->isground);
}



that * (chk->isground) idea is amazing! 8) why didn´t i think of that?

Re: actor retrieval using getactor(x,y)

PostPosted: Sat May 28, 2011 2:06 pm
by jimmynewguy
No problem, sometimes it just takes someone else looking at it to figure out what's wrong or whatever :wink:

Re: actor retrieval using getactor(x,y)

PostPosted: Sat Jun 14, 2014 3:09 pm
by Redfizh
Thanks. I tune this for my need. It didn't work like it should after I transferred all the needed scripts and changed names, sizes and colors. Map was generated and moving worked smoothly but collision to "wall"-tile didn't happen, it was like ground was made of "mud", "grass" and invisible walls around clear field. Maybe It's caused by my different 16x16.pngs but I were happy with results I got after:
if(isground==1) { DestroyActor("Event Actor") }
My logic didn't figure your animpos-line's math but after Switch each case give's different "wall"-tile and that is all I need 8)