Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbReadString? Make a 2-dim Array from a File? I Just dont get it.

Author
Message
Nickles
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location:
Posted: 28th Aug 2008 01:10 Edited at: 28th Aug 2008 02:03
Hi there.
I´m new to DarkGDK and C++.
I usually work with Java , so i´m not that familiar with the C++ Language.
Most of you probably think: "OMG , Not another Noob!"
So i already excuse for that.
As you can see by my Syntax, my English is not the best since i´m German.

How ever , that´s the deal:
I try to create a 2D Game.
To design the different levels , I try to design them with a Tileset System.
That way i want to use textfiles like that , to design them:



Just as an example!

Now i try to make an Array[20][15] with that file , that contains the shown values as integers in it.
So that Array[0][2]=1 f.E.

The problem that i have already starts with reading out the values i need from the file.
I tried something like this:



I know it´s a 1-dim Array , but i don´t even get that one to work the way i want it to.
I try to read the files as a String , so i´m still able to control what the program reads.

With that code , i get either a strange output that has nothing to do with my File or simply nothing.

I hope anybody got through my confuse answer and tries to help me ^^° <
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2008 17:58
You can loop through each string letter by letter to get the second dimension of the array.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 28th Aug 2008 21:00
You might consider taking a look at the std:: file handling functions. They're a bit more flexible.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 05:21:08
Your offset time is: 2024-09-30 05:21:08