Animation Based on Actor movement

Game Editor comments and discussion.

Animation Based on Actor movement

Postby shadowburn » Tue Jul 11, 2006 8:59 pm

Hi,

This may be related to Parent child relationship, however maybe not. How can I take 2 alternate backgrounds using transparency and make them move in the opposite direction when moving a centered character on the screen.

For instance, the infinite x background1 moves left once the character gets 20 pixels from the right side, and while its moving, the infinite x background 2 moves right once background1 starts moving left?

-Jon
shadowburn
 
Posts: 5
Joined: Tue Jul 11, 2006 8:53 pm
Score: 0 Give a positive score

Postby Game A Gogo » Tue Jul 11, 2006 9:48 pm

maybe in draw actor:
Code: Select all
x=center.x/20;
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

draw actor

Postby shadowburn » Tue Jul 11, 2006 10:19 pm

Get an error. x=center.x/20;


Illegal Structure Operation.
shadowburn
 
Posts: 5
Joined: Tue Jul 11, 2006 8:53 pm
Score: 0 Give a positive score

Cool.

Postby shadowburn » Wed Jul 12, 2006 6:09 pm

As rediculous as this was, I coded the actor animations all up to work now. Though thier may have been some hidden settings somewhere I havent found or maybe im blind and just missing, im sure it might have simplified tha matter abit more. I really can say that I do enjoy the power of the scripting language though. It has greatly opened up some flexibility in me doing this with the actor entites. I will have to open up another post on a new question and issue though. Thanks for the earlier reply.

-Jon
shadowburn
 
Posts: 5
Joined: Tue Jul 11, 2006 8:53 pm
Score: 0 Give a positive score

Postby Game A Gogo » Thu Jul 13, 2006 12:44 am

you need to have a center actor that follows the player and the screen is parented to
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Fuzzy » Thu Jul 13, 2006 1:48 am

Game a Gogo wrote:maybe in draw actor:
Code: Select all
x=center.x/20;


You cannot safely do this because x may equal zero, which may not be divided.

Here is a work around. Use multiplication.

Code: Select all
x=center.x*0.05;


or slightly more obfuscated..

Code: Select all
x=center.x*1/20;


but thats going to be messy. Trust me.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Game A Gogo » Fri Jul 14, 2006 12:19 am

or maybe
Code: Select all
x=center.x/20;
if(center.x==0)
{
center.x+=1;
}
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DilloDude » Fri Jul 21, 2006 6:51 am

Game a Gogo wrote:or maybe
Code: Select all
x=center.x/20;
if(center.x==0)
{
center.x+=1;
}
That wont work because it is still dividing it by zero.
Try:
Code: Select all
if (center.x != 0)
{
    x = center.x/20;
}
else
{
    x = 0;
}
But I think
Code: Select all
x = center.x * .05;
is simpler
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby DilloDude » Fri Jul 21, 2006 7:06 am

ThreeFingerPete wrote:
Game a Gogo wrote:maybe in draw actor:
Code: Select all
x=center.x/20;

You cannot safely do this because x may equal zero, which may not be divided.

I just relized - this shouldn't be a problem because it is 0 divided by 20, which will be 0. It is when you have something divided by zero that you get the problem:
Code: Select all
x = 20/center.x;
could produce problems.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest