Enemy Touch = Death?

Started by blueshamoo, Mon 25/08/2008 02:41:17

Previous topic - Next topic

blueshamoo

Hi everyone, thanks for being so helpful. I'm new to this software but I have begun to make a game in adventure style and I am stuck on something.

For anyone familiar with king's quest, there is a part in number V where a monster comes out of the cave at him, and if you dont throw a pie in his face in time, you die.

I rigged up some code that made it so when you click the last display message a monster comes towards you, but when it gets to you how do you make a code where you go to the "You lose" room automatically?

Also, you can see the monster waiting for you to finsh clicking the display messages.. is there a way to keep him off stage until then or should I use invisible for that?

zabnat

You could use Character.IsCollidingWithChar function in rooms repeatedly execute to check if monster is colliding with player character. This isn't pixel perfect collisiondetectiong as it only checks if baselines are overlapping. Or you could do your own check. For example by manually checking that monsters position is close enough to player position.
Code: ags
if(monster.x > player.x - 10 && monster.x < player.x + 10 && monster.y > player.y - 5 && monster.y < player.y + 5)
  player.ChangeRoom(302); // where 302 is the number of your "You lose" room


Depending what kind of background and setup your room has, you can hide the monster behind something (using walkbehinds) or just simply place it outside the screen by giving a x-coordinate that is less than zero or greater than room width. Since you don't have walkable areas outside the screen you need to define walkWhere parameter as eAnywhere if you use Character.Walk to move the monster.

Baro

Quote from: zabnat on Mon 25/08/2008 06:32:56
You could use Character.IsCollidingWithChar function in rooms repeatedly execute to check if monster is colliding with player character. This isn't pixel perfect collisiondetectiong as it only checks if baselines are overlapping.

Wasn't there a perfect collision module by SSH?
EDIT: *cough*

blueshamoo

#3
Thanks for the codes guys.

Had a problem figuring out repeat checking til I found :


"repeatedly execute to check if monster is colliding"

Messing around in AGS... I went to the actions for the room I'm in, and there i see an option for a function called "repeatedly execute" ...
T__T

I guess we'll see if this solves the problem.

is that the main way to do it?


-UPDATE- Problem solved, thanks again guys. it works like a charm!!!!

SMF spam blocked by CleanTalk