Beispiel #1
0
 public void RenderScene(Scene scene, GameView view)
 {
     if (LightEnabled)
         RenderWithEffects(scene, view);
     else
         RenderWithoutEffects(scene, view);
 }
Beispiel #2
0
        public Game(GameSettings settings, Scene scene, Application app)
        {
            App = app;

            Settings = settings;
            TickInterval = settings.TickInterval;

            Scene = scene;
            Scene.Camera.LockOffset = Settings.CameraLockOffset;
            Scene.PhysicsQuality = Settings.PhysicsQuality;
            Scene.Camera.ReactionSpeed = Settings.CameraSpeed;
            Scene.Gravity = Settings.Gravity;
            if (Settings.PhysicsStaticResistance != 0)
                Scene.Physics.StaticResistance = Settings.PhysicsStaticResistance;

            View = new GameView();
            if (!String.IsNullOrEmpty(Settings.Background))
            {
                var bgTexture = ResourceManager.GetTexture(Settings.Background);
                bgTexture.Repeated = true;
                View.Background = bgTexture;
            }

            View.SpriteSet = Settings.Textures
                .ToDictionary(kv => kv.Key, kv => new Sprite(ResourceManager.GetTexture(kv.Value)));
            View.SpriteSet[0] = new Sprite();

            logicLock = new Mutex();
            KeysPressed = new HashSet<Keyboard.Key>();

            timer = new System.Timers.Timer(TickInterval);
            timer.Elapsed += Act;
            timer.AutoReset = true;

            Listener.GlobalVolume = 100;
            Listener.Direction = new Vector3f(1, 0, 0);

            render = new Render(App.Window, App.Settings.EnableLights);
        }
Beispiel #3
0
        private void RenderWithoutEffects(Scene scene, GameView view)
        {
            var cameraOffset = scene.Camera.Body.Position - new Vector2f(Window.Size.X, Window.Size.Y) / 2;

            Window.Clear();

            if (view.Background != ResourceManager.DefaultTexture)
                DrawBackground(Window, view.Background, scene.Camera.Body.Position);

            DrawObjects(Window, scene, view.SpriteSet, cameraOffset);

            if (scene.Camera.IsAllSeeingEye)
                DrawGrid(Window, scene, cameraOffset);

            Window.Display();
        }
Beispiel #4
0
        private void RenderWithEffects(Scene scene, GameView view)
        {
            var cameraOffset = scene.Camera.Body.Position - new Vector2f(Window.Size.X, Window.Size.Y) / 2;

            Window.Clear();
            DrawLights(Window, scene, cameraOffset, LightMode.Backlight);

            frame.Clear();
            if (view.Background != ResourceManager.DefaultTexture)
                DrawBackground(frame, view.Background, scene.Camera.Body.Position);
            DrawObjects(frame, scene, view.SpriteSet, cameraOffset);
            frame.Display();

            var state = new RenderStates(BlendMode.Multiply);
            Window.Draw(new Sprite(frame.Texture), state);

            DrawLights(Window, scene, cameraOffset, LightMode.Flashlight);
            DrawParticles(Window, scene, cameraOffset);

            if (scene.Camera.IsAllSeeingEye)
                DrawGrid(Window, scene, cameraOffset);

            Window.Display();
        }