User Tag List

Results 1 to 10 of 10

Thread: Binary Array

  1. #1
    No Products Registered

    Join Date
    Jun 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Binary Array

    I'm attempting to make a level editor, and I've been looking at the Knytt level reader... and I have no clue how binary array works.

    My current code just writes a 1 or a 0 to an array to place tiles, and refreshes the screen. So I know it works with a normal array, but this binary array thing is something that I just dont understand. I tried saying "write 1 to combineXY(x and y)" or whatever, but that produces so wild results.

    I've tried looking for some sort of documentation but I've failed pretty hard at that... if anyone has any useful info or links about this extension, send 'em along ;p

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module

    Join Date
    Feb 2007
    Location
    Queensland, Australia
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    You have to create a workspace first, otherwise you just get garbage data I think.

    Start of Frame:
    Create Workspace "Test"
    Switch Workspace "Test"
    Modify range at 0 with size SOMEBYTECOUNT to 0

    (Nifflas' uses 3006 for the SOMEBYTECOUNT ( 25 x 10 tiles per layer, 8 layers or something and some bytes for config data )

  3. #3
    No Products Registered

    Join Date
    Jun 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    This doesnt seem to be working then...

    start of frame:
    create workspace "map"
    switch workspace "map"
    modify range 0 with size 300 to 0

    the application just crashes when I do this... :I

  4. #4
    Clicker Fusion 2.5 DeveloperSWF Export ModuleInstall Creator Pro

    Join Date
    Jun 2006
    Location
    France
    Posts
    1,266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    because you didnt open a file for reading/writing?

  5. #5
    No Products Registered

    Join Date
    Jun 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    I guess I had to set the virtual width and height and size in the frame editor, I didnt know this.

    But.. it still doesnt work. I cant seem to get the editor to work with the binary array, but normal array works fine, and I'm pretty sure I was following the Knytt example step by step.

  6. #6
    No Products Registered

    Join Date
    Aug 2006
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    For anyone else who needs to know, this answers the questions:

    soundofjw: he has 12 bytes of information for every tile
    soundofjw (6:02:25 PM): 25*10*12 = 3000
    soundofjw (6:02:36 PM): the 6 extra bytes store information about the level.
    soundofjw (6:02:38 PM): music, tileset, etc.
    soundofjw (6:03:08 PM): the virtual height and width are really only for helping you read it with ease
    soundofjw (6:03:13 PM): thats why he stores the extra information at the end
    soundofjw (6:03:36 PM): he can use the height and width to quickly read the information with offsets without multiplying by various values.

  7. #7
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    That's correct! In KS, the information is stored like this:

    0-249 = Layer 0 tile
    250-499 = Layer 1 tile
    500-749 = Layer 2 tile
    750-999 = Layer 3 tile
    1000-1499 = Layer 4 bank & object
    1500-1999 = Layer 5 bank & object
    2000-2499 = Layer 6 bank & object
    2500-2999 = Layer 7 bank & object

    The remaining bytes are used to store the ambiance (x2), music, tileset (x2), and gradient values.

    In my opinion, you have to plan out the file content like this, to set the correct workspace size, virtual width / height, and have a good understanding of where you need to write what to... And of course, you must remember that different data types eats different amount of bytes in the array. If you write a 'short' integer to position 0, both position 0 and 1 will be used to store that value.

  8. #8
    No Products Registered

    Join Date
    Jun 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    Alright, so I think I've got it down for bytes, and tiles with layers. But now I want to tackle putting entities in.

    I want to use another binary array, this one suited for strings for the placement of entities. An entity would be represented by a string, with some arguments with it broken up with the "|" character. So like a door would say "door|outside|5|42" as its string, and it would represent a door entity, it would send the player to the map file "outside" with a new X of 5, and a new Y of 42.

    I figured that 256 characters per string would be fine, and my world is 200 x 150 tiles max.. so I multiplied all these numbers together to set the binary array size.

    I guess my problem is how to approach strings with this thing, since if I write the string to just 10,10 for example, the string is placed in (10, 10) through (10+string length, 10), and I only want it to be placed in (10,10)...

    I want to avoid using a regular array, since that would be a pretty big filesize per level.

    edit

    Okay so I've been trying to multiply 256 into the combine xyz function to attempt to give each element 256 bytes for the string. I only multiply the x by 256, and I leave the y alone, and the z is always 1. But now something odd happens...

    Say I write a string to 11, 3. That works, but then the last few characters of that string also end up at 4, 12 for some reason. 2, 8 results in the same thing at 9, 3.

    Now back to trying to figure this out...

  9. #9
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    Try using the combine xyz function with 0 in x, x in y and y in z, 256 in xsize, width in ysize and height in zsize (if there is a zsize).

    Alternatively using combine xyz with x *256 and width*256 should also work.

    But as you're only storing stings, I'd expect a proper string array object to be more efficient. No need to set a maximum size then.

  10. #10
    No Products Registered

    Join Date
    Jun 2006
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Binary Array

    Quote Originally Posted by Dynasoft
    Try using the combine xyz function with 0 in x, x in y and y in z, 256 in xsize, width in ysize and height in zsize (if there is a zsize).

    Alternatively using combine xyz with x *256 and width*256 should also work.

    But as you're only storing stings, I'd expect a proper string array object to be more efficient. No need to set a maximum size then.
    I think I got it, with some of that. I decided on a max string length of 100, and make the width*100, and then multiplied the x by 100 with combine xyz.

    I also realized that 0 is the first element of the z part, not 1, so that fixed a lot of my bizarro problems.

Similar Threads

  1. Binary array bug.
    By wwmb in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 18th December 2012, 08:51 PM
  2. Dynamic Array to Binary Array problems
    By BREK in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 22nd March 2010, 10:48 PM
  3. binary array help
    By Oreo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 4th November 2008, 11:11 PM
  4. Binary Array
    By dragonguy in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 3rd November 2008, 03:41 PM
  5. Binary Array
    By astrospoon in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 9th September 2008, 03:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •