0 Members and 1 Guest are viewing this topic.
using System;using SFML;using SFML.Window;using SFML.Graphics;namespace SFMLTest{ class Program { public Player MyPlayer; static void OnClose(object Sender, EventArgs e) { RenderWindow Window = (RenderWindow)Sender; Window.Close(); } static void Main(string[] args) { RenderWindow Window = new RenderWindow(new VideoMode(384,256),"Hello world!"); Window.Closed += new EventHandler(OnClose); Window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed); while(Window.IsOpened()) { Window.DispatchEvents(); Window.Clear(); Player MyPlayer = new Player(); Player.Initialize(MyPlayer); Sprite ImageToDraw = MyPlayer.Draw(MyPlayer); Window.Draw(ImageToDraw); Window.Display(); } } static void OnKeyPressed(object Sender, KeyEventArgs e) { RenderWindow Window = (RenderWindow)Sender; if (e.Code == KeyCode.Escape) Window.Close(); } }}
using System;using SFML;using SFML.Window;using SFML.Graphics;namespace SFMLTest{ class Player { public int X,Y; public string ImagePath; public Player() { } public static void Initialize(Player Player) { Player.X = 100; Player.Y = 100; Player.ImagePath = "Images/TestImage.png"; } public Sprite Draw(Player Player) { Sprite PlayerImage = new Sprite(new Image(Player.ImagePath)); PlayerImage.Position = new Vector2(Player.X,Player.Y); return PlayerImage; } }}