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.

Newcomers DBPro Corner / Reading from file isnt working

Author
Message
Destrugter 1
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 23rd Jun 2008 03:43
Ok, I am reading from a file to determine where to place bricks and what the color of the bricks are. So I have the following code (just assume your on level 1):



When running it, it makes "CharactersR, CharactersG, CharactersB" all equal 0...which messes up everything because then it thinks all the blocks are set the the RGB value of black...because it automatically thinks there are no characters in each string. Now here is the file of level 1.



Now how I have it set up (if you can't tell already) is I have a Line that equals whether or not its a block(0=no block, 1=block) and the lines that follow each number are their RGB values.

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Jun 2008 13:48 Edited at: 23rd Jun 2008 13:49
have you tried getting to print to screen what the value is that you have read in is, what it is when you have changed it.




what does your read file look like (just afew lines. )

from what I can tell I think is reading like this
read look one 1
read look two r=xxx
read look three g=xxx

and so on, that if your read file is the same as the output file you showed.

Dark Physics makes any hot drink go cold.
Destrugter 1
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 24th Jun 2008 03:25 Edited at: 24th Jun 2008 04:36
Well I changed the code to make it read faster...all I did was make a repeat until file end loop (Thanks a ton for the tut TDK, you are AWESOME!).

So here is the new read file code.

That is what I'm doing...first loop:reading to see if the current line is a block or not
Second loop:determine the red value, if 0 is the color then it creates a random color for it.
Third loop:same as red except for green
Fourth loop: same as red except for blue.

The new file for level 1, I realized it was working correctly but incorrectly at the same time. It was working correctly for the fact that I specified each one as 0 -_-

So here is the new file 1:


Here is the code I used to determine the block colors.


EDIT:Tried that and it won't work...it doesn't print anything to the screen. When I put it to display what BlocksR(8) (which should be 255 from what my code is like with my file) and it displays a random number everytime.

EDIT2k, I figured it out, I had to close the file and re-open it before and after every loop...if there is a faster way then please tell me but this seems to work fine without speed reductions.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 24th Jun 2008 13:29
closeing the file and re-opening is like resetting the pointer in the file.

this I think you might find faster.


Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-11-25 22:40:14
Your offset time is: 2024-11-25 22:40:14