How is to create indicator changing according to user value?

Posted By: gamers

How is to create indicator changing according to user value? - 02/19/20 14:03

Hello,
How can I make the indicator (needle) that has a value of 50 at the beginning, and ranges between 0 and 100 according to user ratings in the video?

The video example link is here: https://we.tl/t-z3DX5YiCTB

Thank you,
Posted By: 3run

Re: How is to create indicator changing according to user value? - 02/19/20 14:54

You can use needle for that.

Here is an example:
[Linked Image]

Code:
Code
#include <acknex.h>
#include <default.c>

#define PRAGMA_POINTER

FONT *main_text_font = "Courier#64";

var credibility = 50;

BMAP *needle_png = "needle.png";
BMAP *range_png = "range.png";

PANEL *needle_pan = 
{
	scale_x = 4;
	scale_y = 4;
	digits(0, -48, "CREDIBILITY", main_text_font, 0, 0);
	needle(0, 0, needle_png, 30, 1, 0, 200, 0, credibility);
	flags = SHOW | CENTER_X | CENTER_Y;
}

PANEL *range_pan = 
{
	scale_x = 6;
	scale_y = 6;
	bmap = range_png;
	flags = SHOW;
}

void main()
{
	warn_level = 6;
	fps_max = 60;
	
	pan_setcolor(needle_pan, 1, 1, COLOR_GREY);
	
	while(!key_esc)
	{
		needle_pan->pos_x = screen_size.x / 2;
		needle_pan->pos_y = (screen_size.y / 2) + 96;
		
		range_pan->pos_x = needle_pan->pos_x - ((bmap_width(range_pan->bmap) * range_pan->scale_x)  / 2);
		range_pan->pos_y = needle_pan->pos_y - ((bmap_width(range_pan->bmap) * range_pan->scale_y)  / 2);
		
		DEBUG_VAR(credibility, 0);
		credibility -= 5 * (key_a - key_d) * time_step;
		credibility = clamp(credibility, 0, 100);
		wait(1);
	}
}


Images used:
[Linked Image]

[Linked Image]

Best regards!
Posted By: gamers

Re: How is to create indicator changing according to user value? - 02/19/20 15:25

Fantastic! Thank you so much 3run.
© 2024 lite-C Forums