3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Creating A Grid
[Re: DJBMASTER]
#316171
03/22/10 03:13
03/22/10 03:13
|
Joined: Dec 2009
Posts: 6
nikka08
OP
Newbie
|
OP
Newbie
Joined: Dec 2009
Posts: 6
|
1) When creating panels in a function, you have to use the function 'pan_create'. Panel* definitions can only be declared globally. Ok, so I'm using the pan_create function instead of PANEL*. 2) Like point 1, you have to use 'pan_create' function when building a panel at runtime. Also you can only pass constants to certain members of a panel definition. So are you saying that I can't use an array to define the position of the panel? Thank you very much for your quick response.
|
|
|
Re: Creating A Grid
[Re: DJBMASTER]
#316347
03/23/10 14:56
03/23/10 14:56
|
Joined: Dec 2009
Posts: 6
nikka08
OP
Newbie
|
OP
Newbie
Joined: Dec 2009
Posts: 6
|
Sure you can use an array to define the position. You have 2 choices...
1) If you know the positions already use a global array. 2) If you want to calculate positions and store them in an array, you will need to know how to use 'dynamic memory', with the functions 'malloc/calloc/free'. I am using a global array that I defined all of the positions for. My problem is the actual syntax of the code. Instead of pos_x = 256;, I used pos_x = Gridx[8];. And it errors. So I guess I'm just asking how you would actually code it. Again, thank you for your responses.
|
|
|
Re: Creating A Grid
[Re: nikka08]
#316354
03/23/10 15:31
03/23/10 15:31
|
Joined: Nov 2009
Posts: 89 Germany, NRW
TrackingKeks
Junior Member
|
Junior Member
Joined: Nov 2009
Posts: 89
Germany, NRW
|
You have to set the position in a loop,not in the panel definition to define the position. I think you have to use pan_setpos.
Last edited by TrackingKeks; 03/23/10 15:33.
Gamestudio: A7.82 Commercial/A8 Commercial System specs (Laptop): Windows 7 64bit DirectX v10.1 Intel Core i7-720QM CPU @ 1,60 GHz 4GB DDR2 Ram NVIDIA GeForce GT 230M (1024MB)
|
|
|
Re: Creating A Grid
[Re: TrackingKeks]
#316376
03/23/10 16:59
03/23/10 16:59
|
Joined: Nov 2007
Posts: 1,143 United Kingdom
DJBMASTER
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,143
United Kingdom
|
Yes, you can't specify variables in the panel definition. They can only be changed within a function. There's no need for 'pan_setpos' because you can directly modify the positon with 'PANEL*.pos_x/pos_y'...
var gridx[5] = {0,32,64,96,128};
var gridy[5] = {0,32,64,96,128}; // bla bla
BMAP* panel_bmap = "image.bmp";
void CreateGrid()
{
PANEL* p = pan_create("",1);
p.bmap = panel_bmap;
p.pos_x = gridx[0]; p.pos_y = gridy[0];
set(p,SHOW);
}
Of course, this is tedious, so let the computer do the work...
BMAP* bmp = "image.bmp";
void CreateGrid()
{
var i,j,size = 33; // tested with a 32x32 picture.
for(i=0; i<screen_size.x; i+=size)
{
for(j=0; j<screen_size.y; j+=size)
{
PANEL* p = pan_create("",1);
p.bmap = bmp;
p.pos_x = i; p.pos_y = j;
set(p,SHOW);
}
}
}
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|