Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, vicknick), 692 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Suggestions for improving some lite-c standard functions #286301
08/24/09 14:21
08/24/09 14:21
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
Hi there,

I've been working with panels during the past few weeks a lot. As we all know, a panel is defined like this:

Code:
PANEL* mypan =
{
  pos_x = 160;
  pos_y = 120;
  [...]
}



Okay. In a screen resolution of 320x240px that would be the center of the screen. Now let's say we switch the screen resolution to 1024x768px. The absolute position of the panel on the screen would change and be somewhere on the upper left. So, I tried to improve the code and did something like this:

Code:
PANEL* mypan =
{
  pos_x = screen_size.x / 2;
  pos_y = screen_size.y / 2;
  [...]
}



In theory, this makes sure that the panel is always at the center of the screen. However, it cannot be compiled since lite-c NEEDS a numeric value in the "pos_x" parameter. A var parameter is NOT accepted, which would be very useful. You might say that a var parameter there would cost a lot of CPU power because whenever the var changes, the position of the panel has to change as well - I claim that it would be enough if the panel reads its position out of the variable at the time of its creation and then maintains that position, no matter what the var's content might be later on, until the "pos_x" or "pos_y" parameter is changed manually.


Another example of where a var parameter is impossible: the WINDOW command for panels.

Code:
window(x, y, dx, dy, bmap, varx, vary);



bmap, varx and vary can be given a variable or pointer. dx and dy, however, expect a numeric value. However, it would be so *VERY* useful if dx and dy could be given variables as parameters. Why? Let us assume we have an energy bar. Its bitmap displays a color gradient from red (on the left side) to green (on the right end). Currently, we can only "move" the window within the bitmap. If we do so, the red and green end and all the colors in between would change their position, making the entire color gradient senseless. However, if we were able to manipulate the actual SIZE of the window on the bitmap, the colors always maintain their position (if the player has high HitPoints, the right end of the bar is green, the lower they get the more red the right end of the bar gets as the size of the window is decreasing as well).

Do you know what I mean? Basically what I would suggest is: free the parameters! Expect the user to enter numeric values OR variables for EVERY parameter a function/struct has. I don't know whether this is possible or not, but after all, this is just a suggestion ^^'

Greets,

Alan

Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286316
08/24/09 16:26
08/24/09 16:26
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:
A var parameter is NOT accepted, which would be very useful.


Is already in the forecast.

Edit: It seems like they removed it, but I'm sure that this is a planned feature, event if it's not high priority.

Last edited by Dark_samurai; 08/24/09 16:28.

ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: Suggestions for improving some lite-c standard functions [Re: Dark_samurai] #286318
08/24/09 16:39
08/24/09 16:39
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
For changing a variable in a programming language, such as a panel position, you must use a function. This is common to all languages and explained in the first workshops of the tutorial.

Re: Suggestions for improving some lite-c standard functions [Re: jcl] #286321
08/24/09 16:52
08/24/09 16:52
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
@JCL: Changing the position of a panel *after* it has been created is easy. I would like to define its position using a variable at the time the panel is CREATED. The main purpose is the one I described above - changing screen resolutions can not cause the panels to change their position if the pos_x and pos_y are defined "screen relative".
And what about the window-element and its dx and dy parameters? I can't imagine a function which is capable of changing these two values...

Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286322
08/24/09 17:00
08/24/09 17:00
Joined: Aug 2008
Posts: 133
Sweden, Stockholm
E
Enduriel Offline
Member
Enduriel  Offline
Member
E

Joined: Aug 2008
Posts: 133
Sweden, Stockholm
why don't you write inside your "change resolution" function to use pan_setpos function? that function takes a vector, the Z component can be 0.

and also you can always access the panels pos_x with panel.pos_x = 50; as an example. You could always write that inside your "change resolution" function aswell.

Last edited by Enduriel; 08/24/09 17:03.
Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286325
08/24/09 17:10
08/24/09 17:10
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
You can change all panel elements - look in the manual under "Panel functions". Predefining panel movement already in the definition offers no advantage and makes no sense to me.


Re: Suggestions for improving some lite-c standard functions [Re: jcl] #286335
08/24/09 19:10
08/24/09 19:10
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Hey Alan, you could always do it my way.
NEVER define a panel...

Just create a "panel_action" function that creates the panel with pan_create,
and arranges its position, size and all its buttons etc.
Then this panel_action STAYS RUNNING, watching for a resolution change,
and then re-arranges itself if there was a resolution change.

Works for me...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Suggestions for improving some lite-c standard functions [Re: EvilSOB] #286458
08/25/09 11:50
08/25/09 11:50
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
@EvilSOB: Hm, sounds good... I did it the way Enduriel explained, but your solution for this problem sounds good, too!


@JCL: Defining the pos_x and pos_y coordinates in a panel definition has nothing to do with movement. If the variable given changes after the panel was defined, the panel does not have to change its position as well. The only purpose for a variable to be in a definition is flexibility - the flexibility to define screen-relative (and therefore resolution-independent) panel-positions. Of course this can be done in a function after the definition, but it would be cool if one could define things like

Code:
var my_screen_size_x = 1024;
var my_screen_size_y = 768;

PANEL* my_test_pan =
{
pos_x = my_screen_size_x / 2 + 30;
pos_y = my_screen_size_y / 2 + 50;
[...]
}


void main()
{
screen_size.x = my_screen_size_x;
screen_size.y = my_screen_size_y;

[...]

my_screen_size_x *= 2;        //the panel maintains its absolute position here,
my_screen_size_y *= 2;        //although the resolution is changed!
screen_size.x = my_screen_size_x;
screen_size.y = my_screen_size_y;

}



No matter what I enter for "my_screen_size_x" and "my_screen_size_y", the panel would maintain its relative position on the screen.
Of course, as mentioned, it can be done afterwards by a function. But a definition like the one I did above would make that function unneccessary.

Last edited by Alan; 08/25/09 11:53.
Re: Suggestions for improving some lite-c standard functions [Re: Alan] #286465
08/25/09 12:39
08/25/09 12:39
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Why not use a #define? Since the panels get defined right at the very beginning, the only variables that would be relevant are global variables' default values, so instead of doing that you could just use a #define (since they just get replaced at compile time anyway).

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Suggestions for improving some lite-c standard functions [Re: JibbSmart] #286507
08/25/09 15:29
08/25/09 15:29
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
@JulzMighty: Could you give me an example? What you say sounds like the solution I've been looking for...

Page 1 of 2 1 2

Moderated by  aztec, Spirit 

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