Thread: level files and variables

  1. #1
    Registered User canine's Avatar
    Join Date
    Sep 2001
    Posts
    125

    level files and variables

    I have created a program that plays a little game and the level is stored in a file. the data in that file is extracted and seperated into an array of different varaibles. How should I declare that aray so that there is enough space for big complicated variables(more numbers to extract) and to save space when using a small level(less numbers)?
    The game is here it is not all that reliable and uses a aray declared with like 500 slots or something
    Game
    Game Level Maker
    In a perfect world every dog would have a home and every home would have a dog.
    Visit My Web Site, Canine Programming
    I use Win32 API

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Re: level files and variables

    Originally posted by canine
    I have created a program that plays a little game and the level is stored in a file. the data in that file is extracted and seperated into an array of different varaibles. How should I declare that aray so that there is enough space for big complicated variables(more numbers to extract) and to save space when using a small level(less numbers)?
    The game is here it is not all that reliable and uses a aray declared with like 500 slots or something
    Game
    Game Level Maker
    I didn't have time to look at your game. The obvious suggestion would to be dynmically allocate your arrays. Read in the first byte to tell you how many items follow it , then allocate enough room to store it. Remember to free the memory also!!

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    57
    <*talks in a arrogant fashion*>array, srarry. Use an STL vector. More reliable and customizable. It lets you change the size of the array in real time.
    "A Programmer being told to 'go to' hell sees the 'go to' part of the sentence as the worst part." - Master Foto

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    vector shmector, use a linked list.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Static variables and header files
    By drrngrvy in forum C++ Programming
    Replies: 8
    Last Post: 12-02-2006, 01:27 PM
  2. Replies: 3
    Last Post: 11-28-2006, 03:44 PM
  3. Variables in header files
    By Overlord in forum C++ Programming
    Replies: 5
    Last Post: 10-15-2006, 06:43 AM
  4. make variables visible on multiple files
    By jagerhans in forum C++ Programming
    Replies: 4
    Last Post: 08-28-2004, 06:32 PM
  5. variables across files
    By Hunter2 in forum C++ Programming
    Replies: 13
    Last Post: 07-23-2002, 10:58 AM