Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Too many panels #237846
11/22/08 21:50
11/22/08 21:50
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Is there a way I can cut down on the use of code in creating my
70 panels?

I have to put a code like this 70 tines:

Code:
// Panel #01
BMAP imageButtonFrame = "button_frame.pcx";
PANEL panelButtonFrame = 
{
    scale_x = 0.5;
    scale_y = 0.5;
    layer = 4;
    bmap = imageButtonFrame;
    flags = OVERLAY | VISIBLE;
}


and then I have to put a code for their position in here:

Code:
/*---------------MAIN----------------*/
// The main() function is started at game start
function main()
{
   panelButtonFrame.pos_x = 5; //Position ButtonFrame
   panelButtonFrame.pos_y = (screen_size.y)-115;
   // load the level
	level_load("test.WMB");
	wait(2);
}


Is there a way to compress the code?
Also, if I wanted to use the same panel in many places, is there a way I can do so without creating another panel?
Thanks

Re: Too many panels [Re: JGGamer] #237849
11/22/08 22:05
11/22/08 22:05
Joined: Nov 2008
Posts: 44
United States
Dante_Scott Offline
Newbie
Dante_Scott  Offline
Newbie

Joined: Nov 2008
Posts: 44
United States
I doubt you can compress the code in any way. I would just do the code over and over. I know this doesn't help much but I think that you should just take some time to do that. I have been in this same spot before.

Re: Too many panels [Re: Dante_Scott] #237855
11/22/08 23:49
11/22/08 23:49
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
it's possible to draw buttons and windows all inside one panel, and also possible to change the bmap within a panel,

so it really depends on why you have 70 panels and what they're all doing?

Re: Too many panels [Re: MrGuest] #237865
11/23/08 01:20
11/23/08 01:20
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
Thanks

Quote:
it's possible to draw buttons and windows all inside one panel


Could you show me how to do that? That may be the answer to my second question.
Quote:
Also, if I wanted to use the same panel in many places, is there a way I can do so without creating another panel?


These are just frames that do nothing, so if I could put them all in one panel, that would be fine. Could you help me with that please?

Re: Too many panels [Re: JGGamer] #237925
11/23/08 17:49
11/23/08 17:49
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Look at the manual for "button" and "window"

Re: Too many panels [Re: Widi] #237934
11/23/08 18:28
11/23/08 18:28
Joined: Nov 2008
Posts: 19
Sweden
Alof Offline
Newbie
Alof  Offline
Newbie

Joined: Nov 2008
Posts: 19
Sweden
Another thing you could do is creating a new script named "Panels.c" or something - Then write your panel codes in there, then include the script into your main script.

I know this is not compressing the code in any way - but it sure makes it easier to sort things if you've got a lot of code.

Hope this helps a bit laugh


"If you say 'plz' because it's shorter than 'please', then I'll say 'no' because it's shorter than 'yes'.
Re: Too many panels [Re: Alof] #237940
11/23/08 18:41
11/23/08 18:41
Joined: Nov 2008
Posts: 19
Sweden
Alof Offline
Newbie
Alof  Offline
Newbie

Joined: Nov 2008
Posts: 19
Sweden
Or... you could rearange the panels and create less panels by do some cut n' and such. Create a larger Panel containing several panels? Unless the Panels aren't doing different stuff.
But if you're creating a simple ui then I guess you'll want to use one or two large panels and do the buttons in the same panel. There's no reason to split it if they're all static?


"If you say 'plz' because it's shorter than 'please', then I'll say 'no' because it's shorter than 'yes'.
Re: Too many panels [Re: Alof] #237944
11/23/08 19:04
11/23/08 19:04
Joined: Aug 2003
Posts: 902
Van Buren, Ar
Gordon Offline
User
Gordon  Offline
User

Joined: Aug 2003
Posts: 902
Van Buren, Ar
You can addapt what I did in one of my games.

Code:
Panel Storage:
PANEL* Panels[MAX_X][MAX_Y][5];

Panel Init:
   str_cpy(panel,"");
   str_cat_num(panel,"bmap=BackgroundTile; pos_x = %4.0f;",i*64+X_OFFSET);
   str_cat_num(panel," pos_y = %4.0f; size_x = 64; size_y = 64; flags = OVERLAY;",j*64+Y_OFFSET);
   Panels[i][j][BASE_LAYER] = pan_create(panel,-105);


The init code was run inside two loops to set the posistion of the panels at the correct x,y location. This worked for 360 panels. if you need a different bitmap for each panel then use a text object for storage of the bitmap names.


Our new web site:Westmarch Studios
Re: Too many panels [Re: Gordon] #238011
11/24/08 02:53
11/24/08 02:53
Joined: Nov 2008
Posts: 109
J
JGGamer Offline OP
Member
JGGamer  Offline OP
Member
J

Joined: Nov 2008
Posts: 109
All of these are helpful.
Widi, I will check the manual, thanks.
Alof, I was thinking of doing your first suggestion:
Quote:
Another thing you could do is creating a new script named "Panels.c" or something - Then write your panel codes in there, then include the script into your main script.

But I did not know how to include the script into your main script. Could you give me an example of how to do that, or point me to where I can find the info in the manual? Thanks.
Gordon, you code does a perfect compression. I'll see if I can get this done. Thanks.
Alof, please still send me that info on how to include the script into my main script.
Thanks very much for all your help.

Re: Too many panels [Re: JGGamer] #238017
11/24/08 04:46
11/24/08 04:46
Joined: Nov 2008
Posts: 7
C
Chris_Newman Offline
Newbie
Chris_Newman  Offline
Newbie
C

Joined: Nov 2008
Posts: 7
#include <panels.h>

put that at the top of your main file
put panels.c in the same dir.

Page 1 of 2 1 2

Gamestudio download | 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