Legacy GM spawning death

W

Wintermute()

Guest
classic game problem I am having in the last week of trying to solve it.

When my player dies, it spawns in the same place on screen, and there is a period of indestructability. (similar to Joust, the classic arcade game) if the player spawns onto a place that is simultaneously occupied by an enemy, all lives get lost and game over happens within fractions of a second, regardless of the invulnerability... but, The invulnerability DOES work if the enemy object, or enemy projectiles are not immediately occupying that same space on the screen - but then pass through the spawning, indestructible player fine, no problem. So the issue seems to be that very first moment of spawning, and if a hostile object is in that same space.

Wondering: what is an easy way to check for the existance of an object, before spawning, and move the spawn point away (x) pixels ?

thank you
 

obscene

Member
Basically you need a script that randomly selects an area and checks if an enemy is there. If there is, repeat randomly selecting an area again and checking for an enemy. After a few tries you'll find a safe place.

But also it shouldn't be hard to make your player invulnerable at start. Actually in the create event of your player it should be this way automatically and then a timer sets him/her back to vulnerable in a moment.
 
W

Wintermute()

Guest
Basically you need a script that randomly selects an area and checks if an enemy is there. If there is, repeat randomly selecting an area again and checking for an enemy. After a few tries you'll find a safe place.

But also it shouldn't be hard to make your player invulnerable at start. Actually in the create event of your player it should be this way automatically and then a timer sets him/her back to vulnerable in a moment.
Thanks, but as I said in the original post, my player is already invulnerable at the start ie "The invulnerability DOES work if the enemy object, or enemy projectiles are not immediately occupying that same (spawn) space on the screen"

the problem is If there is an enemy existing at the spawn point when my player spawns, he dies - even though the invulnerable (no collision sprite) mask exists.(very weird.)

What I am trying to find is a way to check point (x,y) for an enemy and if one exists, spawn (x) pixels away from it.
 

obscene

Member
What I am trying to find is a way to check point (x,y) for an enemy and if one exists, spawn (x) pixels away from it.
Well you pretty much wrote the code in that line....

var xx=whatever;
var yy=whatever;
if (instance_exists(xx,yy,obj_enemy)) xx+=some_value;
instance_create(xx,yy,etc.);
 
W

Wintermute()

Guest
thank you. I'm still much better at describing the logic, than writing the code :) I appreciate your help !
 
Top