Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PacmanPrototype
- {
- class Map
- {
- public int[,] map = new int[,]
- {
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
- {0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0},
- {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
- {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
- {0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0},
- {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0},
- {0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0},
- {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
- {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}
- };
- private Texture2D wand;
- private Texture2D boden;
- public Map()
- {
- }
- public Map(Texture2D wand, Texture2D boden)
- {
- this.wand = wand;
- this.boden = boden;
- }
- public void Draw(SpriteBatch spriteBatch)
- {
- //map.GetLength(0) -> Gibt die Länge des 1. Dimension des Arrays zurück
- //map.GetLength(1) -> Gibt die Länge des 2. Dimension des Arrays zurück
- Texture2D aktTex = wand;
- int pos_i = 0; // hohe -> y
- int pos_j = 0; // breite -> x
- spriteBatch.Begin();
- for (int i = 0; i < map.GetLength(0); i++) // -> 0
- {
- for (int j = 0; j < map.GetLength(1); j++) // j -> 1
- {
- if (map[i,j] == 0)
- {
- aktTex = wand;
- }
- else if (map[i, j] == 1)
- {
- aktTex = boden;
- }
- spriteBatch.Draw(aktTex, new Microsoft.Xna.Framework.Vector2(pos_j, pos_i), Color.White);
- pos_j += aktTex.Width; // pox x
- }
- pos_j = 0;
- pos_i += aktTex.Height;
- }
- spriteBatch.End();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement