Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Edgar_Herrera, VoroneTZ, Akow), 973 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
window panel element not working #470359
01/09/18 20:52
01/09/18 20:52
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline OP
User
badapple  Offline OP
User

Joined: Apr 2006
Posts: 624
DEEP 13
hello i am trying to create a bargraph to display a var with the window panel element and it shows it on screen but the window bar starts at dx value and does not change according to the var assigned to it . any ideas why? i am using a8 free lite c the bmap image is 32 by 32 pcx





here is the code



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



var players_health =100;



PANEL* bars_pan =
{

pos_x = 0;
pos_y = 8;
layer = 1;
window(2,2,200,10,"bargreen.pcx",players_health,0);
flags = SHOW;
}






function main()
{
video_screen = 1;
video_mode = 8;
level_load ("");


while (1)
{

if (key_1) players_health += 2 * time_step;

if (key_2) players_health -= 2 * time_step;

wait(1);
}
}

Re: window panel element not working [Re: badapple] #470360
01/09/18 21:12
01/09/18 21:12
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hey man!

I'm happy to see you back on forum! laugh

I never worked with 'window' and also couldn't get it working (for the first try). For bar graphs I used to scale simple panels.

Here an example (also used 32x32):
Code:
#include <acknex.h>
#include <default.c>

var players_health = 100;

BMAP* bar_pcx = "bar.pcx";

PANEL *bars_pan = { 

	pos_x = 8;
	pos_y = 32;
	layer = 1;
	bmap = bar_pcx;
	flags = SHOW;
	
}

function main(){
	
	fps_max = 60;
	
	video_screen = 2;
	video_mode = 8;
	
	level_load("");
	wait(3);

	while(!key_esc){ 
		
		players_health -= 5 * (key_1 - key_2) * time_step;
		players_health = clamp(players_health, 0, 100);
		DEBUG_VAR(players_health, 10);
		
		
		bars_pan->scale_x = maxv(0.05, (players_health / 25));
		bars_pan->scale_y = 0.5;
		
		wait(1);
		
	}
	
}



Also, will you run your webpage again? I remember it had a lot of useful stuff in it! F.e. mortair example grin

My best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: window panel element not working [Re: 3run] #470361
01/09/18 21:32
01/09/18 21:32
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline OP
User
badapple  Offline OP
User

Joined: Apr 2006
Posts: 624
DEEP 13
ty 3run i like your example works great ! two thumbs up there. but i would still like to know why window isnt working (i hate it when things dont work right ) pet peev , appreciate the fast response and help thx again man laugh . and i lost all that content on the website will try to get another going , and ya mortar was cool lol.

Re: window panel element not working [Re: 3run] #470362
01/09/18 21:55
01/09/18 21:55
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline OP
User
badapple  Offline OP
User

Joined: Apr 2006
Posts: 624
DEEP 13
if i want to increase the players max health the bar increases also i want the bar to stay at the same total length no matter what i increase the health to and still represent the var like it does now (moving up and down as it changes) any ideas? (got it resolved)well this question resoveled . window still not working

Last edited by badapple; 01/10/18 02:44.
Re: window panel element not working [Re: badapple] #470367
01/10/18 10:51
01/10/18 10:51
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
a window is a panel element that shows a part of a bitmap. The variables set the offset of the upper-left corner of the window from the upper-left corner of the bitmap in pixels.

Look at templates bluebar.pcx file. The upper half part of the bitmap is black (translucent in the engine) and the lower half part is the bar itself. This way, the upper half part is shown when the bar is empty, so the offset is 0. And the lower half part is shown when the bar is full, so the offset is the half of the bitmap height.

With this bitmap<->window realationship in mind, you only need to factorize the health by a healthMax (or so) variable and multiply it by the half of the bitmap height.

Code:
#include <acknex.h>
#define PRAGMA_PATH "%EXE_DIR%templatesimages"

FONT *fntCourier20b = "Courier New#20b";
BMAP *bmpBar = "bluebar.pcx";
var nHealthBar = 0;
var nHealthMax = 100;
var nHealth = 100;

PANEL *panHealth = {
	pos_x = 100;
	pos_y = 100;
	window ( 0, 0, 5, 80, bmpBar, 0, nHealthBar );
	digits ( 20, 40, "Health     [Q+][A-]: %3.1f", fntCourier20b, 1, nHealth );
	digits ( 20, 60, "Health Max [W+][S-]: %3.1f", fntCourier20b, 1, nHealthMax );
	flags = SHOW;
}

function healthBarUpdate () {
	nHealthBar = ( nHealth / nHealthMax ) * ( bmap_height(bmpBar) / 2 );
}

function healthUp () {
	while ( key_q ) {
		nHealth = minv ( nHealth + 5 * time_step, nHealthMax );
		healthBarUpdate ();
		wait(1);
	}
}

function healthDown () {
	while ( key_a ) {
		nHealth = maxv ( nHealth - 5 * time_step, 0 );
		healthBarUpdate ();
		wait(1);
	}
}

function healthMaxUp () {
	while ( key_w ) {
		nHealthMax += 5 * time_step;
		healthBarUpdate ();
		wait(1);
	}
}

function healthMaxDown () {
	while ( key_s ) {
		nHealthMax = maxv ( nHealthMax - 5 * time_step, 1 );
		nHealth = minv ( nHealth, nHealthMax ); 
		healthBarUpdate ();
		wait(1);
	}
}

function main () {
	fps_max = 60;
	healthBarUpdate ();
	on_q = healthUp;
	on_a = healthDown;
	on_w = healthMaxUp;
	on_s = healthMaxDown;
	while ( !key_esc )		
		wait(1);
	sys_exit ( NULL );
}



Salud!

PD: You might redo the engine tutorial about windows. I guess it is clearifier enough.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1