The Daily Click ::. Forums ::. Klik Coding Help ::. Array loading question...
 

Post Reply  Post Oekaki 
 

Posted By Message

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
12th March, 2007 at 05:45:22 -

I'm making a level editor type dealy using arrays and externally load tilesets.

I can get the objects to blit nicely with the active picture, the problem is I don't know how to create my objects by reading the array.. I tried a fastloop but I couldn't get my array to create anything but the first tile no matter what i set its values to. I really don't know where to go from here... I have pretty simple code (so far):

+ Start of Frame
- Load array file ".\level.dat"
- Start loop "createx" 10 times

+ Upon pressing "Space"
- Save the array

+ On loop "createx"
- Create backdrop at (index x array)*16, (index y array)*16, rectangle position x = value current position in array*16, rectangle y position = value current position in array*16, width 16, height 16, obstacle
- Move 1 position Right in array

I don't know what to do and my code is probably ridiculous, but if anyone could help out I'd GREATLY appreciate it.

The loading of the array works fine, it's either the creation or my handling of the array that's wrong...


 
Image
http://bfollington.tumblr.com

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
12th March, 2007 at 06:44:32 -

Good story!

Edit: I don't understand your problem.

Image Edited by the Author.

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
12th March, 2007 at 06:54:12 -

EDIT:

My problem NOW is getting it to create objects vertically, it works fine horizontally, also this is my code...

Image

So yeah, I don't know how to implement the vertical loading.

Image Edited by the Author.

 
Image
http://bfollington.tumblr.com

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
12th March, 2007 at 07:22:56 -

I knew there was a reason I had kept my signature for so long. When you load the objects set their positions to this:

x dimension = [index] mod [size of x]
y dimension = ([index] / [size of x])

Basically, you run the loop [Xsize * Ysize times] and then set xpos of the object to:

(loopindex.createx mod [size of x]) * 16

and y to

(loopindex.createx / [size of x]) * 16

PS. The other mod parts eg. "mod [size of y]" are used for if you have a Z index. That's why my code is slightly different from my sig. Enjoy.


Image Edited by an Administrator.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
12th March, 2007 at 07:34:53 -

That creates them perfectly now, but I still don't know how to make the loop move vertically through the array...

I'm not too familiar with arrays etc. So if you could tell me how to load in both dimensions that would be GREAT

 
Image
http://bfollington.tumblr.com

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
12th March, 2007 at 13:30:40 -

I'm not sure if I understand what you want to do, but isn't it just to add an event which includes "Add 1 to Y dimension"?

...

E_e

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
12th March, 2007 at 17:21:10 -

Yes but which event...? Because otherwise it moves diagonally. I tried saying: X index >= 40 then add 1 to y dimension & set x index to 1. But it didn't work...

 
Image
http://bfollington.tumblr.com

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
12th March, 2007 at 18:15:35 -

I use arrays in a stupid way, not sure if it'll solve your problem.
After each loop I just "Add 1 to Y dimension" which sets it to the next row - so making it go through the array vertically. Then I check that row for an object, create the object, then Y dimension will go up by one again and the loop continues until there are no more rows.

Haven't a clue if that's what you're on about LOL

 
This is a signature. Have this one on me.

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
12th March, 2007 at 18:27:54 -

You could try something like this:
First add a counter.
Second, add a restriction to the events in which the tiles are created;
"Counter < X.dimension of Array"
also
"add 1 to counter" in the same loopstep.

Now make a copy of the whole event and change
"Counter < X.dimension of Array"
to
"Counter = X.dimension of Array"
and instead of
"add 1 to counter"
use
"set counter to 0"
and
"add 1 to Ydimension of Array"

That should loop it correctly. The only downside to it is that you need to copy each of the creation events, and I noticed you have quite a few. But the upside is that it'll work. You might have to tweak the "Counter = X.dimension of Array" to either "Counter = X.dimension of Array+1" or "Counter = X.dimension of Array-1".
Hope that helps!

Damn smiley!

E_e

Image Edited by E_e.

Image Edited by the Author.

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
13th March, 2007 at 01:50:38 -

Okay so reading over the way you are doing it again, it's not particularly efficient. I mean it will work, but it's not the conventional way to do it.

The way I do the loading is how I told you before. Saving the data couldn't be simpler. Make a 'cursor object' (a blank active object) then you just save the data to its (X position / 16) and to its (Y position / 16). I've made an example because I had some free time and put it on clickteam.com:

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=34538&page=0#Post34538

I hope that makes things clearer.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
13th March, 2007 at 02:29:41 -

Thanks a lot everyone got it working. It was a problem with the positioning code, not the array position.

Now I have an app that loads all tiles from an external tileset and all enemy animations from external pictures . Now for the level editor...

 
Image
http://bfollington.tumblr.com
   

Post Reply



 



Advertisement

Worth A Click