sfml main menu in csharp

Here's an example of how to create a simple main menu using SFML and C#:

main.cs
using SFML.Graphics;
using SFML.System;
using SFML.Window;
using System;

namespace SFMLMainMenu
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create the main window
            RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML Main Menu");

            // Load font
            Font font = new Font("arial.ttf");

            // Create menu items
            Text playText = new Text("Play", font);
            Text exitText = new Text("Exit", font);

            // Set menu item positions
            playText.Position = new Vector2f(350, 300);
            exitText.Position = new Vector2f(350, 400);

            // Create menu loop
            while (window.IsOpen)
            {
                // Check for events
                window.DispatchEvents();

                // Clear the window
                window.Clear(Color.White);

                // Draw menu items
                window.Draw(playText);
                window.Draw(exitText);

                // Display the window
                window.Display();
            }
        }
    }
}
1126 chars
45 lines

This code creates a main window, loads a font, and creates two menu items using the font. It positions the menu items within the window, and then sets up a loop that renders the menu items and waits for events. You can add event handling code to handle user input and control the flow of the program.

gistlibby LogSnag