Computer Science Canada Generating sprites while reading .txt files |
Author: | Skilgannon [ Tue Apr 25, 2006 5:25 pm ] | ||||
Post subject: | Generating sprites while reading .txt files | ||||
I'm trying to make an rpg game, and I want to generate the world while keeping track of collision at the same time, using 2d arrays. Basically I have a 2d of 18x25, in which values 0,1 or 2 are put, and depending on which, it outputs or rather SHOULD output a 16x16 sprite. For some reason, it doesn't work. Here's a program which randomly generates a 18 row x 25 collumn txt file with numbers 0,1,2
Now here's the program which should read the .txt file and output the sprites :
For some reason it says "Variable has no value". Can someone help ? I've also attached the files in a .rar |
Author: | Delos [ Tue Apr 25, 2006 5:39 pm ] | ||||
Post subject: | |||||
Try adding a space between each of your numbers as you write them to the file. Currently it looks like they'll all be written one after the other. You can test this buy puting the value of each element of the array ('testing') as it is being read in. So, instead of:
Replace with:
Haven't tested the code, but that should work. Good luck on your RPG, and make sure you read the [Turing Walkthrough] for some important pointers and general info that will help you improve your coding hugely. |
Author: | Skilgannon [ Tue Apr 25, 2006 8:08 pm ] |
Post subject: | |
Solved it, I figured out what I did wrong XD Thanks |