6
« on: November 03, 2014, 10:58:36 am »
does this help at all...?
public static class Program
{
private static bool isFullScreen = false;
public static VideoMode screenRes = new VideoMode(400, 300);
private static Game game;
public static Game Game
{
get { return game; }
}
private static Encryption encryption;
public static Encryption Encryption
{
get { return encryption; }
}
private static RenderWindow window;
public static RenderWindow Window
{
get { return window; }
set { window = value; }
}
private static RenderWindow windowencryipt;
public static RenderWindow WindowEncyript
{
get { return windowencryipt; }
set { windowencryipt = value; }
}
private static DateTime previousTick;
public static DateTime PreviousTick
{
get { return previousTick; }
}
private static TimeSpan tickLength;
/// Length of time between each update call
/// </summary>
public static TimeSpan TickLength
{
get { return tickLength; }
}
private static int fps;
public static int FPS
{
get { return fps; }
}
private static float delta;
static void Main(string[] args)
{
//Window = new RenderWindow(VideoMode.DesktopMode, "0", Styles.Fullscreen);
game = new Game();
encryption = new Encryption();
if (isFullScreen)
{
screenRes = VideoMode.DesktopMode;
window = new RenderWindow(screenRes, "0", Styles.Fullscreen);
windowencryipt = new RenderWindow(screenRes, "0", Styles.Fullscreen);
}
else
window = new RenderWindow(screenRes, "0", Styles.Default);
windowencryipt = new RenderWindow(screenRes, "0", Styles.Default);
WindowEncyript.Closed += new EventHandler(Exit);
WindowEncyript.SetVerticalSyncEnabled(true);
Window.Closed += new EventHandler(Exit);
Window.SetVerticalSyncEnabled(true);
SetFPS(60);
Assets.Initialize();
Game.Initialize();
Encryption.Initialize();
while (Window.IsOpen())
{
if (PreviousTick.Add(TickLength) <= DateTime.Now)
{
Update();
Draw();
}
}
while (WindowEncyript.IsOpen())
{
if (PreviousTick.Add(TickLength) <= DateTime.Now)
{
Update();
Draw();
}
}
}
private static void Draw()
{
Window.Clear(Color.White);
Game.Draw(Window, delta);
Window.Display();
WindowEncyript.Clear(Color.White);
Encryption.Draw(WindowEncyript, delta);
WindowEncyript.Display();
//if (Game.Test == true)
//{
// WindowEncyript.Display();
// //Window.Close();
//}
//Window.Display();
}
private static void Update()
{
// Launch all events
Window.DispatchEvents();
WindowEncyript.DispatchEvents();
//Calculate delta time
delta = (float)DateTime.Now.Subtract(previousTick).TotalSeconds;
Game.Update(window, delta);
Encryption.Update(windowencryipt, delta);
previousTick = DateTime.Now;
if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
window.Close();
windowencryipt.Close();
}
public static void Exit(object obj, EventArgs args)
{
Window.Close();
WindowEncyript.Close();
}