Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (alibaba), 3,592 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
create copy of a panel via function? #65429
03/03/06 09:44
03/03/06 09:44
Joined: Feb 2006
Posts: 43
S
shady Offline OP
Newbie
shady  Offline OP
Newbie
S

Joined: Feb 2006
Posts: 43
i want to put random pieces (panels) on my screen.

panel1
{}
panel2
{}
.....

then i have - let's say 10 - numbers, each for a panel.
i.e. 1 2 1 1 1 2 2 2 3 3

then i want that a panel1 is created for each "1" in my numbers, a panel2 is created for each "2" in my numbers and so on....

Last edited by shady; 03/03/06 09:51.
Re: create copy of a panel via function? [Re: shady] #65430
03/03/06 10:10
03/03/06 10:10
Joined: Feb 2006
Posts: 43
S
shady Offline OP
Newbie
shady  Offline OP
Newbie
S

Joined: Feb 2006
Posts: 43
or another approach:

Code:
strCoord[1]="img1.pcx";
strCoord[2]="img2.pcx";
strCoord[3]="img3.pcx";

i = int(random(3))+1;

panel coord00
{
bmap=strCoord[i];
}



i can't create an array of strings, can i? how can i solve it in another way?

Last edited by shady; 03/03/06 10:14.
Re: create copy of a panel via function? [Re: shady] #65431
03/03/06 11:47
03/03/06 11:47
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
you cannot creat an array of strings neither can you put something like
bmap = strCoord[ i ]; into a panel definition.
insead define the panel without a bmap, if this isnt possible either replace it with the first panel of yours.
then write a function which does this random stuff and gives the coord00 panel the right bmap:
Code:

string file_name = "img";
string file_type = ".pcx";
string file;
string file_number;

function set_panels
{
var i;
i = int(random(3))+1;
str_cpy(file,file_name);
str_for_num(file_number,i);
str_cat(file,file_number);
str_cat(file,file_type);

coord00.bmap = file;
}

//another way to have a high number of panels and assign them all a random bmap:

var max_panels = 10;
var panel_handle[10]; //array to store the panel pointers

coord00 { ... }
coord01 { ... }
//and so on

panel* coord_ptr;

string file_name = "img";
string file_type = ".pcx";
string file;
string file_number;

function set_panels
{
panel_handle[0] = handle(coord00);
panel_handle[1] = handle(coord01);
//and so on

var i;
var a = 0;

while(a < max_panels)
{
i = int(random(3))+1;
str_cpy(file,file_name);
str_for_num(file_number,i);
str_cat(file,file_number);
str_cat(file,file_type);

coord_ptr = ptr_for_handle(panel_handle[a];
coord_ptr.bmap = file;
a += 1;
wait(1);
}
}


well i guess this is a pretty komplex way. You should
check out the pan_create instruction. That would be the easy way.

Last edited by Thunder; 03/03/06 11:54.
Re: create copy of a panel via function? [Re: Xarthor] #65432
03/06/06 10:03
03/06/06 10:03
Joined: Feb 2006
Posts: 43
S
shady Offline OP
Newbie
shady  Offline OP
Newbie
S

Joined: Feb 2006
Posts: 43
i read through your post and i don't get it completely.

can you give me one example of i.e. 4 panels that are created randomly with your second attempt (with the handles)? i think that's the one that fits my needs, but i don't get it.
what should be in
Code:
coord00 { ... }

?
and what does "panel*" mean? i didn't find anything about it in the manual.

thanks!

Re: create copy of a panel via function? [Re: shady] #65433
03/06/06 17:24
03/06/06 17:24
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
ok, with coord00 { ... } I meant the panel definition:
Code:

panel coord00
{
bmap = ...
pos_x = ...
pos_y = ...
//and so on
}



panel* is a panel pointer, its used to store the recent pointer.
I need this caus I read the handle (a number) out of an array. So I've to convert this number by using ptr_for_handle(number); into a pointer and this pointer is stored in pointer* coord_ptr. So now coord_ptr refers to the recent panel which i want to edit i.e. give it another bmap or change the x,y pos or whatever is possible.

Re: create copy of a panel via function? [Re: Xarthor] #65434
03/14/06 07:55
03/14/06 07:55
Joined: Feb 2006
Posts: 43
S
shady Offline OP
Newbie
shady  Offline OP
Newbie
S

Joined: Feb 2006
Posts: 43
i can't get it to work

here's my code:

Code:
var max_panels = 12;
var panel_handle[12]; //array to store the panel pointers
panel* coord_ptr;
string file_name = "t";
string file_type = ".pcx";
string file;
string file_number;

function random_panel()
{
panel_handle[0] = handle(transform_l01_normal);
panel_handle[1] = handle(transform_l02_normal);
panel_handle[2] = handle(transform_l03_normal);
panel_handle[3] = handle(transform_l04_normal);
panel_handle[4] = handle(transform_l05_normal);
panel_handle[5] = handle(transform_l06_normal);
panel_handle[6] = handle(transform_l07_normal);
panel_handle[7] = handle(transform_l08_normal);
panel_handle[8] = handle(transform_l09_normal);
panel_handle[9] = handle(transform_l10_normal);
panel_handle[10] = handle(transform_l11_normal);
panel_handle[11] = handle(transform_l12_normal);

var i;
var a = 0;

while(a < max_panels)
{
i = int(random(3))+1;
str_cpy(file,file_name);
str_for_num(file_number,i);
str_cat(file,file_number);
str_cat(file,file_type);

coord_ptr = ptr_for_handle(panel_handle[a]);
coord_ptr.bmap = file;
a += 1;
wait(1);
}
}

in another function i have i.e. this line:

transform_l01_normal.visible=on;



i have some bmps (t1.pcx, t2.pcx, t3.pcx, t4.pcx)

as soon as the panel should get visible, the game crashes.
i can't find the error. please help!


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