Beispiel #1
0
        public void Update(InputHandle input)
        {
            if (input.getKey(Keys.RightControl).pressed) { stack = !stack; }

            if ((input.getKey(Keys.Up).pressed || (input.getKey(Keys.Up).down && input.getKey(Keys.LeftShift).down)) && position.Z > 0)
                position.Z--;
            if ((input.getKey(Keys.Down).pressed || (input.getKey(Keys.Down).down && input.getKey(Keys.LeftShift).down)) && position.Z < VoxelManager.MAX_Z - 1)
                position.Z++;
            if ((input.getKey(Keys.Left).pressed || (input.getKey(Keys.Left).down && input.getKey(Keys.LeftShift).down)) && position.X > 0)
                position.X--;
            if ((input.getKey(Keys.Right).pressed || (input.getKey(Keys.Right).down && input.getKey(Keys.LeftShift).down)) && position.X < VoxelManager.MAX_X - 1)
                position.X++;

            if (stack) { position.Y = manager.FindTopSpace((int)position.X, (int)position.Z); }
            else
            {
                if (input.getKey(Keys.PageUp).pressed && position.Y < VoxelManager.MAX_Y - 1) { position.Y++; }
                if (input.getKey(Keys.PageDown).pressed && position.Y > 0) { position.Y--; }
            }

            light.position = position;
            toCreate.position = position;
            toCreate.ForceVerticeUpdate();

            if (input.getKey(Keys.RightShift).pressed)
            {
                manager.lights.Add(new Light(position, 10));
            }

            if (input.getKey(Keys.Space).pressed && position.Y != -1)
            {
                manager.Add(toCreate);
                bool test = TextureManager.containsAlpha(texture);
                toCreate = new Voxel(manager, position, TextureManager.getTexture(texture), TextureManager.containsAlpha(texture), TextureManager.isCube(texture), texture == "torch");
            }

            if (input.getKey(Keys.P).pressed) //clear map
            {
                manager.Clear();
            }

            if (input.getKey(Keys.OemPeriod).pressed)
            {
                texture_index++;
                if (texture_index >= textures.Count()) { texture_index = 0; }
                toCreate.texture = TextureManager.getTexture(texture);
                toCreate.alpha = TextureManager.containsAlpha(texture);
                toCreate.cube = TextureManager.isCube(texture);
            }
            if (input.getKey(Keys.OemComma).pressed)
            {
                texture_index--;
                if (texture_index < 0) { texture_index = textures.Count()-1; }
                toCreate.texture = TextureManager.getTexture(texture);
                toCreate.alpha = TextureManager.containsAlpha(texture);
                toCreate.cube = TextureManager.isCube(texture);
            }
        }
Beispiel #2
0
        public void Update(InputHandle input)
        {
            if (input.getKey(Keys.Left).down)
            {
                velocity.X -= acceleration;
            }

            position += velocity;
        }
Beispiel #3
0
        public void Update(InputHandle input)
        {
            if (input.getKey(Keys.A).down)
            {
                position.X -= 0.5f;
                lookToPosition.X -= 0.5f;
            }

            if (input.getKey(Keys.D).down)
            {
                position.X += 0.5f;
                lookToPosition.X += 0.5f;
            }

            if (input.getKey(Keys.W).down)
            {
                position.Z -= 0.5f;
                lookToPosition.Z -= 0.5f;
            }

            if (input.getKey(Keys.S).down)
            {
                position.Z += 0.5f;
                lookToPosition.Z += 0.5f;
            }

            if (input.leftMouseDown)
            {
                distance--;
                position = lookToPosition + new Vector3(0, (float)(distance * Math.Cos(angle)), (float)(distance * Math.Sin(angle)));
            }
            if (input.rightMouseDown)
            {
                distance++;
                position = lookToPosition + new Vector3(0, (float)(distance * Math.Cos(angle)), (float)(distance * Math.Sin(angle)));
            }
        }