Computer Science Canada How does turing handle/interpret text files? |
Author: | Recoil [ Mon Jan 19, 2004 9:23 pm ] | ||||||
Post subject: | How does turing handle/interpret text files? | ||||||
semester's almost over, and ill be starting commtech 11 (java!) in a few weeks, so i thought i'd brush up on my turing skills for practice, and maybe start my java ISU in turing, and port it over later. so im making a platformer, (if you must know, based on that oh-so-holy FPS HALO ) and have got pretty much everythng worked out (i've made a smaller-scale platformer before, so the actual mechanics are no problem for me) the problem comes in implementing turing's open/get through external text files.. here's how its layed out so far... the plan is to have the screen set up as a 640x480 (scaling will be implemented later on) window, split up into 16x16 tiles, Mario Style. therefore, a two-dimensional array, layer1 which is 40x30. what i want to end up with, is a text file like so:
(as an example of a single screen, with a gradually sloping ground and island about 2/3 to the right) each value represents what that tile will be in-game, 0 being sky, 1 being solid ground, 2 being grass, etc. i want turing to open this file, and line by line distribute each number into the array, based upon its position in the textfile. from there, the game can already handle it. but so far, the only way i've been able to do it is by putting each number on its own line... ie:
...etc, 1200 lines down. the code for this is:
but i just *can't* get it to read each row and THEN split it up and distribute to the array. its just totally wracking my brain... please help i've attached a zip of the entire directory... if you want to see how it is supposed to work in the end, open up and run leveleditor, and when it asks for a file, tell it to use "level1.txt"..but open up level1.txt in notepad, and see how it is 1200 lines :/ .... what i want to use in the end is something like level1a.txt ..... thanks for the help |
Author: | McKenzie [ Mon Jan 19, 2004 9:36 pm ] |
Post subject: | |
well to get one character in Turing use: get:fileNo, data:1 I think from what I see in your code you'll figure it out from here. (The colon forces character-based rather than token based input so it does not skip over whitespace before getting data) - oh data had better be string. (use strint later if you want int) |
Author: | Recoil [ Mon Jan 19, 2004 10:29 pm ] | ||
Post subject: | |||
and w00t, it works... awesome... thanks man.. didn't work at first (passed illegal character to strint), then realized it was counting carriage returns, and i changed the column forcount to 41 (insted of 40) and told it to skip over passing it into the array when the count was 41... thanks alot
so just to be clear... when turing *normally* gets anything from say a textfile, it stops at a space right? and skips over all spaces, going to the next "word" ? and doesn't count carriage returns as a word, but does count them as characters... just being 100% sure here... |