Character collides with object events not working...

Started by barefoot, Sun 12/06/2011 07:47:38

Previous topic - Next topic

barefoot

Hi

I am using a trial game to complete this task and I am having a problem. My character or object may be blocking events for when character collides with the object?

I am having my character jump up the screen via keypress 1 (move using -y  eNoBlock, Anywhere ) to head butt an object that is slowly moving right to left eNoBlock, eAnywhere.
I am having to use Wait(25) before the character then moves (move using +y ) back down the screen. Unfortunately the collision events do not take place when the character collides with the object (dreaded watch!) Think of Sonic the Hedgehog jumping up for Stars...

Code: ags

 object[0].Move(-25, 55, -1, eNoBlock, eAnywhere);


Global
Code: ags

{
  if (keycode == eKey1) {  // Key 1

  cEgo.StopMoving();
  cEgo.SetWalkSpeed(10, 10);
  cEgo.Move(cEgo.x + 0, cEgo.y -176, eNoBlock, eAnywhere);
 Wait(32);
  cEgo.Move(cEgo.x + 0, cEgo.y +176, eBlock, eAnywhere);
  cEgo.StopMoving();
 cEgo.SetWalkSpeed(7, 7);
	
}
}


I also have in Room

Code: ags

 function room_RepExec()
{
  if (cEgo.IsCollidingWithObject(object[0])) {
   object[0].Visible = false;
   Display("10 points.");
   GiveScore(10);
	 
}
}


Is there something i am overlooking or something I should replace/amend?

Grateful for all help

barefoot

I May Not Be Perfect but I Have A Big Heart ..

barefoot

Hi

This works up to the point of making object off and adding points but the character fails to move back down screen:

Global
Code: ags

{
  if (keycode == eKey1){ {  // Key 1
   
  cEgo.StopMoving();
  cEgo.SetWalkSpeed(10, 10);
  cEgo.Move(cEgo.x + 0, cEgo.y -176, eNoBlock, eAnywhere);
	
	
}
  if (cEgo.IsCollidingWithObject(object[1])==1 && player.Room==1) {
		
  cEgo.Move(cEgo.x + 0, cEgo.y +176, eNoBlock, eAnywhere);
 object[1].Visible = false;
  Display("10 points.");
  GiveScore(10);
{
 if (object[1].Moving) {
  object[1].StopMoving();


Help/hint still appreciated

barefoot

I May Not Be Perfect but I Have A Big Heart ..

barefoot

Hi

At the moment this is now solved.. If you have some options / hints for better scripting they would be welcomed.

barefoot
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

Well, something that stands out to me in the original code is that you're telling the Character.Move command explicitly not to block other scripts, and then immediately negating that by calling Wait.

So, your room_RepExec would never be run during that movement..seeing as you explicitly prevented it from doing so. Of course if you really needed to you could use repeatedly_execute_always (in the global or the room script), which isn't blocked by blocking commands like Wait.

barefoot

Cheers Monkey

Yes, I can see what you mean now...  it is now working as I wanted but more to do before I can finally close this case.

Thanks again Monkey

:=

barefoot

I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk