Example #1
0
 protected GameContext(Graphics ctx)
 {
     _loop     = RenderLoop.Create(ctx, Scene.Update);
     _isLoaded = false;
 }
Example #2
0
        private static void Main(string[] args)
        {
            Application.Run(() =>
            {
                // Create spatial collection
                Spatial = new BoundingTreeSpatialCollection <ISpatialObject>();

                //
                Pipes = new PipeManager();

                // Create entities collection
                _entities       = new TypeDictionary <Entity>();
                _removeEntities = new HashSet <Entity>();
                _addEntities    = new HashSet <Entity>();

                // Create the game window
                Window = new Window("Superfluid!");
                Window.Graphics.EnableFPSOverlay = true;
                Window.Maximize();

                // Bind Input
                Input.AttachToWindow(Window);

                // Load BGM
                Music           = new AudioSource(Files.OpenStream("assets/music/4222-pixelland-by-kevin-macleod.mp3"));
                Music.IsLooping = true;
                Music.Play();

                // Load game assets
                Assets.LoadDatabase();

                PackImageAtlas();

                // Center origins on assets prefixed by string given
                Assets.SetImagesCenterOrigin("crosshair102", "particle");
                Assets.SetImagesCenterOrigin("alien", "slime"); // alienpink_walk1, etc

                // Setup the cursors
                var cursorImage = Assets.GetImage("crosshair102");
                HealCursor      = CreateImageClone(cursorImage, Color.Green);
                KillCursor      = CreateImageClone(cursorImage, Color.Red);
                Window.SetCursor(KillCursor); // ...

                // Load the background image
                Background = Assets.GetImage("colored_desert");

                //
                _elapsedTime = 0;

                // Create the player actor
                Player = AddEntity(new Player());
                Player.Transform.Position = (200, 300);

                // Load the test map
                LoadMap(StageNames[StageIndex]);

                // Create main loop
                Loop = RenderLoop.Create(Window.Graphics, OnUpdate);
                Loop.Start();
            });
        }