This is how you put a Game Over message with LunaDLL
Posted: Fri Sep 04, 2015 2:23 pm
I have finally discovered how you make the game write "GAME OVER" on the center of the screen when you lose your last life!
Now, this code has THREE weaknesses that I know of:
First and most important issue with this code is it will lag the game for the short time the player's last death animation lasts. This is because the code is ALWAYS checking the variables, and when both variables are 0 it prints the text EVERY SINGLE FRAME over and over, thus why the ShowText only lasts 1 frame, as it lags much worse if it lasts any longer.
Secondly, I was unable to get a lunaglobal.txt file to work, so you will have to do the tedious task of writing this code in the lunadll.txt of EVERY level! Thankfully for me, my projects are much shorter than those of the average SMBX community member.
Lastly, as mentioned in the comments of the code itself, it works with hearts, so I doubt it will work with Mario and Luigi, who are the most used characters. My project uses Toad, so at least I can guarantee it works with him.
That's all. Use this code and enjoy your lagging Game Over screens. And if any of you finds a way to improve on this code (i.e: getting it to NOT lag), be sure to post it so we all know!
Code: Select all
#0 //Section number where it applies. 0 means always
OnGlobalMem,0x00B2C5AC,0,0,1001,0,f //Checks if the player's number of lives equals 0 and calls event 1001
#1001
OnPlayerMem,0x16,0,0,1002,0,w //Checks if the player's number of hearts equals 0 as well (not tested with Mario or Luigi) and calls event 1002
#1002
ShowText,0,300,260,3,1,GAME OVER //Shows the text for 1 frame, you'll see why
First and most important issue with this code is it will lag the game for the short time the player's last death animation lasts. This is because the code is ALWAYS checking the variables, and when both variables are 0 it prints the text EVERY SINGLE FRAME over and over, thus why the ShowText only lasts 1 frame, as it lags much worse if it lasts any longer.
Secondly, I was unable to get a lunaglobal.txt file to work, so you will have to do the tedious task of writing this code in the lunadll.txt of EVERY level! Thankfully for me, my projects are much shorter than those of the average SMBX community member.
Lastly, as mentioned in the comments of the code itself, it works with hearts, so I doubt it will work with Mario and Luigi, who are the most used characters. My project uses Toad, so at least I can guarantee it works with him.
That's all. Use this code and enjoy your lagging Game Over screens. And if any of you finds a way to improve on this code (i.e: getting it to NOT lag), be sure to post it so we all know!