Mar 13, 2017 03:54 AM
(This post was last modified: Mar 13, 2017 03:55 AM by Hogtalare1.)
We're currently working on a school project where we are going to make a very simple little game, but here is my problem:
I currently have a text document in which I write coordinates where I want to place a certain sprite using "streamreader" formatted like this: CoordinateX:CoordinateY:texturename.
I have made another classfile called "level" with methods with get and set functions for each value.
Here it adds the strings and floats from the text document into the list "List<level> tilesposlist = new List<level>();".
Here it draws the "tiles" sprite which is a Texture2d using the correct coordinates.
Now I want the program to check the "tilestexturess" in the text document and change the "tiles" texture to the correct texture from all the textures I have.
I was thinking of having another list where I put all textures and then make it check if the names match. How do I do this in the most simplest form?
I currently have a text document in which I write coordinates where I want to place a certain sprite using "streamreader" formatted like this: CoordinateX:CoordinateY:texturename.
I have made another classfile called "level" with methods with get and set functions for each value.
Code
while ((k = blockposition.ReadLine()) != null)
{
string[] database = k.Split(':');
tilestemppos.X = float.Parse(database[1]);
tilestemppos.Y = float.Parse(database[0]);
tilestexturess = database[2];
tilesposlist.Add(new level(tilestemppos.X, tilestemppos.Y,tilestexturess));
}Here it adds the strings and floats from the text document into the list "List<level> tilesposlist = new List<level>();".
Code
for (int i = 0; i < tilesposlist.Count; i++)
{
tiles_pos.X = tilesposlist.ElementAt(i).blockpositionX;
tiles_pos.Y = tilesposlist.ElementAt(i).blockpositionY;
spriteBatch.Draw(tiles, tiles_pos, Color.White);
}Here it draws the "tiles" sprite which is a Texture2d using the correct coordinates.
Now I want the program to check the "tilestexturess" in the text document and change the "tiles" texture to the correct texture from all the textures I have.
I was thinking of having another list where I put all textures and then make it check if the names match. How do I do this in the most simplest form?

