leet
Cold Store
Posts: 3
|
Post by leet on Feb 27, 2014 17:57:12 GMT
I'm making a Manic Miner-style platformer, with a fairly standard set of rules. You die if you fall too far. Previously I was opening the exits once you collect all the objects by putting a 'custom' block over the top of the door, then my scripts determined that if the player touched a custom block you moved to the next level. This works very nicely. However, I decided I wanted to repurpose the custom block for making conveyor belts, so I changed the 'next level' code to look at my player sprite's X or Y coordinate in order to determine whether it's time to change level or not. So now I put an 'empty space' block over the top of the door and check whether you've moved through it. That's fine for levels where you exit on the left or right of the screen, but I have one screen where you fall a long way and out of the bottom of the screen. This one's presenting a challenge because the 'fell too far' detection kicks in even if I tell it to move to the next level and you die as soon as you hit the exit. The code looks like this: if X >= 144 nextlevel endif fall I tried putting fall before the check, but the result's just the same. If I take the 'kill' out of the fell too far event it works fine. I tried using a variable to temporarily disable the kill in the fell too far event too but that didn't seem to work either. Anyone got any ideas? I'm stumped.
|
|
|
Post by egotrip on Feb 28, 2014 18:49:54 GMT
Did you try setting a variable when you change screen? Something like this might work.
if y>=256 let a = 1 screendown let y = 0 endif
and in your fell too far event if a=0 if other stuff you have kill endif else let a = 0 endif
|
|
leet
Cold Store
Posts: 3
|
Post by leet on Mar 1, 2014 15:27:46 GMT
I tried something similar to that, yeah, and it still fails. Unless I disable the 'kill' statement permanently my player just dies as soon as he hits the point where the door used to be. If I take the 'kill' command away he moves on to the next level as you would expect.
I wondered if I could test the player's X co-ordinate within the 'fell too far' event and use that instead of a variable, but if I try to check X or Y in that even the editor just tells me there's an error - I surmise I'm not allowed to do that there?
It's quite strange, I get the feeling I'm just doing something not-quite-right. Like I said before, it worked perfectly when I was using the custom block to determine whether you went to the next screen or not, I just don't seem to be able to get the same effect by checking the player's coordinates instead.
|
|
|
Post by Jonathan Cauldwell on Mar 14, 2014 17:55:25 GMT
You could try removing the KILL statement from the fall too far event and instead set a flag. Then check that flag right at the start of the player event and kill the player there if it has been set and you haven't touched the custom block.
|
|
leet
Cold Store
Posts: 3
|
Post by leet on May 5, 2014 15:26:42 GMT
You could try removing the KILL statement from the fall too far event and instead set a flag. Then check that flag right at the start of the player event and kill the player there if it has been set and you haven't touched the custom block. Sorry for the long delay there but I only just got around to trying your suggestion. And.... it works perfectly! Fantastic, thanks very much, Jonathan!
|
|