• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM QUESTION I CAN'T EXPLAIN PRECISELY PART 2

Status
Not open for further replies.
H

Heat4Life

Guest
SO IF I DO THIS:
Code:
var randomangle = random(360);
var o;

o = instance_create(x, y, obj_deadplayer);
o.angle = 0 + randomangle;
o = instance_create(x, y, obj_deadplayer);
o.angle = 120 + randomangle;
o = instance_create(x, y, obj_deadplayer);
o.angle = 240 + randomangle;

with (obj_deadplayer) {
direction = angle;
image_angle = angle;
speed = 3;
}
AND I WANT TO DRAW A TEXT TO THE SCREEN SO I CAN KNOW WHAT IS THE VALUE OF ANGLE NOW:
Code:
var randomangle = random(360);
var o;

o = instance_create(x, y, obj_deadplayer);
o.angle = 0 + randomangle;
o = instance_create(x, y, obj_deadplayer);
o.angle = 120 + randomangle;
o = instance_create(x, y, obj_deadplayer);
o.angle = 240 + randomangle;

with (obj_deadplayer) {
direction = angle;
image_angle = angle;
speed = 3;
draw_set_color(c_red);
draw_text(32, 32, angle) // or maybe o.angle?!
}
Will that work? Lol I'm dying...
 

FrostyCat

Redemption Seeker
Of course it won't work, it's not a Draw-type event.

If you want to know what the value of angle is at that point, you have numerous options that don't involve drawing functions:
  • show_message() for a popup that pauses the runner
  • show_debug_message() for output to the compile console and the debugger
  • Running the game in debug mode with the locals panel open and placing a breakpoint after var randomangle = random(360);
 

TheouAegis

Member
Just make a Draw Event for obj_deadplayer and put in it:

Code:
draw_self();
draw_set_color(c_red)
draw_text(x-32, y-32, angle);
draw_set_color(c_black);
Just make sure if you do it that way that you create obj_deadplayer via Shaun's code so that angle is created before the Draw event can run.
 
H

Heat4Life

Guest
Just make a Draw Event for obj_deadplayer and put in it:

Code:
draw_self();
draw_set_color(c_red)
draw_text(x-32, y-32, angle);
draw_set_color(c_black);
Just make sure if you do it that way that you create obj_deadplayer via Shaun's code so that angle is created before the Draw event can run.
Will this work now? Lol
 

TheouAegis

Member
So the draw color isn't red all the time.

Say you had two objects - one that draws a message on the screen like, "Game Over", and your obj_deadplayers. If you want Game Over to draw the text in black, you'd either have to set the draw_set_color(c_black) before drawing the Game Over text or set it back after you draw the red text.

You don't have to set it back to black, but it's just common practice from the olden days. It stems from the use of draw_set_halign and draw_set_valign when typically only one thing would be drawn centered and everything else would be drawn left-aligned, so it made more sense to just reset the alignment immediately after centering it for the centered text.
 
H

Heat4Life

Guest
So if we did draw_self() it will draw the sprite of the current Object? will the actions, events still work when we draw the sprite of that object?
 
Status
Not open for further replies.
Top