public void StartGame(Graphics g) { _gEngine = new GEngine(this, g); _gEngine.Init(); _updateThread.Start(); }
public GSphere(GEngine engine, float x, float y, float z, float rad, float r, float g, float b) : base(engine) { this.x = x; this.y = y; this.z = z; this.rad = rad; this.r = r; this.g = g; this.b = b; }
// Call after canvas size changes public static void UpdateAllScaleAndPosition() { GEngine.pause(); for (int i = 0; i < AllScalable.Count; i++) { AllScalable[i].UpdateScale(); AllScalable[i].UpdatePosition(); } GEngine.resume(); }
private void Sync_Loop() { //Init InitLogic(); InitGraphics(); Stopwatch logicTimer = new Stopwatch(); Stopwatch drawTimer = new Stopwatch(); Sampler fpsAvg = new Sampler(100); Sampler tpsAvg = new Sampler(100); //Initial Stuff GEngine.LoadStatics(this); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, ParseRenderScale(Properties.RenderScaleQuality)); while (!ResourcesLoaded) { SDL_Delay(1000); } logicTimer.Start(); drawTimer.Start(); double total; bool flip = false; do { total = GetPreciseMs(); if (ETtoMS(logicTimer.ElapsedTicks) >= Properties.TargetLogictime) { _cur_logictime = ETtoMS(logicTimer.ElapsedTicks); tpsAvg.AddPoint(1000.00 / _cur_logictime); logicTimer.Restart(); LogicStep(); } if (ETtoMS(drawTimer.ElapsedTicks) >= Properties.TargetFrametime || !Properties.EnableFramelimiter) { if (!flip) { _cur_frametime = ETtoMS(drawTimer.ElapsedTicks); fpsAvg.AddPoint(1000.00 / _cur_frametime); drawTimer.Restart(); DrawStep(); } if (!Properties.EnableFramelimiter) { flip = !flip; } } total = GetPreciseMs() - total; _cur_totaltime = total; _fps = fpsAvg.GetAverage(); _tps = tpsAvg.GetAverage(); } while (!_StopThread); _Aborted_S = true; }
public GMenuPanel(Control parent, GEngine engine) { this.BackColor = Color.FromArgb(50, 50, 50); this.Width = 180; this.Height = 85; parent.Controls.Add(this); this.Left = parent.Width - this.Width; this.Top = parent.Height - this.Height; this.TabStop = false; but = new GButtonFlat[4]; int intent = 0; for (int i = 0; i < 2; i++) { but[i] = new GButtonFlat(this); but[i].Top += intent; but[i].TabStop = false; but[i].Width = 90; but[i].Click += (o, e) => { Clicks(o, e); }; intent += but[i].Height; } intent = 0; for (int i = 2; i < 4; i++) { but[i] = new GButtonFlat(this); but[i].Top += intent; but[i].Width = 90; but[i].Left = but[i].Width; but[i].TabStop = false; but[i].Click += (o, e) => { Clicks(o, e); }; intent += but[i].Height; } but[0].Text = "Продолжить"; but[1].Text = "Сохранить"; but[2].Text = "Загрузить"; but[3].Text = "Выйти"; this.Visible = false; }
public void Start() { //Initializations _occupant = new Occupant(Map, Window, 'W', 'S', 'A', 'D'); gEngine = new GEngine(Window, Map, SimulationRoom); CreateLightUnit(); Controller = new DALIController(LightUnitCoordinates); Controller.InitGroups(); InfoScreen = new InfoScreen(Window, Controller); ControlPanel = new ControlPanel(Window, Controller, LightUnitCoordinates, InfoScreen, SimulationRoom); //Draw info Info = new InfoDrawing(Window); Info.initWattInfo(); Info.InitBrugerPosWiFi(); Info.InitBrugerPos(); //Quadtree, initialize the graphics engine and load the visual level _tree.CreateQuadTree(LightUnitCoordinates); gEngine.init(); gEngine.LoadLevel(LightUnitCoordinates, Router1, Router2); }
public SaveObjects(GEngine engine) { InitializeComponent(); this.engine = engine; }
public GBaseModel(GEngine engine) { this.engine = engine; }
public static void LoadWorld(string name) { string progfiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string json = System.IO.File.ReadAllText(progfiles + @"\Sap\Worlds\" + name + @"\" + "world.json"); // Pause game loop before messing with data GEngine.pause(); // Clear all world data Tile.RemoveAll(); World w = new World(name); SpriteHandler.sprites.Clear(); SpriteHandler.sentiants.Clear(); //SpriteHandler.VisableSprites.Clear(); World.BinWorld binw = new World.BinWorld(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json)); DataContractJsonSerializer ser = new DataContractJsonSerializer(binw.GetType()); binw = ser.ReadObject(ms) as World.BinWorld; // Load in all saved world data Tile[] tiles = new Tile[binw.tiles.Length]; List <StructureTile> struct_tiles = new List <StructureTile>(); for (var i = 0; i < binw.tiles.Length; i++) { // if its a function tile, load it as one if (binw.tiles[i] is FunctionTile.BinFuncTile) { tiles[i] = new FunctionTile(binw.tiles[i] as FunctionTile.BinFuncTile); } else if (binw.tiles[i] is StructureTile.BinStructureTile) { tiles[i] = new StructureTile(binw.tiles[i] as StructureTile.BinStructureTile); struct_tiles.Add(tiles[i] as StructureTile); } else { tiles[i] = new Tile(binw.tiles[i]); } } // Populate arrays with saved data (must be up here since function tiles are appended on init) w.Tiles = tiles.ToList(); w.StructureTiles = struct_tiles; Game.World = w; Game.P = new Player(); string playerjson = System.IO.File.ReadAllText(progfiles + @"\Sap\Worlds\" + name + @"\" + "player.json"); Player.BinPlayer binp = new Player.BinPlayer(); MemoryStream msp = new MemoryStream(Encoding.UTF8.GetBytes(playerjson)); DataContractJsonSerializer serp = new DataContractJsonSerializer(binp.GetType()); binp = serp.ReadObject(msp) as Player.BinPlayer; Game.P.LoadInventory(binp); Game.P.X = binp.X; Game.P.Y = binp.Y; Game.Camera = new Camera(Game.P); // Resume the game loop GEngine.resume(); // Set the gamestate Game.GameState = GameState.GAME; }