Score and lives moving with player
#1
Posted 27 July 2012 - 02:53 PM
I´m quite new in Game Maker. I have created already small platform game, but I have one fatal problem. I have room and I´m using views. So the camera is moving with player and everything work, BUT I really don´t know how to make score counter and lives move too with player. Can someone tell me how to do that? Like in the top on some position will be score and next to it lives but this will move as player move too. Thanks a lot!
#2
Posted 27 July 2012 - 03:09 PM
x = view_xview[0] + view_wiew[0] - <any value> y = view_yview[0] + <any value> draw_text(x,y,score)
Otherwise if you use D&D, try entering the above values as x and y as arguments.
Also,if you have only one active view, you can skip [0] index for simplicity.
Hope that helps..
Edited by Dark Dragon, 27 July 2012 - 03:11 PM.
#3
Posted 27 July 2012 - 03:33 PM
view_xview is the left position of the view currently visible, view_yview is the top position of the view currently visible. So, if you placed this code in the draw_event of an object:
draw_text(view_xview+10,view_yview+10,"Score: "+string(score));
You would draw the text in the top left hand corner of the view (at point 10,10 relative to the view).
view_wview is the width of the current view, view_hview is the height of the current view. Therefore, view_xview+view_wview is the right hand side of the view and view_yview+view_hview is the bottom of the view.
Edit: Spelling.
Edited by TerraFriedSheep, 27 July 2012 - 03:33 PM.
#4
Posted 27 July 2012 - 03:34 PM
Just where to put in this code text? Like if I want to have there "Score:"
EDIT: Thanks, got reply to this at the same time I wrote the question :D
Edited by Ferda12, 27 July 2012 - 03:35 PM.
#5
Posted 27 July 2012 - 03:42 PM
Working, thanks!
Just where to put in this code text? Like if I want to have there "Score:"
EDIT: Thanks, got reply to this at the same time I wrote the question
Glad you got it sorted
You can combine text and variables in the same draw_text function using +, like so:
draw_text(view_xview+10,view_yview+10,"This is some text "+string(variable_name_here)+" a variable, and a bit more text!");
#6
Posted 28 July 2012 - 06:16 AM
1) How to change color of text of "Score: ..."? Or how to use some background for it?
2) How to do the same thing with lives if I want lives as images. I have tried to modify the previous code, but unsuccessfuly, can you help me with this too pls?
Thanks a lot in advance!
#7
Posted 28 July 2012 - 09:42 AM
draw_set_color( c_red ); draw_text( someX, someY, "mytext" ); // *** or *** draw_text_color( someX, someY, "myText", c_red, c_red, c_red, c_red, 1 );to draw lives as an image you would just repeat the drawing of a sprite lives amount of times
for( i = 0; i < lives; i += 1 ) draw_sprite( spr_someSprite, image_index, someX + xBuffer * i, someY + yBuffer * i ); // NOTE: spr_someSprite = name of sprite you wish to show // someX/someY = the actual location you wish to view the sprite // xBuffer/yBuffer = how far apart horizontally or vertically you want the sprites to be view // ( put zero (0) if you don't want any )
Edited by drt_t1gg3r, 28 July 2012 - 09:43 AM.
#8
Posted 29 July 2012 - 09:52 AM
draw_set_color( c_yellow ); draw_set_font(arialblack); draw_text(view_xview+40,view_yview+20,"Lives: "+string(lives));
Is it wrong? I have really in create event in player: set live to 3 and It worked before I tried to make lives as picture. Have someone idea what can be wrong here? (It is showing everytime number 38 after "Lives:" even there is contact with enemy, this number is not getting down, but It worked before..)
EDIT: If I use directly function draw lives, It works, can someone tell me what is wrong in my code above?
Edited by Ferda12, 29 July 2012 - 02:27 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











