Legacy GM Help Drawing Text Showing Increased Points (Hotline Miami Style)

D

dawson2223

Guest
Hey everyone,

I have a question. In Hotline Miami you know how every time you hit someone there is a flashing animation that shows an increase in points? How do you do that? Is it created as an object and the animation is ran that way, or is there some type of alarm set up?

Hotline Miami is just one example. But I'm trying to figure out how to tell the player they increased their score by doing damage, and I don't know how to make the information go away after a certain amount of time so it doesn't stay on the screen.

Any ideas?

Thanks!!!!
 

Phil Strahl

Member
In my game I have something similar: When the player clicks on a tile, it disappears and a floating score gets displayed in its place that fades away after a while.
In my case, this score is an object, "obj_points" that gets created when the a tile is destroyed, roughly like this:
Code:
// when player clicks the tile
if (tile_click)
{
   var score_display = instance_create(x,y,obj_points);
   score_display.text = string(tile_score); // passes the score amount to the new instance
   score = score + tile_score; // adds the score amount also to the global score
   insance_destroy(); // self destruct tile
}
So the obj_points itself displays what's in its "text" variable, slowly moves upwards and fades out. When its alpha value falls below 0, it self-destructs, so it's "fire and forget":
Code:
// obj_points create event
alpha = 1.0;
alpha_step = 1/ room_speed; // amount of alpha to subtract each step
text = ""; 
y_step = 20 / room_speed; // amount in pixels to move it up each step

// more stuff, e.g. font, color,
Code:
// obj_points step event
if (alpha <= 0)
{
   instance_destroy();
}

alpha = alpha - alpha_step;
y = y - y_step;
Code:
//Draw event
// set font, alignment, color, blend mode, etc.

draw_set_alpha(alpha);
draw_text(x, y, text);
 
D

dawson2223

Guest
In my game I have something similar: When the player clicks on a tile, it disappears and a floating score gets displayed in its place that fades away after a while.
In my case, this score is an object, "obj_points" that gets created when the a tile is destroyed, roughly like this:
Code:
// when player clicks the tile
if (tile_click)
{
   var score_display = instance_create(x,y,obj_points);
   score_display.text = string(tile_score); // passes the score amount to the new instance
   score = score + tile_score; // adds the score amount also to the global score
   insance_destroy(); // self destruct tile
}
So the obj_points itself displays what's in its "text" variable, slowly moves upwards and fades out. When its alpha value falls below 0, it self-destructs, so it's "fire and forget":
Code:
// obj_points create event
alpha = 1.0;
alpha_step = 1/ room_speed; // amount of alpha to subtract each step
text = "";
y_step = 20 / room_speed; // amount in pixels to move it up each step

// more stuff, e.g. font, color,
Code:
// obj_points step event
if (alpha <= 0)
{
   instance_destroy();
}

alpha = alpha - alpha_step;
y = y - y_step;
Code:
//Draw event
// set font, alignment, color, blend mode, etc.

draw_set_alpha(alpha);
draw_text(x, y, text);

this helps a lot! Thank you!
 
D

dawson2223

Guest
In my game I have something similar: When the player clicks on a tile, it disappears and a floating score gets displayed in its place that fades away after a while.
In my case, this score is an object, "obj_points" that gets created when the a tile is destroyed, roughly like this:
Code:
// when player clicks the tile
if (tile_click)
{
   var score_display = instance_create(x,y,obj_points);
   score_display.text = string(tile_score); // passes the score amount to the new instance
   score = score + tile_score; // adds the score amount also to the global score
   insance_destroy(); // self destruct tile
}
So the obj_points itself displays what's in its "text" variable, slowly moves upwards and fades out. When its alpha value falls below 0, it self-destructs, so it's "fire and forget":
Code:
// obj_points create event
alpha = 1.0;
alpha_step = 1/ room_speed; // amount of alpha to subtract each step
text = "";
y_step = 20 / room_speed; // amount in pixels to move it up each step

// more stuff, e.g. font, color,
Code:
// obj_points step event
if (alpha <= 0)
{
   instance_destroy();
}

alpha = alpha - alpha_step;
y = y - y_step;
Code:
//Draw event
// set font, alignment, color, blend mode, etc.

draw_set_alpha(alpha);
draw_text(x, y, text);


Hey! Hope you see this, I'm trying to use the code but all my objects are disappearing instead of just the text! Can you help please?!
 

Phil Strahl

Member
Oh. Add after the last line in the draw event this:

Code:
draw_set_alpha(1);
This is because many of the draw functions apply globally once they have been set. In this case, the GPU will keep drawing all sprites with the last alpha value that got set explicitly.
 
Last edited:
Top