Example #1
0
        public OpenTKWindow(GameEngine engine)
            : base(800, 600, new GraphicsMode(32, 24, 0, 2), "ORTS.Test")
        {
            VSync = VSyncMode.Off;
            Views= new ConcurrentDictionary<Type,IGameObjectView>();
            this.Engine = engine;

            this.Engine.Bus.OfType<LoadObjectView>().Subscribe(m => Views.TryAdd(m.GameObjectType,m.View));
            KeyMap map = new KeyMap();

            Keyboard.KeyDown += (object sender, KeyboardKeyEventArgs e) => {
                this.Engine.Bus.Add(new KeyDown(this.Engine.Timer.LastTickTime, map.Do(e.Key)));
            };
            Keyboard.KeyUp += (object sender, KeyboardKeyEventArgs e) => {
                this.Engine.Bus.Add(new KeyUp(this.Engine.Timer.LastTickTime, map.Do(e.Key)));
            };

            Mouse.WheelChanged += (object sender, MouseWheelEventArgs e) => {
                camera.Translate(new Vect3(0,0,-e.DeltaPrecise));
            };

            engine.Bus.Add(new GraphicsLoadedMessage(engine.Timer.LastTickTime));

            camera = new Camera();
            camera.Translate(new Vect3(0, 0, 30));
        }
Example #2
0
        public VoxelRTSWindow(GameEngine engine)
            : base(1280, 720, new GraphicsMode(32, 24, 0, 1), "ORTS.Test")
        {
            VSync = VSyncMode.Off;
            Views= new ConcurrentDictionary<Type,IGameObjectView>();
            Engine = engine;

            Engine.Bus.OfType<GraphicsDirtyMessage>().Subscribe(m => _graphicsDirty = true);

            var map = new KeyMap();
            Keyboard.KeyDown += (sender, e) => Engine.Bus.Add(new KeyDownMessage(Engine.Timer.LastTickTime, map.Match(e.Key)));
            Keyboard.KeyUp += (sender, e) => Engine.Bus.Add(new KeyUpMessage(Engine.Timer.LastTickTime, map.Match(e.Key)));
            Mouse.WheelChanged += (sender, e) => Camera.Translate(new Vect3(0,0,-e.DeltaPrecise));

            Camera = new Camera();
            Camera.Translate(new Vect3(0, 0, 30));
            engine.Bus.Add(new GraphicsLoadedMessage(engine.Timer.LastTickTime));
        }