The Daily Click ::. Forums ::. Klik Coding Help ::. Active Picture Object Limitations?
 

Post Reply  Post Oekaki 
 

Posted By Message

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
31st January, 2012 at 04:09:35 -

Start of Frame:

Activate Group "Level_Generator".

Group >Level Generator<
On Loop "PopulateX":
Active Picture -> Create Backdrop Object (X (PainterX))+(Y (PainterY)) 32,0,32,32)

{Translation: Create backdrop object at X+Y of the active Painter object. Use the Active Picture object as a source starting at X=32 Y=0 [grass tile, but will eventually read tile data from an array] and make the selection 32x32 pixels)
On Loop "PopulateX":

Set Xpos of Painter to Xpos of Painter + 32

(Translation: Every time the loop starts, move the painter active to 32 pixels to the right of it's current position)

That takes care of populating one line.
Now, let's fill the rest of the frame.
Ypos of Painter < Frame Height:

Start Loop "PopulateX"
Set Painter Xpos to 0
Set Painter Ypos to PainterX + 32

(Translation: If the active Painter object hasn't left the bottom of the screen, run the PopulateX loop until it stops, then drop down to the next line and retest Painter's Ypos)

That would be good enough, but once the active painter object reaches the very bottom of the frame, there's no sense in letting it continue.
Ypos of Painter > Frame Height:

Destroy Painter.
Deactivate Group "Level Generator"


I have a 960x704 level size and a 480x352 window size. The scripting works for about 3/4th's the way through the level then just stops. Anybody know why?

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Zephni

My other cars a Balrog

Registered
  17/10/2007
Points
  4019

Has Donated, Thank You!VIP MemberSonic Speed
31st January, 2012 at 08:04:00 -

Rather than adding 32 pixels each time, I tend to divide the screen width by 16 (In your case 32), and same with height. And then run the loop that many times. But when pasting the backdrop object from the active picture object set it to the loop index * 16.

Then you would do somthing like:

On loop X, start loop Y. On loop Y set X position to 16 * Loop and Y position to 16 * Loop
Its just a couple of conditions and events compared to the way you are doing it.

I have made massive levels with 4 layers full of tiles that have been created from the active picture object and never had a problem with limitations.

If you wanna do it the way you already are just try changeing some values or increaseing the limits to see if you can figure out why its stopping early

Edited by Zephni

 
dont make me divide by zero...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
31st January, 2012 at 13:46:20 -

I'd always run a fastloop a fixed number of times, according to the size of the array you loaded.
I'd also use Actives instead of Active Pictures (use the "Load Frame" to import image files).

eg.

+ Start of frame
-> Array: Load file
-> Start fastloop "Load", DimX("Array") * DimY("Array") times

+ On Loop "Load"
-> Set GridX to LoopIndex("Load") mod DimX("Array")
-> Set GridY to LoopIndex("Load") / DimX("Array")

+ On Loop "Load"
+ ValueAtXY( "Array", GridX, GridY) = Something...
-> Active: Set animation / direction / frame to Something...
-> Active: Set X position to GridX * 32
-> Active: Set Y position to GridY * 32
-> Active: Add to backdrop


Very simple and reliable

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
31st January, 2012 at 15:07:02 -

Which way is best then sketchy? I use nested loops for tasks like these. i.e.:

Start Loop "PlaceY" - DimY("Array")
On Loop "PlaceY" - Start Loop "PlaceX" - DimX("Array")
On Loop "PlaceX" - Place object code.

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
31st January, 2012 at 15:19:23 -

I don't think either is "better" - they're just two slightly different ways of doing the same thing - both work perfectly fine.

Anyway, now that I look at it, The_Antisony's problem is probably caused by hitting the object limit - the limit by default is 500, whereas a map the size of his would require 660 tiles (plus all the other miscellaneous objects in his game).
I don't know why, but I thought the default was much higher, which is why I thought it must be something else causing problems. Shows what I know...

 
n/a

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
1st February, 2012 at 08:14:31 -

Whelps, I decided to scrap it and switch to using the Surface object.
I did hit the level object limit. Instead of increasing it, I'll just translate my array values to tile data and blit those to the surface object, then blit the surface to a backdrop object and destroy the Surface object.
Yes?

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
1st February, 2012 at 16:33:58 -

Sounds good to me

 
n/a
   

Post Reply



 



Advertisement

Worth A Click