Advertisement
Guest User

sfmlc#

a guest
Mar 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using SFML;
  7. using SFML.Graphics;
  8. using SFML.Window;
  9.  
  10. namespace sfmlcsharp
  11. {
  12.     class Program
  13.     {
  14.         static RenderWindow window = new RenderWindow(new VideoMode(800, 600), "sfml");
  15.  
  16.         static uint FPS = 60;
  17.  
  18.         private void Init()
  19.         {
  20.             window.SetFramerateLimit(FPS);
  21.             window.Closed += OnClosed;
  22.             window.KeyPressed += OnKeyPressed;
  23.         }
  24.  
  25.         public Program()
  26.         {
  27.             Init();
  28.             while (window.IsOpen)
  29.             {
  30.                 window.DispatchEvents();
  31.  
  32.  
  33.  
  34.  
  35.                 window.Clear(new Color(255, 128, 0));
  36.  
  37.                 window.Display();
  38.             }
  39.         }
  40.  
  41.         static void OnClosed(object sender, EventArgs e)
  42.         {
  43.             var window = (RenderWindow)sender;
  44.             window.Close();
  45.         }
  46.  
  47.         static void OnKeyPressed(object sender, KeyEventArgs e)
  48.         {
  49.             if (e.Code == Keyboard.Key.Escape)
  50.             {
  51.                 window.Close();
  52.             }
  53.             if(e.Code == Keyboard.Key.A)
  54.             {
  55.                 Console.WriteLine("A pressed");
  56.             }
  57.         }
  58.  
  59.         static void Main(string[] args)
  60.         {
  61.             new Program();
  62.            
  63.         }
  64.  
  65.        
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement