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
2 registered members (TipmyPip, 1 invisible), 18,789 guests, and 8 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
multiple panels #300655
12/03/09 23:12
12/03/09 23:12
Joined: Mar 2004
Posts: 71
Scotland
westray Offline OP
Junior Member
westray  Offline OP
Junior Member

Joined: Mar 2004
Posts: 71
Scotland
Using a for loop,how could I create different panels at regular locations on the screen.I am trying to create a 2d game and the panels are different "sprites".

Re: multiple panels [Re: westray] #300658
12/04/09 00:11
12/04/09 00:11
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Something like this:

Code:
randomize();

PANEL *panels[10];

var i;
for( i=0; i<10; i++ ) {
  
  PANEL *newPanel = pan_create("bmap=mysprite.tga; flags=VISIBLE;", i); //set on layer i
  newPanel->pos_x = random(screen_size.x-newPanel->size_x);
  newPanel->pos_y = random(screen_size.y-newPanel->size_y);
  

  //Now store the panel in our array,
  //so as not to lose track of the pointer (and create a memory leak).
  panels[i] = newPanel;
}




Click and join the 3dgs irc community!
Room: #3dgs
Re: multiple panels [Re: Joozey] #300711
12/04/09 16:33
12/04/09 16:33
Joined: Mar 2004
Posts: 71
Scotland
westray Offline OP
Junior Member
westray  Offline OP
Junior Member

Joined: Mar 2004
Posts: 71
Scotland
I've tried this and it doesn't appear to work.I have done this without the for loop and it works fine at placing a panel at a random position on screen.As soon as I use the for loop it won't compile.Could you give a more detailed explanation?

Last edited by westray; 12/04/09 16:50.
Re: multiple panels [Re: westray] #300721
12/04/09 18:09
12/04/09 18:09
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
You probably forgot to add "var i;" above the loop. Else the compiler doesn't know what i is. Changed it in the sample above.

Last edited by Joozey; 12/04/09 18:09.

Click and join the 3dgs irc community!
Room: #3dgs

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

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