Page 1 of 1
Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 1:13 pm
by Chilly14
Say, have you played any of the more recent Kirby and Mario 3D platformers (such as Super Mario 3D World)? Well, whenever the player dies, almost everything on the screen darkens except the player themselves. So I'd love to find a way to make it so that whenever the player dies in SMBX, almost everything on the screen darkens except the player.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 1:25 pm
by Emral
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority
in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end
The 0.2 is the alpha channel for the color overlay.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:02 pm
by Chilly14
Enjl wrote: ↑Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority
in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end
The 0.2 is the alpha channel for the color overlay.
Tried doing that, but for some reason, it still darkens the death effect. I set the effect's priority to 6.0 and the black screen's to -3.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:18 pm
by Emral
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:36 pm
by Chilly14
Enjl wrote: ↑Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).
Hastebin suddenly stopped working properly so I had to paste it like this.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:37 pm
by Emral
Chilly14 wrote: ↑Sat Oct 19, 2019 2:36 pm
Enjl wrote: ↑Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).
Hastebin suddenly stopped working properly so I had to paste it like this.
Enjl wrote: ↑Sat Oct 19, 2019 2:18 pm
effect.txt doesn't apply to old effects
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:39 pm
by Chilly14
Enjl wrote: ↑Sat Oct 19, 2019 2:37 pm
Chilly14 wrote: ↑Sat Oct 19, 2019 2:36 pm
Enjl wrote: ↑Sat Oct 19, 2019 2:18 pm
...huh? How did you change the effect's priority? effect.txt doesn't apply to old effects. The handbook explciitly states that. I just tested my code and it works (no other code or modifications present).
Hastebin suddenly stopped working properly so I had to paste it like this.
Enjl wrote: ↑Sat Oct 19, 2019 2:18 pm
effect.txt doesn't apply to old effects
Well, that sucks. Can you show me your code?
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:40 pm
by Emral
Chilly14 wrote: ↑Sat Oct 19, 2019 2:39 pm
Well, that sucks. Can you show me your code?
Enjl wrote: ↑Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority
in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end
The 0.2 is the alpha channel for the color overlay.
Like I said, I didn't have anything else going on.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:42 pm
by Chilly14
Enjl wrote: ↑Sat Oct 19, 2019 2:40 pm
Chilly14 wrote: ↑Sat Oct 19, 2019 2:39 pm
Well, that sucks. Can you show me your code?
Enjl wrote: ↑Sat Oct 19, 2019 1:25 pm
Player death effect renders to priority -5, so without redrawing that manually, you will still see other foreground effects and the HUD undarkened.
https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority
in onDraw:
if player.deathTimer > 0 then
Graphics.drawScreen{color = Color.black .. 0.2, priority = -6}
end
The 0.2 is the alpha channel for the color overlay.
Oh.
Wait, how do I redraw the death effect's priority?
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:44 pm
by Emral
Why do you want to do that?
There's many ways to do it. I'd probably make an effect in the custom range (751-1000) and manually spawn it and make the default one invisible.
Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 2:52 pm
by Chilly14
Okay. I'll try that later.
Added in 6 hours 34 minutes 46 seconds:
Enjl wrote: ↑Sat Oct 19, 2019 2:44 pm
Why do you want to do that?
There's many ways to do it. I'd probably make an effect in the custom range (751-1000) and manually spawn it and make the default one invisible.
Okay, I've made an attempt to do it. However, there's still a problem. Whenver I die, it results in error spam.
Current code:
https://hastebin.com/nimacoxuzu.rb
The error:

Re: Screen Darken when Player Dies
Posted: Sat Oct 19, 2019 9:54 pm
by Hoeloe
You never defined what v is in this context. You're looking for "v.x", without telling the program what "v" is.