@FistiPaul wrote:
Hello,
I try to get the IndexSprite of the 2d list in my Level class to check if the player will be able to walk or not.
My problem is that i need to get the list with the index from my Level class, and i need to create a new object
ancienneListe but if i have a new one the index will all be set to 1 (i decied to have it to 1 by default if not set in my Leve class)public MapRowColumn ancienneListe = new MapRowColumn; // new = index set to 1 and my player cant move
This is from my class Player:
public MapRowColumn ancienneListe; public List<MapRowColumn.IndexLigne> nouvelleListe = new List<MapRowColumn.IndexLigne>(); if (Keyboard.GetState().IsKeyDown(Keys.Right) && old_right == false) { if (ancienneListe.Rows[joueur_position.X].Columns[joueur_position.Y].IndexSprite == 0) { direction = "droite"; joueur_position.X++; old_right = true; } else if (ancienneListe.Rows[joueur_position.X].Columns[joueur_position.Y].IndexSprite == 1) { joueur_position.X = joueur_position.X + 0; } } if (Keyboard.GetState().IsKeyUp(Keys.Right) && old_right == true) old_right = false;
This is from my class Level:
public MapRowColumn map_row_column; public Point joueur_pos = new Point(1, 2); // position du joueur public Niveau1() { map_row_column = new MapRowColumn(); map_row_column.Rows[1].Columns[1].IndexSprite = 0; map_row_column.Rows[1].Columns[2].IndexSprite = 0; map_row_column.Rows[1].Columns[3].IndexSprite = 0; map_row_column.Rows[1].Columns[4].IndexSprite = 0; }
I hope this make sense and that you can help me, thank you
Posts: 2
Participants: 2