Exemplo n.º 1
0
    private CTile getMouseTile()
    {
        int col = (int)(CMouse.getX() / CTileMap.Instance.getTileWidth());
        int row = (int)(CMouse.getY() / CTileMap.Instance.getTileHeight());

        return(CTileMap.Instance.getTile(col, row));
    }
Exemplo n.º 2
0
    //Es como un manager de tiles
    public void update()
    {
        //Si la iteracion no pasa el maximo se repite
        for (int y = 0; y < MAP_HEIGHT; y++)
        {
            //Si la iteracion no pasa el maximo se repite
            for (int x = 0; x < MAP_WIDTH; x++)
            {
                //se update los tiles a medida que cambie
                mMap[y][x].update();
            }
        }
        int   col  = (int)(CMouse.getX() / TILE_WIDTH);
        int   row  = (int)(CMouse.getY() / TILE_HEIGHT);
        CTile tile = getTile(col, row);

        if (tile != null)
        {
            if (CMouse.firstPress())
            {
                int index = tile.getTileIndex();
                if (index == 0)
                {
                    tile.setTileIndex(1);
                    tile.setImage(mTiles[1]);
                }
                else if (index == 1)
                {
                    tile.setTileIndex(0);
                    tile.setImage(mTiles[0]);
                }
            }
        }
    }
Exemplo n.º 3
0
    override protected void rightClickPower()
    {
        int direction = 1;



        if (CMouse.getX() <= player.getX() + player.getWidth() / 2)
        {
            direction = -1;
            player.setFlip(true);
        }
        else
        {
            player.setFlip(false);
        }

        player.setState(CAndy.STATE_DASHING);
        player.setVelX(DASH_VELOCITY * direction);
    }
Exemplo n.º 4
0
    override protected void leftClickPower()
    {
        AireDisparo bullet = new AireDisparo();
        //La direcion de la bala
        CVector playerCenter = new CVector(player.getX() + player.getWidth() / 2, player.getY() + player.getHeight() / 2);
        float   radius       = player.getHeight() > player.getWidth() ? player.getHeight() / 2 : player.getWidth() / 2;
        float   xDiff        = CMouse.getX() - playerCenter.x;
        float   yDiff        = CMouse.getY() - playerCenter.y;
        float   angRad       = Mathf.Atan2(yDiff, xDiff);

        bullet.setRotation(CMath.radToDeg(angRad));
        // X: Centro del personaje + ancho / 2 * angulo
        bullet.setX(playerCenter.x + radius * Mathf.Cos(angRad));
        // Y: Centro del personaje + alto / 2 * angulo
        bullet.setY(playerCenter.y + radius * Mathf.Sin(angRad));
        bullet.setVelXY(AireDisparo.SPEED * Mathf.Cos(angRad), AireDisparo.SPEED * Mathf.Sin(angRad));
        bullet.setBounds(0, 0, CTileMap.Instance.getMapWidth() * CTileMap.Instance.getTileWidth(), CTileMap.Instance.getMapHeight() * CTileMap.Instance.getTileHeight());
        CBulletManager.inst().add(bullet);
    }
Exemplo n.º 5
0
    public void update()
    {
        for (int y = 0; y < MAP_HEIGHT; y++)
        {
            for (int x = 0; x < MAP_WIDTH; x++)
            {
                mMap [y] [x].update();
            }
        }

        int   col  = (int)(CMouse.getX() / TILE_WIDTH);
        int   row  = (int)(CMouse.getY() / TILE_HEIGHT);
        CTile tile = getTile(col, row);

        //Aca TENGO LO DEL EL CLICK PARA LOS PODERES

        /*
         * if (tile != null)
         *      {
         *              if (CMouse.firstPress())
         *              {
         *                      int index = tile.getTileIndex ();
         *                      if (index == 0)
         *                      {
         *                              tile.setTileIndex (1);
         *                              tile.setImage (mTiles[3]);
         *                      }
         *
         *                      else if (index == 1)
         *                      {
         *                              tile.setTileIndex(0);
         *                              tile.setImage(mTiles[0]);
         *                      }
         *              }
         *
         *      }
         *
         */
    }
Exemplo n.º 6
0
    override protected void rightClickPower()
    {
        int   col  = (int)(CMouse.getX() / CTileMap.Instance.getTileWidth());
        int   row  = (int)(CMouse.getY() / CTileMap.Instance.getTileHeight());
        CTile tile = CTileMap.Instance.getTile(col, row);

        if (tile == null)
        {
            return;
        }

        CTile topTile = tile.getNeighbourTile(CTile.Direction.TOP);

        if (tile.getTileType() == CTile.Type.WATER && topTile.getTileType() == CTile.Type.AIR && iceTileCounter < MAX_ICE_TILES)
        {
            CTileMap.Instance.changeTile(tile, CTile.Type.ICE);
            iceTileCounter++;
        }
        else if (tile.getTileType() == CTile.Type.ICE && topTile.getTileType() == CTile.Type.AIR && iceTileCounter > 0)
        {
            CTileMap.Instance.changeTile(tile, CTile.Type.WATER);
            iceTileCounter--;
        }
    }
Exemplo n.º 7
0
    public void update()
    {
        for (int y = 0; y < MAP_HEIGHT; y++)
        {
            for (int x = 0; x < MAP_WIDTH; x++)
            {
                mMap [y] [x].update();


                // RUNNER
                //mMap[y][x].setVelX(-400);
            }
        }

        int   col  = (int)(CMouse.getX() / TILE_WIDTH);
        int   row  = (int)(CMouse.getY() / TILE_HEIGHT);
        CTile tile = getTile(col, row);

        if (tile != null)
        {
            if (CMouse.firstPress())
            {
                int index = tile.getTileIndex();
                if (index == 0)
                {
                    tile.setTileIndex(1);
                    tile.setImage(mTiles[1]);
                }
                else if (index == 1)
                {
                    tile.setTileIndex(0);
                    tile.setImage(mTiles[0]);
                }
            }
        }
    }