Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,170 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 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 | chip programmers | 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