Beispiel #1
0
        private void KeyUp(KeyUpMessage m, GameEngine engine)
        {
            if(m.Key == Keys.P)
            {
                PerlinNoise perlinNoise = new PerlinNoise(99);
                Bitmap bitmap = new Bitmap(200, 200);
                double widthDivisor = 1 / (double)200;
                double heightDivisor = 1 / (double)200;
                bitmap.SetEachPixelColour(
                    (point, color) =>
                    {
                        double v =
                            // First octave
                            (perlinNoise.Noise(2 * point.X * widthDivisor, 2 * point.Y * heightDivisor, -0.5) + 1) / 2 * 0.7 +
                            // Second octave
                            (perlinNoise.Noise(4 * point.X * widthDivisor, 4 * point.Y * heightDivisor, 0) + 1) / 2 * 0.2 +
                            // Third octave
                            (perlinNoise.Noise(8 * point.X * widthDivisor, 8 * point.Y * heightDivisor, +0.5) + 1) / 2 * 0.1;

                        v = Math.Min(1, Math.Max(0, v));
                        byte b = (byte)(v * 255);
                        return Color.FromArgb(b, b, b);
                    });
                bitmap.Save("test.png", ImageFormat.Png);
            }
            if(m.Key == Keys.G)
            {

            }
        }
Beispiel #2
0
 private void KeyUp(KeyUpMessage m, GameEngine engine)
 {
     engine.Bus.Add(new SystemMessage(engine.Timer.LastTickTime, "{0} KeyUp - {1}".fmt(m.TimeSent, m.Key)));
     if (m.Key == Keys.Escape)
     {
         engine.Stop();
     }
 }
Beispiel #3
0
 public void Start(GameEngine engine)
 {
     Bus.Add(new SystemMessage(engine.Timer.LastTickTime, "VoxelRTS Graphics starting."));
     using (var p = new VoxelRTSWindow(engine))
     {
         p.LoadView(typeof(VoxelGreen), new VoxelGreenView());
         p.LoadView(typeof(Planet), new PlanetView());
         p.LoadView(typeof(TopMenu), new TopMenuView(p));
         p.Run();
     }
 }
Beispiel #4
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));
        }
Beispiel #5
0
 public void Start(GameEngine engine)
 {
     Bus.Add(new SystemMessage(engine.Timer.LastTickTime,"Sound Starting."));
 }
Beispiel #6
0
 public IdleState(GameEngine engine)
 {
     _engine = engine;
 }
Beispiel #7
0
 public MainMenuState(GameEngine engine)
 {
     _engine = engine;
 }
Beispiel #8
0
 public void Initialise(GameEngine engine)
 {
     throw new System.NotImplementedException();
 }
Beispiel #9
0
 public TopMenuState(GameEngine engine)
 {
     _engine = engine;
 }
Beispiel #10
0
 private void Setup(GameEngine engine)
 {
     engine.Timer.Subscribe(t =>
     {/*
        * foreach (var item in engine.MapItems().OfType<TempItem>())
         {
             Console.WriteLine(item.ToString());
         }*/
     });
 }
Beispiel #11
0
 public TestGameState(GameEngine engine)
 {
     _engine = engine;
 }