Level up Notification on level end

S

Stratos.la

Guest
Hey everyone! i cant seem to be able to make it! i have a controller that records gold and exp mid level to display on level end how much xp and gold gained but i also want if the player levels up mid game to show it at the end. the way i have it only works if the player levels up exactly at level end.

this is my level end vew object (displaying the stats)
GML:
with (oLevelEndStats)
{
    if lvend > prev_level
    {
        draw_set_font(fntTeutonic)
        draw_set_color(c_black)
        draw_set_halign(fa_center)
        draw_text(x,y-320,"Level up!" + " " + "level:"+ " " + string(global.p_level))
        draw_text(x,y-260,"You Gained" + " " + string(global.skp) + " " + "Skill Points")
        draw_set_halign(-1)
        draw_set_color(-1)
        draw_set_font(-1)
    }
}
and this is the object that holds the variables
Room Start
GML:
prev_level = global.p_level
end step event
GML:
lvend = global.p_level
i also tried this code in the step end and just draw the lvtext in the object that shows the stats but still nothing
GML:
textlv ="Level up!" + " " + "level:"+ " " + string(lvend + prev_level)
 
Last edited by a moderator:

Tornado

Member
It is the question where do you increment global.p_level ?
Also no need to complicate, I think you dont need the variable "lvend", you can use global.p_level directly. No need to maintain one extra variable. Then you don't need step end event. Also normally one needs Step End event very rarely. IF as a beginner you catch yourself using Step End, then something might be wrong with your code design.
 
S

Stratos.la

Guest
the global.p_level is used in a persistent object that handles everything in the game, level exp gold health etc
. but im still wondering how will it know the difference? if i call the global.p_level on the levelend object it has to level up exactly at that point to show it
 

Tornado

Member
Why do you need
with (oLevelEndStats) ?
If drawing is in the Draw Event of the object oLevelEndStats you don't need "with" there.

Where do you increment global.p_level?
 
S

Stratos.la

Guest
i have another object for leveling up a persistent one. its not that i cannot level up or show it. its just that if the player levels up mid level thus the xp going back to 0 i want to show it on the level end. In the way shown above i display gold and exp gained in level and thats why i thought i could do the same with the level.
 
S

Stratos.la

Guest
GML:
if (global.p_exp > global.p_exptolevel)
{
global.p_level +=1;
global.hp = global.hp_max
global.mp = global.mp_max
global.p_exp = 0;
global.p_exptolevel = 70 * global.p_level
global.skp += 2;
global.skp_next = 2 * global.p_level;
}
 

Tornado

Member
If you temporary remove this "if"

if lvend > prev_level
{

do you see then that
"Level up!"
is drawn?

If not, then you are not setting lvend or/and prev_level correctly or you are setting them at the wrong place or to the wrong object instance.
 

TheouAegis

Member
Is all of this code running in the same room as the end of the level? Or are you moving to a different room, showing the gained stats, then moving to the next level's room? Because if you're moving to a different room in between levels, you are setting prev_level in the Room Start event and going to an intermediate room would cause the information to be overwritten.

I don't even understand how the player can level up "exactly at level end" and that would affect everything else. Such a scenario doesn't exist in the codes shown here.
 
S

Stratos.la

Guest
both objects are in the level ( well in every level ) i have a oLevelEndStats object running in the room from room start to end. now when the enemies are 0 i instansiate the olevelEnd object which displays gained gold experience points and a progress bar along with a button to return to level selection room. the code used above is used for displaying gold and experience points and it works. and what i mean by saying that it works when i say exactly at level end is that is the player reaches the second level while the room ends it shows it but if he levels up mid game it wont display it. Say the player needs only 10 exp to go to level 2 and by killing 3 enemies he levels up well if the level wont end there and he still gets xp at the end it doesnt show that he leveld up.
 
S

Stratos.la

Guest
here is a gif. i am incrementing exp manualy right now. As you can see it only shows the notification if the level up happens exactly when the xp reach the xp max and when in actuall game that happens to be the end of the game. ideally it should show the level up notificiation everytime! if of cource the player does level up. meaning that the player could go 2 levels up mid game i want to show that on the level end!

bandicam-2020-09-30-09-42-52-078.gif
 
S

Stratos.la

Guest
well i don't know if that would be ok since my controller gives out exp every 3 seconds while on levels plus the enemy gained from killing enemies. i mean leveling up happens at its own. i just cant think of a way to actually show it! i mean it shoudlnt be this difficult. its like cheking to see it the global.p_level is different than when you started the level and if it is show it!
 
S

Stratos.la

Guest
maybe in my leveling object i can save the level up to a variable and display it? just an idea but still how would i go about doing that?
 

TheouAegis

Member
now when the enemies are 0 i instansiate the olevelEnd object
Right here you stated there is a point in time where you can wait to update lvend. You do not need to update lvend every single step, because it doesn't matter every step, it only matters at this specific point in time, right? For that matter, you don't even need lvend.


with (oLevelEndStats) {
if lvend > prev_level {
You can just make that

Code:
with (oLevelEndStats) {
    if global.p_level != prev_level {
 
Top