actor retrieval using getactor(x,y)

Non-platform specific questions.

actor retrieval using getactor(x,y)

Postby sonicfire » Thu May 26, 2011 3:36 pm

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
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby sonicfire » Thu May 26, 2011 3:53 pm

...could it be that i need to use getclone rather than getactor? but how can i get a clone at position xyz?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby jimmynewguy » Thu May 26, 2011 7:09 pm

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 218 times


EDIT: This is probably a more confusing version, but it allows movement in diagonals between corners of the wall (see picture).
Attachments
Grid Mover.zip
Diagonal Movement
(35.05 KiB) Downloaded 204 times
show.PNG
"Diagram"
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby sonicfire » Fri May 27, 2011 3:53 pm

thanks! i will have a look! :)
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby sonicfire » Sat May 28, 2011 7:16 am

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?
sonicfire
 
Posts: 425
Joined: Wed Nov 01, 2006 9:34 pm
Location: berlin germany
Score: 16 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby jimmynewguy » Sat May 28, 2011 2:06 pm

No problem, sometimes it just takes someone else looking at it to figure out what's wrong or whatever :wink:
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: actor retrieval using getactor(x,y)

Postby Redfizh » Sat Jun 14, 2014 3:09 pm

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)
Redfizh
 
Posts: 2
Joined: Wed Jun 11, 2014 4:29 am
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron