Sequence of moves using MoveTo

Non-platform specific questions.

Sequence of moves using MoveTo

Postby mcavalcanti » Tue Oct 04, 2011 1:56 pm

Hello, guys.

Is there a simple way to make a sequence of moves using MoveTo and MoveFinish? For example, I have a ship that make a square move. It comes from the left top of the screen, go down, go to the right, and come back to the top. When Y is smaller than -350, the ship is destroyed.

Code: Select all
if(x==30&&y<80){MoveTo("Event Actor", 30.000000, 80.000000, 8.000000, "Game Center", "");}
else if(x==30&&y>=79){MoveTo("Event Actor", 600.000000, 80.000000, 3.000000, "Game Center", "");}
else if(x==600&&y>=79){MoveTo("Event Actor", 600.000000, -400.000000, 5.000000, "Game Center", "");}
else if(x==600&&y<=-350){DestroyActor("Event Actor");

But it is an amount of code. And I'm avoiding to use paths because I think path moves are, well, not natural. Any good solution? Best.
Mario Cavalcanti
----------------------------
Code is poetry.
User avatar
mcavalcanti
 
Posts: 54
Joined: Fri Jul 22, 2011 1:09 am
Location: Rio de Janeiro, Brazil
Score: 1 Give a positive score

Re: Sequence of moves using MoveTo

Postby NERDnotGEEK » Tue Oct 04, 2011 4:55 pm

You can achieve the same effect just adding on x and y values. EG to go in a square from 0 and back to 0 again you'd do this.
Code: Select all
int i;
if(i<50)
{
    y = y - 1;
    i = i + 1;
}
else if(i<100)
{
    x = x + 1;
    i = i + 1;
}
else if (i<150)
{
    y = y + 1;
    i = i + 1;
}
else if (i<200)
{
    x = x - 1;
    i = i + 1;
}




NERDnotGEEK
 
Posts: 75
Joined: Sat Oct 30, 2010 1:48 am
Score: 12 Give a positive score

Re: Sequence of moves using MoveTo

Postby mcavalcanti » Tue Oct 04, 2011 9:53 pm

Hey, thanks! It's working very nice. Many possibilities with this method. :D
Mario Cavalcanti
----------------------------
Code is poetry.
User avatar
mcavalcanti
 
Posts: 54
Joined: Fri Jul 22, 2011 1:09 am
Location: Rio de Janeiro, Brazil
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest