-
Notifications
You must be signed in to change notification settings - Fork 0
/
Engine.cs
79 lines (62 loc) · 2.43 KB
/
Engine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.IO;
using System;
using System.Reflection;
using Newtonsoft.Json;
using MoonSharp.Interpreter;
using BBQLib;
namespace Snowball
{
public static class Engine
{
const string defaultDirectory = "demo";
public const string engineName = "Sn0wballEngine V6.0";
public static float deltaTime;
public static string gameDirectory;
public const string engineScripts = "engineScripts/";
public static void CreateGameDirectory(string name)
{
Engine.gameDirectory = name;
Directory.CreateDirectory(name);
string[] importantDirs = new string[]
{
DirectoryConsts.scriptDirectory,
DirectoryConsts.spriteDirectory,
DirectoryConsts.soundDirectory,
DirectoryConsts.musicDirectory,
DirectoryConsts.sceneDirectory,
DirectoryConsts.prefabDirectory,
DirectoryConsts.inputDirectory,
DirectoryConsts.fontDirectory
};
Console.WriteLine("Creating new game {0}", name);
foreach(var dir in importantDirs)
{
Console.WriteLine("creating directory {0}", dir);
Directory.CreateDirectory(dir);
}
LuaUtils.CreateLuaFile("load.lua");
}
public static void Run(string[] args)
{
Console.WriteLine("{0} created by BBQGiraffe running on {1}", engineName, Environment.OSVersion);
Json.InitSettings();
gameDirectory = ((args.Length > 0) ? args[0] : defaultDirectory) + "/";
WindowConfig windowConfig = Json.Load<WindowConfig>(gameDirectory + "game.json");
BBQLib.BBQLib.Init(windowConfig, BackendType.SFML);
Input.LoadAxisFile(DirectoryConsts.inputDirectory + "axes.json");
BBQLib.BBQLib.rootDirectory = gameDirectory;
BBQLib.BBQLib.LoadFonts("fonts.json");
Console.WriteLine("starting lua{0}...", Script.LUA_VERSION);
BBQLib.BBQLib.LoadSounds("sfx");
LuaUtils.LoadEngineClasses();
LuaObject.LoadLua();
while(BBQLib.BBQLib.IsOpen)
{
BBQLib.BBQLib.Clear();
LuaObject.Update();
BBQLib.BBQLib.Display();
GC.Collect();
}
}
}
}