Repos

MELHARFI-2D-Game-Engine.

Got to repo.

22. Drawing Surface

Usualy you can create only one instance of Game Engine that i call often "manager" (instance of Manager).

In the other hand, if your game is more advanced, with a hud, menu, drawing surface you still can use one instance of Manager but you need to organize sections.

In that case better to devide your game into different sections by using multi instance of Manager.

Assuming you draw a RPG game, probably you need a surface to draw your map and another section to draw a hud and another section for menu.

Since the placeholder is the main form itself we need a way to devide it into many peaces, you can then use panels, a Content panel, and a Bottom panel for hud and Menu panel inleft side.

                        
using System.Drawing;
using System.Windows.Forms;
using MELHARFI.Manager;

namespace _2dProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            Manager containerManager = new Manager(PlContainer, "container");
            containerManager.Background = Color.Blue;

            Manager hudManager = new Manager(PlHude, "hud");
            hudManager.Background = Color.Gray;

            Manager menuManager = new Manager(PlMenu, "menu");
            menuManager.Background = Color.Red;
        }

    }
}
                        
                      

As you can see we create 3 instances of manager to allow each one to handle a specific purpose and they are completely separated and the background has been changed too.

Remember that you can invoc the Manager instance anytime when you are out of scope

                        
private void Do()
{
    Manager containerManager = Manager.Managers.First(f => f.Name == "container");
    Manager hudManager = Manager.Managers.First(f => f.Name == "hud");
    Manager menuManager = Manager.Managers.First(f => f.Name == "menu");
}
                        
                      

Services

App Developpement

Want me to dev an app for you ? dont hesitate to contact me.

Programming

Are you looking for a coder/teammate for your project ? Let's give it a try.

Job Invitation

Have a proposal for me ? we can discuss about it.

Donation maybe ?!

You want to buy me a coffe ? m.elharfi@gmail.com