A little animation

Started by maraki_ang3l, Sun 07/06/2009 21:15:12

Previous topic - Next topic

maraki_ang3l

I have my main character entering one room and there  it exists a second character who is walking right left all the time my code is the following :

function room_AfterFadeIn()
{
   cSecond.LockView(13);
   cSecond.Animate(0, 9, eRepeat, eBlock, eForwards);
 
}



function room_RepExec()
{
 cSecond.Walk(43, 449, eBlock, eWalkableAreas);
 cSecond.Walk(959, 449, eBlock, eWalkableAreas);
}

I want my main character to be able to work while the second is walking so I put eBlock,but with the eblock my second character is not walking.

If i put eNoBlock then the second character walks but i have the cursos with the clock...

Any ideas? :)

JpSoft

Code: ags
function room_AfterFadeIn()
  {
  cSecond.LockView(13);
  cSecond.Animate(0, 9, eRepeat, eNoBlock, eForwards);
  cSecond.Walk(43, 449, eNoBlock, eWalkableAreas);
  }

function room_RepExec()
  { 
  if ((cSecond.x == 959) && (cSecond.y == 449))cSecond.Walk(43, 449, eNoBlock, eWalkableAreas);
  if ((cSecond.x == 43) && (cSecond.y == 449)) cSecond.Walk(959, 449, eNoBlock, eWalkableAreas);
  }


This must work

Jp

Trent R

Basically, you can't repeatedly call .Walk() every frame, cause they'll pile up and eventually the character never moves. Jp has changed this so that it only calls a .Walk command if the character is on one of two points.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

GuyAwesome

#3
Or
Code: ags

function room_RepExec()
{ 
  if (cSecond.Moving == false) {
    cSecond.Walk(43, 449);
    cSecond.AddWaypoint(959, 449);
  }
}


You don't need the eNoBlock, eWalkableAreas parameters for cSecond.Walk, because they're the defaults, as is eForwards for Animate. AddWaypoint ignores walkable areas, so it might not be what you want - in which case go with Jp's version.

Why are you using LockView and starting a repeating animation? Character.Walk will replace that animation with the walking animation (or rather, the appropriate loop from view 36). If you want to keep the animaton running, try using cSecond.Move instead of Walk.

Dualnames

Code: ags


int counter;
function room_RepExec()
  { 
if ((cSecond.x == 959) && (cSecond.y == 449)) {
if (counter!=80) {//in case you need for the character to wait before walking.
counter++;
}
if (counter==80) {
cSecond.Walk(43, 449);
counter=0;
}
}

 }


Don't think it will be mostly helpful but then again it might.

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Trent R

#5
DN, would you even need the !80 check? I'm thinking that if it is 79 (satisfying !80) then it will be come 80 and then come to the next if and satisfy it. The same would happen without the !80 line, and counter will never be 80 to even check against that line.

[Edit]: Oh wait, that would be useful. You can set counter to a value greater than 80 to disable it. Please forgive my ignorance....


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

GuyAwesome

Quote
You can set counter to a value greater than 80 to disable it.

In which case, I'd make it a <80 check, instead of !=80. No functional difference, but 'greater than 80' is also 'not equal to 80', and I don't like the idea of the counter ticking away in the background for no reason. But that could just be me - I don't think it'll interfere with anything if it does keep running, I just ... don't like it.

JpSoft

QuoteYou can set counter to a value greater than 80 to disable it.

I did it for the verbcoin system i just designed; if in the moment you press the left button the cursor is over nothing or if you move the mouse before the counter reach 15 is just  matter to assign 16 to the value of counter. The verbcoin GUI never will show until you reset the counter.

Code: ags

if (IsButtonDown(eMouseLeft)) counter++;
else counter=0;
if (GetAtScreen(mouse.X, mouse.Y) == null) counter == 16; 
if (OldX != mouse.X) || (OldY != mouse.Y) counter = 16;
if (counter == 15) // Open verb coin
OldX = mouse.X;
OldY = mouse.Y;


Its not the excat code, but i belive it explains very clear how it works

Jp

Trent R

Quote from: GuyAwesome on Tue 09/06/2009 17:06:22
In which case, I'd make it a <80 check
Haha, totally right. I made my first reply to the thread, and then came back to it after letting it stew in my head and forgot that is should be <80. But, like you said it would disable it anyways (I also agree that it would bother me too).

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

maraki_ang3l

Thanks you all for your replies.I tried them but Ms.GuyAwersome was exactly what i needed. ;D

Thanks guys.

Trent R

Glad to help. Besides, it's good for everybody (not just the OP) to discuss other ways of solving problems. Makes you a better scripter.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

GuyAwesome

Indeed, you're welcome. But it's Mr. GuyAwesome, not Ms. ;D

maraki_ang3l

Ooops sorry for the mistake  ;)

SMF spam blocked by CleanTalk