Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Input;
- namespace Game2
- {
- #if WINDOWS || LINUX
- /// <summary>
- /// The main class.
- /// </summary>
- public static class Program
- {
- static int screenW = 1024, screenH = 576;
- static readonly TileMap Tilemap = new TileMap("C:\\Users\\tizzy\\Desktop\\map\\MSec\\");
- static int worldCoordinateX = 1700;
- static int worldCoordinateY = 0;
- static VisualsManager VM = new VisualsManager();
- static GameManager GM = new GameManager(screenW, screenH);
- static int worldXOffset = 0;
- static int worldYOffset = 0;
- static bool coordinatesChanged = true;
- private static ushort testTile = 0;
- static void Main()
- {
- using (GM)
- {
- GM.Logic += Game_Logic;
- GM.RenderQueue += Game_RenderQueue;
- GM.Load += Game_Load;
- GM.Run();
- }
- }
- private static void Game_Load(string LoadState)
- {
- switch (LoadState)
- {
- case "Init":
- VM.LoadVisualAssetFromFile("player", "C:\\Users\\tizzy\\Desktop\\down0.png");
- VM.LoadVisualAssetFromFile("waterPond", "C:\\Users\\tizzy\\Desktop\\pond04.png");
- VM.LoadVisualAssetFromFile("Land", "C:\\Users\\tizzy\\Desktop\\landtile.png");
- break;
- }
- }
- private static void Game_RenderQueue(BufferQueue Buffer)
- {
- for (int y = 0; y < 21; y++)
- {
- for (int x = 0; x < 35; x++)
- {
- switch (Tilemap.Tile(worldCoordinateX + x - 16, worldCoordinateY + y-9))
- {
- case 1:
- Buffer.Draw(VM["waterPond"], new Rectangle(x * 32 + worldXOffset - 32, y * 32 + worldYOffset - 32, 32, 32));
- break;
- case 2:
- Buffer.Draw(VM["Land"], new Rectangle(x * 32 + worldXOffset - 32, y * 32 + worldYOffset - 32, 32, 32));
- break;
- }
- }
- }
- Buffer.Draw(VM["player"], new Rectangle((screenW / 2) - 32, (screenH / 2) - 32, 64, 64));
- }
- private static void Game_Logic(string GameState)
- {
- if (GM.KeyDown(Keys.Up))
- {
- //worldCoordinateY -= 1;
- if (Tilemap.Tile(worldCoordinateX, worldCoordinateY - 1) != 0)
- {
- worldYOffset += 6;
- if (worldYOffset >= 32)
- {
- worldYOffset = 0;
- worldCoordinateY--;
- }
- }
- }
- else if (GM.KeyDown(Keys.Down))
- {
- //worldCoordinateY += 1;
- if (Tilemap.Tile(worldCoordinateX, worldCoordinateY + 1) != 0)
- {
- worldYOffset -= 6;
- if (worldYOffset <= -32)
- {
- worldYOffset = 0;
- worldCoordinateY++;
- }
- }
- }
- else if (GM.KeyDown(Keys.Left))
- {
- //worldCoordinateX -= 1;
- if (Tilemap.Tile(worldCoordinateX - 1, worldCoordinateY) != 0)
- {
- worldXOffset += 6;
- if (worldXOffset >= 32)
- {
- worldXOffset = 0;
- worldCoordinateX--;
- }
- }
- }
- else if (GM.KeyDown(Keys.Right))
- {
- //worldCoordinateX += 1;
- if (Tilemap.Tile(worldCoordinateX + 1, worldCoordinateY) != 0)
- {
- worldXOffset -= 6;
- if (worldXOffset <= -32)
- {
- worldXOffset = 0;
- worldCoordinateX++;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment