SOLVED Draw Instance Score - prints double (overlapping) text

S

sivispacem

Guest
---If you duplicated your room, ensure you do not have more than one persistent object placed in more than one room.---
Thank you to @TheouAegis, @Slow Fingers for the assistance.

As the title suggests, I have been following the "Space Rocks" tutorial and all parts of the game work as the tutorial intends.
www DOT youtube DOT com/watch?v=sO06cD0YuPU

However, as you can see from the screenshot, the score at the end prints two values: the starting value and then the modified value ("0" and "10", respectively).

1609356945361.png
Currently, I am using the DnD interface for this project.
The DnD should be just as the tutorial suggests for the logic itself (below).
You see "Draw Value" in there because I tested assigning a different variable in all instances to track score and attempted printing that (instead of Draw Instance Score) and it created the same result - printing twice.
1609357008149.png
 
Last edited by a moderator:
S

sivispacem

Guest
Do you have any other code that's drawing to the screen? Does the room have a defined background colour?
Only what you see in the screenshot above. No, no BG color. Also, this is the only instance in the game where the score is drawn like this.
In another area (main game room) the score is drawn along with lives and keeps pace with the camera. However, that score does not have this problem.
 
No, no BG color. Also, this is the only instance in the game where the score is drawn like this.
Give your room a solid BG. I have the feeling it's maybe just an artifact from having no bg. Like if you had drawn the 0, and then aligned it afterward. Everything you draw on a 'transparent' BG will leave it,s print on the screen. Try it in a pet project, remove BG color, make something draw at the end of your cursor, and move the mouse around, you'll understand exactly what I mean.
 
S

sivispacem

Guest
Unfortunately, I added a BG color (black) and it is still printing the same overlapping scores.
To further refine the issue, just in case I wasn't clear, if I were to declare a new variable "plr_scr" and have it modified as the built-in score it produces the same result (which is why I have a Draw Value and a Draw Instance Score).
I have since deleted the new variable and you will note that I am not referencing a variable in the Draw Value - it is just printing text.
Score should read "15" and you can clearly see there is a "0" under there.
Also, if I were to add text to the Draw Instance Score - "Score: " it would print the text twice, too.

1609421683691.png

Thank you in advance
 

TheouAegis

Member
Change Draw Value action to Draw Text action. Draw Value requires a value, which you didn't give, so it's drawing a 0.
 
S

sivispacem

Guest
I removed Draw Value completely and have just Draw Instance Score and it produces the result I had mentioned earlier:
1609422084321.png
 

TheouAegis

Member
I removed Draw Value completely and have just Draw Instance Score and it produces the result I had mentioned earlier:
View attachment 36704
Are you using a Camera or View?


Hold up. Run your game through the Debugger. When you get to the glitchy game over screen, pause the Debugger, then check the instance counts. Make sure the Debugger says there is only 1 instance of whatever object this code is in. Also make sure that object doesn't have any Children listed.

With this action you can draw the score value of the instance. When you use any score action in GameMaker Studio 2 the instance that calls it will have a new instance scope variable called score added.
 
Last edited:
S

sivispacem

Guest
This is in the obj_game (persistent) - Draw Gui
Yes, there is a camera in use and there is also a camera object, however, this persisted before the camera object was created.
Since your next question might be the following, below is a screenshot of the camera/viewport:
1609424232492.png
 

TheouAegis

Member
This is in the obj_game (persistent) - Draw Gui
Yes, there is a camera in use and there is also a camera object, however, this persisted before the camera object was created.
Since your next question might be the following, below is a screenshot of the camera/viewport:
View attachment 36705
Ok the view checks out. I edited my last post while you were doing this. Follow up on the second part.

You can ignore my previous issue with Draw Value, since it's clearly not at fault here.
 
S

sivispacem

Guest
Are you using a Camera or View?


Hold up. Run your game through the Debugger. When you get to the glitchy game over screen, pause the Debugger, then check the instance counts. Make sure the Debugger says there is only 1 instance of whatever object this code is in. Also make sure that object doesn't have any Children listed.
I ran the debugger and it appears that it switches from rm_main_1 to rm_end twice, just frames after each other.
However, why? The code to switch is straightforward:
1609427683599.png
Just to be safe, I change "Less or Equal" to just "Equal" and that is not the cause - same issue.

The tutorial had us respawn using an alarm. Thus, I thought that, perhaps, the loss of the last life was causing the transition to the rm_end and then 60 frames later it would respawn current room. However, I disabled the alarm call and it still occurred.
1609428122278.png(not disabled in thisscreenshot)
 
S

sivispacem

Guest
To further assist, these are the only times rm_end is used:

obj_game-Key Press - Space at line 28: case rm_end:
#to restart game
obj_game-Room Start at line 49: if(room == rm_end)
#to play music (if)
obj_game-Step at line 22: room_goto(rm_end);
#if lives (above)
obj_game-Draw GUI at line 107: case rm_end:
#this thread's topic
Search Complete (4 results)

And some debugging:
1609441384058.png
I don't know from where the first obj_game score is coming. My guess is that is why it is printing twice.
So now I guess I have two problems, the score and the double rm_end call. :(
 
Last edited by a moderator:
S

sivispacem

Guest
Well, I fixed the double room call - but that did not solve the double score print:
1609442688177.png
 

TheouAegis

Member
Yeah, you have TWO instances of obj_game active. One has lives set to 3, but score is 0. That tells me you have an obj_game placed in every room and obj_game is set as persistent, or maybe you called one of the Restart actions and it just compounded obj_game on top of itself. First make sure you have only ONE instance of obj_game in your whole project.
 
S

sivispacem

Guest
I duplicated the start room for the end room and yes, there were two instances of obj_game.
Thank you for your assistance!
 
Top