Esempio n. 1
0
        override public void update()
        {
            // Tilemaps can be collided just like any other FlxObject, and flixel
            // automatically collides each individual tile with the object.
            FlxG.collide(player, collisionMap);

            highlightBox.X = (float)Math.Floor(FlxG.mouse.cursor.X / TILE_WIDTH) * TILE_WIDTH;
            highlightBox.Y = (float)Math.Floor(FlxG.mouse.cursor.Y / TILE_HEIGHT) * TILE_HEIGHT;

            if (FlxG.mouse.pressed())
            {
                // FlxTilemaps can be manually edited at runtime as well.
                // Setting a tile to 0 removes it, and setting it to anything else will place a tile.
                // If auto map is on, the map will automatically update all surrounding tiles.
                collisionMap.setTile((uint)FlxG.mouse.x / TILE_WIDTH, (uint)FlxG.mouse.y / TILE_HEIGHT, (uint)(FlxG.keys.pressed(Keys.LeftShift) ? 0 : 1));
            }

            updatePlayer();
            if (FlxG.keys.justPressed(Keys.Escape))
            {
                onQuit();
            }
            base.update();
        }
Esempio n. 2
0
        override public void update()
        {
            //Toggle the bounding box visibility
            if (FlxG.keys.justPressed(Microsoft.Xna.Framework.Input.Keys.B))
            {
                FlxG.showBounds = !FlxG.showBounds;
            }


            if (FlxG.mouse.pressedRightButton())
            {
                tiles.setTile((int)FlxG.mouse.x / 16, (int)FlxG.mouse.y / 16, 0, true);
            }
            if (FlxG.mouse.pressedLeftButton())
            {
                tiles.setTile((int)FlxG.mouse.x / 16, (int)FlxG.mouse.y / 16, 1, true);
            }

            int tile = tiles.getTile((int)FlxG.mouse.x / 16, (int)FlxG.mouse.y / 16);

            FlxG.setHudTextScale(1, 3);
            FlxG.setHudText(1, "The tile index you are hovering over is: " + tile.ToString());



            base.update();

            //Put the collide after base.update() to avoid flickering.
            FlxU.collide(spaceShip, tiles);

            int velValue = 500;

            if (FlxG.keys.A)
            {
                spaceShip.velocity.X = velValue * -1;
            }
            else if (FlxG.keys.D)
            {
                spaceShip.velocity.X = velValue;
            }
            else if (FlxG.keys.W)
            {
                spaceShip.velocity.Y = velValue * -1;
            }
            else if (FlxG.keys.S)
            {
                spaceShip.velocity.Y = velValue;
            }
            if (FlxG.keys.Z)
            {
                spaceShip.angle -= 5;
            }
            else if (FlxG.keys.X)
            {
                spaceShip.angle += 5;
            }
            else if (FlxG.keys.SPACE)
            {
                spaceShip.thrust = 500;
            }
            else if (FlxG.keys.L)
            {
                spaceShip.play("Transform");
                //FlxG.bloom.Visible = true;
            }
            else
            {
                spaceShip.thrust = 0;
            }
        }