Jump to content


imsweet

Member Since 08 Apr 2012
Offline Last Active May 11 2012 04:41 PM

Posts I've Made

In Topic: enemy destroy when player only jump onto it

06 May 2012 - 09:52 AM

If the player will always touch the door when moving from one room to the next, it is the perfect place for a checkpoint.

Depending on your game, you may want to use the "save a game" action, which saves everything in the game exactly as it is at the time of saving (with a few exceptions you wont come across until you start coding), and it will load exactly as it was when saved. This can be an easy way to create a checkpoint, but can have problems. For example, if your game has lives, then you may only have one life left when you pass the checkpoint, then die in the room. When you respawn, you will only have one life (because that is how many you had when you saved the game), but you may want the player to respawn with 3 lives.

There are many reasons why a "save game" type checkpoint wouldn't work, so the other option is just to save the player's position in a variable.

When the player passes the door (use "object at position" in the step event, as you may have problems placing it in the collision event since you want to be able to walk freely through the door), use "set the value of a variable" to set the variable "save_x" to "x" and the variable "save_y" to "y" (without the quotes). You should also initialise the variables in the create event of the player, using the exact same actions. Then when the player dies, use the "jump to position" action, and put "save_x" in the "x" box, and "save_y" in the "y" box.



I can't get you. I'm new to this. But it's okay...:(

In Topic: enemy destroy when player only jump onto it

06 May 2012 - 09:08 AM

If you restarted him at *exactly* the spot *immediately* before he died, then chances are he would die again straight away. Usually it's pretty hard to work out a good respawn spot automatically, so a better idea is to use checkpoints. Add checkpoints every so often in safe areas. When the player passes them, either save the game or store the position in variables. Then when the player dies, send them back to the checkpoint.

I think it's best to show the checkpoints so the player knows where they are, but if you don't want to, you can also make the checkpoint invisible so the player doesn't know it's there, but it will still take him back there if he dies.



Actually i'm developing the game based learning. In my game the player have to answer the question. Along the long room I put the door sprite. When the player collide with the door the player will go the another room to answer the question. Then the player will back to the room. I have 10 door. Can the door use as a checkpoints?

In Topic: enemy destroy when player only jump onto it

06 May 2012 - 08:17 AM

The collision event makes sure the player is touching the enemy, then the "if" expression takes care of checking where the player is in relation to the enemy.

I have made you an example, hopefully this helps you work it out:

http://www.davesexamples.com/jumponenemy.gmk



Thank you very much it help. But how I need to do to make the player restart at the latest place before he died. I have a long room. I do not know on how to restart at the latest position. My room width is about 10000. What I had did right now is the player will restart at the beginning of the room even the latest position before it died is x=9783. I want the player to restart at the latest position before it died.

In Topic: enemy destroy when player only jump onto it

06 May 2012 - 06:20 AM

Did you remember to put the "else" in there? Also, only put the actions in the player's collision event with the enemy, not in the enemy's collision event with the player.


Yes..I get what you say. That mean when the player collide with the enemy it will die. So the player need to restart the level. How I need to do to make sure the player at specific position?

In Topic: enemy destroy when player only jump onto it

06 May 2012 - 03:25 AM

This can be done using drag and drop. In the collision event with the enemy, check the y position and the vspeed. You only want the player to kill the enemy when he is falling and is above the enemy, so in the player's collision event with the enemy, the code would look like this:

if (y < other.y && vspeed > 0) //if y position is smaller (above, since y = 0 is the top of the room, and it gets bigger as you go down) and vspeed is biger than 0 (falling)
{
  with (other) instance_destroy(); //destroy enemy object
}
else
{
  //enemy kills you
}

To convert this into Drag and Drop:

:GM060: in the box put: y < other.y && vspeed > 0
:GM026: be sure to click the "other" radio button
:GM064:
:GM026: this time leave it as "self"

This will detroy the enemy if you are above it (and falling), and destroy the player if you are not above it.
You probably don't want to destroy the objects (maybe change enemy to "dying_enemy", and restart the room if player dies), but this should give you the idea.



I have done using the drag and drop. But both of the enemy and player were destroy. Where did it wrong?