public SonicEngine() { Instance = this; /*var pl = @""; Window.Instance.Me().Global.Console.Log(new Compressor().CompressText(pl));*/ gameCanvas = CanvasInformation.Create((CanvasElement) Document.GetElementById(gameCanvasName), 0, 0,true); uiCanvas = CanvasInformation.Create((CanvasElement)Document.GetElementById(uiCanvasName), 0, 0, true); //new SpeedTester(gameCanvas);return; canvasWidth = 0; canvasHeight = 0; bindInput(); fullscreenMode = true; Window.AddEventListener("resize", e => resizeCanvas(true)); jQuery.Document.Resize(e => resizeCanvas(true)); sonicManager = new SonicManager(this, gameCanvas, () => resizeCanvas(true)); sonicManager.IndexedPalette = 0; Window.SetInterval(sonicManager.Tick, 1000 / 60); Window.SetInterval(GameDraw, 1000 / 60); Window.SetInterval(UIDraw, 1000 / 10); resizeCanvas(true); }
public TilePaletteAnimationManager(SonicManager sonicManager) { SonicManager = sonicManager; Init(); }
public SonicManager(SonicEngine engine, CanvasInformation gameCanvas, Action resize) { Instance = this; // SonicToon = new Sonic(); this.engine = engine; this.engine.canvasWidth = jQuery.Window.GetWidth(); this.engine.canvasHeight = jQuery.Window.GetHeight(); gameCanvas.DomCanvas[0].SetAttribute("width", this.engine.canvasWidth.ToString()); gameCanvas.DomCanvas[0].SetAttribute("height", this.engine.canvasHeight.ToString()); jQuery.GetJsonData<JsDictionary<string, SonicImage>>("Content/sprites/sonic.js", data => { sonicSprites = data; }); objectManager = new ObjectManager(this); objectManager.Init(); int scl = 2; Scale = new Point(scl, scl); RealScale = new DoublePoint(1, 1); mainCanvas = gameCanvas; WindowLocation = Constants.DefaultWindowLocation(GameState.Editing, mainCanvas, Scale); BigWindowLocation = Constants.DefaultWindowLocation(GameState.Editing, mainCanvas, Scale); BigWindowLocation.Width = (int)(BigWindowLocation.Width * 1.8); BigWindowLocation.Height = (int)(BigWindowLocation.Height * 1.8); TileAnimations = new List<TileAnimationData>(); AnimationInstances = new List<AnimationInstance>(); //jQuery.GetJson("Content/sprites/explosion.js", data => Animations.Add(new Animation("explosion", data))); ShowHeightMap = false; GoodRing = new Ring(false); ActiveRings = new List<Ring>(); ForceResize = resize; Background = null; CurrentGameState = GameState.Editing; ScreenOffset = new Point(mainCanvas.DomCanvas.GetWidth() / 2 - WindowLocation.Width / 2, mainCanvas.DomCanvas.GetHeight() / 2 - WindowLocation.Height / 2); UIManager = new UIManager.UIManager(this, mainCanvas.Context); ; ClickState = ClickState.PlaceChunk; tickCount = 0; DrawTickCount = 0; InHaltMode = false; waitingForTickContinue = false; waitingForDrawContinue = false; TileChunkDebugDrawOptions = new TileChunkDebugDrawOptions(); }