User Tag List

Results 1 to 5 of 5

Thread: Storing Decimals in an Array

  1. #1
    No Products Registered

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

    Storing Decimals in an Array

    Hi,

    I'm making a tile based level editor for a game, and am storing the tile number, followed by its direction in a single array, where the X and Y indexes are the grid co-ordinates of the level.

    I wanted to store the number as:
    TileNo.Direction

    Using the calculation:
    TileNo + (Dir("Tile")/80)

    So:
    Tile1, Direction 0 = 1.0
    Tile1, Direction 8 = 1.1
    Tile1, Direction 16 = 1.2
    Tile3, Direction 24 = 1.3

    However when it is stored, it is automatically stored as an Integer. (The Array is set as a 'Number Array')

    Is there any way to change this, or maybe an easier way to store TileNo and Direction without using 2 different Arrays?

    Thanks in advance.

  2. #2
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Storing Decimals in an Array

    It's a clever idea, but I'm not sure that you'll get it working like that (I'm still uncertain about how MMF decides whether things are integers or floats, to be honest). Could you rework it so that the direction and tile number are combined into an integer?

    TileNo*4 + Dir("Tile")/8

    You'd have to set up your array to divide the tile number out again, though.

    Of course, you could always shove some *1.0s into it and see what happens. I think the most likely thing to work is using /80.0 instead of /80.

  3. #3
    Firecodemonkey

    Join Date
    Aug 2006
    Location
    London, UK
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Storing Decimals in an Array

    As far as I'm aware, the array is for integers only. Regardless, I would avoid decimals if possible, as they do not have perfect precision due to computer limitations - regard them ONLY as an approximation to a value rather than a perfect representation.

  4. #4
    No Products Registered

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

    Re: Storing Decimals in an Array

    Thanks for your replies!

    OT, DavidN: Good to see Crystal Towers 2 on its way! I remember reading an article on Teletext in the UK about Clickteam's products, and Crystal Towers was one of the games mentioned, which persuaded me to try out TGF :cool:

  5. #5
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Storing Decimals in an Array

    To store a float as an integer, it's pretty easy, just multiply the float by 100, store it, and then divide it by 100 when loading...

Similar Threads

  1. Storing floats in an array?
    By mobichan in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 4th September 2012, 01:58 PM
  2. Storing infomation in ini++...
    By Earl in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 6th August 2012, 01:53 AM
  3. Storing Data
    By Kracker in forum Android Export Module Version 2.0
    Replies: 14
    Last Post: 12th June 2012, 06:24 PM
  4. storing objects in array
    By westray in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 20th May 2012, 07:14 PM
  5. Storing variables on which way?
    By Ran_TH in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 27th August 2008, 01:17 PM

Posting Permissions

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