Login | Register

Speedmeter

July 24, 2006, 13:12 by Calle
[loading]
-->
r = 100;
dir = 90;
draw_circle(x,y,r,true);
draw_line(x,y,x+lengthdir_x(r,270+dir),y+lengthdir_y(r,270+dir));

draw_text(x+lengthdir_x(r+15,270),y+lengthdir_y(r+15,270),"0";);
draw_text(x+lengthdir_x(r+15,90),y+lengthdir_y(r+15,90),"2";);
draw_text(x+lengthdir_x(r+15,180),y+lengthdir_y(r+15,180),"1";);
draw_text(x+lengthdir_x(r+15,0),y+lengthdir_y(r+15,0),"3";);


The above is the basic code, basic both visually and technically. But actually it’s already very functioning. The only thing left is to set the dir variable in relation to the speed. As you can see I only wrote 0, 1, 2 and three, but these are to be replaced with other numbers.

Let’s say you replace 3 with 250, because 250 is the max speed, then the direction would be calculated like this:

dir = (speed/max_speed)*270

If you want to use the whole circle then you may replace 270 with 360.

Example:
http://gmtutorials.com/files/speedmeter.gm6

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games