Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using SFML.Audio;
- using SFML.Window;
- using SFML.Graphics;
- using Entity;
- namespace MWM
- {
- class Program
- {
- List<Sprite> entities = new List<Sprite>();
- List<Sprite> blocks = new List<Sprite>();
- List<String> blocksInfo = new List<String>();
- static Player p = null;
- static double speed = 1;
- public static int gravity = 1;
- static void OnClose(object sender, EventArgs e)
- {
- // Close the window when OnClose event is received
- RenderWindow window = (RenderWindow)sender;
- window.Close();
- }
- static void OnKeyPressed(object sender, KeyEventArgs e)
- {
- if (e.Code == Keyboard.Key.W)
- {
- p.jump(2);
- }
- if (e.Code == Keyboard.Key.A)
- {
- p.walk("left", speed);
- }
- if (e.Code == Keyboard.Key.D)
- {
- p.walk("right", speed);
- }
- }
- static void Main(string[] args)
- {
- // Program Starting Code
- RenderWindow window = new RenderWindow(new VideoMode(1024, 768), "Game");
- window.Closed += new EventHandler(OnClose);
- window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
- p = new Player("Graphics/mainCharStand.PNG", new Vector2f(320, 320));
- Text hi = new Text(p.getPos().X.ToString() + ", " + p.getPos().Y.ToString());
- // Loop
- while (window.IsOpen())
- {
- System.Threading.Thread.Sleep(50); // Loop Timer
- window.DispatchEvents(); // Send Events To Handlers
- hi.DisplayedString = p.getPos().X.ToString() + ", " + p.getPos().Y.ToString(); // Display Player Location
- p.updateV(ref window); // Update Player Velocity
- // Program Drawing Code
- window.Clear();
- p.draw(ref window);
- window.Draw(hi);
- window.Display();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment