Pointer Question

Game Editor comments and discussion.

Pointer Question

Postby Soullem » Sun Oct 14, 2012 12:54 am

I am trying to make a little soccer game and I have a code like this.
Code: Select all
Actor* xpointer = getclone("ManU.0");
Actor* ypointer = getclone("ManU.0");
Actor* xpointer1 = getclone("ManU.1");
Actor* ypointer1 = getclone("ManU.1");
xpointer->x;
ypointer->y;
xpointer1->x;
ypointer1->y;



if (abs(xpointer-Ball.x)<abs(xpointer1-Ball.x))
{
    P=0;
}
if (abs(xpointer-Ball.x)>abs(xpointer1-Ball.x))
{
    P=1;
}






Why wont it work??? It gives me an error message
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Pointer Question

Postby Soullem » Sun Oct 14, 2012 2:16 am

Nevermind figured it out
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: Pointer Question

Postby skydereign » Sun Oct 14, 2012 2:43 am

For the record, variables are multi-use. Namely you can store the clone with the getclone, and use it whenever (you don't need one per variable).
Code: Select all
Actor* p1 = getclone("ManU.0");
Actor* p2 = getclone("ManU.1");

p1->x+=10;
p2->x+=10;
p1->y+=5;
p2->y+=5;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Pointer Question

Postby Soullem » Sun Oct 14, 2012 2:58 am

Pointers are one of those things that I could not get untill I had this AHA moment. And now they are really simple and obvious. And thanks for the info about multi use. Will make my code look much better.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest