Hello everyone,
So i'm having problems with my music it's playing and stuff but my window kinda starts bugging.
If i set the music in my gameloop then the window isn't usable anymore.
I haven't tested to draw anything on it so that could still be possible but the close open and minimize button no longer work and when i overlay another program over it, then i can no longer open it.
static void Main
() { // initialize the form System.Windows.Forms.Form form
= new System.Windows.Forms.Form(); // create our form form
.Text = Variables
.General.GameName; System.Drawing.Icon ico
= new System.Drawing.Icon("icon.ico"); form
.Icon = ico
; form
.Size = new System.Drawing.Size(Variables
.GameScreen.ScreenWidth, Variables
.GameScreen.ScreenHeight); // set form size to 600 width & 600 height form
.Show(); // show our form DrawingSurface rendersurface
= new DrawingSurface
(); // our control for SFML to draw on rendersurface
.Size = new System.Drawing.Size(Variables
.GameScreen.ScreenWidth, Variables
.GameScreen.ScreenHeight); // set our SFML surface control size to be 500 width & 500 height form
.Controls.Add(rendersurface
); // add the SFML surface control to our form rendersurface
.Location = new System.Drawing.Point(0,
0); // center our control on the form // initialize sfml SFML
.Graphics.RenderWindow renderwindow
= new SFML
.Graphics.RenderWindow(rendersurface
.Handle); // creates our SFML RenderWindow on our surface control // drawing loop while (form
.Visible) // loop while the window is open { System.Windows.Forms.Application.DoEvents(); // handle form events renderwindow
.DispatchEvents(); // handle SFML events - NOTE this is still required when SFML is hosted in another window renderwindow
.Clear(SFML
.Graphics.Color.Black); // clear our SFML RenderWindow renderwindow
.Display(); // display what SFML has drawn to the screen GameLoop
.Running(); } } /// <summary> /// Play a music /// </summary> public static void PlayMusic
(string path,
bool loop
) { // Load an ogg music file Music music
= new Music
(path
); // Play it music
.Volume = 50; music
.Play(); music
.Loop = loop
; // Loop while the music is playing while (music
.Status == SoundStatus
.Playing) { // Leave some CPU time for other processes Thread
.Sleep(100); } } class GameLoop
{
public static void Running()
{
SoundEngine.PlayMusic("DataFiles/Music/Main.wav", true);
}
}
Kind regards santa,