Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (PeWi, AndrewAMD, TipmyPip, Geir), 15,254 guests, and 21 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Geir, ondrej, mredit, vestriaa, Lukudo
19206 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