Esempio n. 1
0
    public bool clicked()
    {
        Vector3 mousePos = CMouse.getPos();

        if (CMouse.release())
        {
            if (CMath.pointInRect(mousePos.x, mousePos.y, getX() - getWidth() / 2, getY() - getHeight() / 2, getWidth(), getHeight()))
            {
                return(true);
            }
        }

        return(false);
    }
Esempio n. 2
0
    public int[] getMouseTile()
    {
        Vector3 mousePos = CMouse.getPos();

        int[] ret = { -1, -1 };

        float minX = matrixBoard[0][0].background.getX() - matrixBoard[0][0].background.getWidth() / 2;
        float maxX = matrixBoard[0][boardWidth - 1].background.getX() + matrixBoard[0][boardWidth - 1].background.getWidth() / 2;
        float minY = matrixBoard[0][0].background.getY() - matrixBoard[0][0].background.getHeight() / 2;
        float maxY = matrixBoard[boardHeight - 1][0].background.getY() + matrixBoard[boardHeight - 1][0].background.getHeight() / 2;


        if (mousePos.x >= minX & mousePos.x <= maxX & mousePos.y >= minY & mousePos.y <= maxY)
        {
            ret[1] = (int)((mousePos.x - minX) / matrixBoard[0][0].background.getWidth());
            ret[0] = (int)((mousePos.y - minY) / matrixBoard[0][0].background.getHeight());
        }
        return(ret);
    }
    public bool nextScreenClick()
    {
        bool clicked = false;

        if (CMouse.firstPress())
        {
            float button1MinX = btnNextScreen.getX() - btnNextScreen.getWidth() / 2;
            float button1MaxX = btnNextScreen.getX() + btnNextScreen.getWidth() / 2;
            float button1MinY = btnNextScreen.getY() - btnNextScreen.getHeight() / 2;
            float button1MaxY = btnNextScreen.getY() + btnNextScreen.getHeight() / 2;
            float mouseX      = CMouse.getPos().x;
            float mouseY      = CMouse.getPos().y;
            if (mouseX >= button1MinX && mouseX <= button1MaxX && mouseY >= button1MinY && mouseY <= button1MaxY)
            {
                clicked = true;
            }
        }

        return(clicked);
    }
    public bool optionsClick()
    {
        bool clicked = false;

        if (CMouse.firstPress())
        {
            float button1MinX = optionsBttn.getX() - optionsBttn.getWidth() / 2;
            float button1MaxX = optionsBttn.getX() + optionsBttn.getWidth() / 2;
            float button1MinY = optionsBttn.getY() - optionsBttn.getHeight() / 2;
            float button1MaxY = optionsBttn.getY() + optionsBttn.getHeight() / 2;
            float mouseX      = CMouse.getPos().x;
            float mouseY      = CMouse.getPos().y;
            if (mouseX >= button1MinX && mouseX <= button1MaxX && mouseY >= button1MinY && mouseY <= button1MaxY)
            {
                clicked = true;
            }
        }

        return(clicked);
    }
Esempio n. 5
0
    public bool exitClick()
    {
        bool clicked = false;

        if (CMouse.firstPress())
        {
            float button1MinX = exit.getX();
            float button1MaxX = exit.getX() + exit.getWidth();
            float button1MinY = exit.getY();
            float button1MaxY = exit.getY() + exit.getHeight();
            float mouseX      = CMouse.getPos().x;
            float mouseY      = CMouse.getPos().y;
            if (mouseX >= button1MinX && mouseX <= button1MaxX && mouseY >= button1MinY && mouseY <= button1MaxY)
            {
                clicked = true;
            }
        }

        return(clicked);
    }
Esempio n. 6
0
    private bool skill2Click()
    {
        bool clicked = false;

        if (CMouse.firstPress())
        {
            float button2MinX = button02.getX() - button02.getWidth() / 2;
            float button2MaxX = button02.getX() + button02.getWidth() / 2;
            float button2MinY = button02.getY() - button02.getHeight();
            float button2MaxY = button02.getY();
            float mouseX      = CMouse.getPos().x;
            float mouseY      = CMouse.getPos().y;
            if (mouseX >= button2MinX && mouseX <= button2MaxX && mouseY >= button2MinY && mouseY <= button2MaxY)
            {
                clicked = true;
            }
        }

        return(clicked);
    }
Esempio n. 7
0
    public override void update()
    {
        base.update();

        float scale = 1.0f;
        int   frame = 1;

        Vector3 mousePos = CMouse.getPos();

        mIsMouseOver = CMath.pointInRect(mousePos.x, mousePos.y, getX() - getWidth() / 2, getY() - getHeight() / 2, getWidth(), getHeight());

        if (CMouse.pressed())
        {
            if (mIsMouseOver)
            {
                scale = 0.9f;
                frame = 2;
            }
        }
        else
        {
            if (mIsMouseOver)
            {
                scale = 1.1f;
                frame = 1;
            }
            else
            {
                scale = 1.0f;
                frame = 1;
            }
        }

        setScale(scale);
        this.buttonText.setScale(scale);

        gotoAndStop(frame);

        this.buttonText.setXY(this.getX(), this.getY());
        this.buttonText.update();
    }
Esempio n. 8
0
    override public void update()
    {
        mAngle += mIncAngle;

        base.update();

        if (CKeyboard.pressed(CKeyboard.KEY_A))
        {
            turnLeft(ROTATION_SPEED);
        }
        if (CKeyboard.pressed(CKeyboard.KEY_D))
        {
            turnRight(ROTATION_SPEED);
        }

        if (CKeyboard.pressed(CKeyboard.KEY_W) /*|| CMouse.pressed()*/)
        {
            float angRad = CMath.degToRad(getRotation());
            setAccelX(500.0f * Mathf.Cos(angRad));
            setAccelY(500.0f * Mathf.Sin(angRad));

            mFire.setVisible(true);
        }
        else
        {
            setAccelX(0.0f);
            setAccelY(0.0f);

            mFire.setVisible(false);
        }

        if (CKeyboard.firstPress(CKeyboard.SPACE) /*|| CMouse.firstPress()*/)
        {
            CPlayerBullet bullet = new CPlayerBullet();

            float angRad = CMath.degToRad(getRotation());
            bullet.setXY(getX() + Mathf.Cos(angRad) * RADIUS, getY() + Mathf.Sin(angRad) * RADIUS);
            bullet.setVelXY(BULLET_SPEED * Mathf.Cos(angRad), BULLET_SPEED * Mathf.Sin(angRad));
            CBulletManager.inst().add(bullet);
        }

        // Friccion.
        setFriction(0.99f);

        float xMouse = CMouse.getPos().x;
        float yMouse = CMouse.getPos().y;

        //Debug.Log ("Mouse: " + xMouse + "," + yMouse);

        // La nave mira al mouse.
        //lookAt(xMouse, yMouse);

        // Bullet Hell.
        if (CKeyboard.pressed(CKeyboard.KEY_G))
        {
            float         angRad2 = CMath.degToRad(mAngle);
            CPlayerBullet bullet2 = new CPlayerBullet();
            bullet2.setXY(getX() + Mathf.Cos(angRad2) * 30.0f, getY() + Mathf.Sin(angRad2) * 30.0f);
            bullet2.setVelXY(400.0f * Mathf.Cos(angRad2), 400.0f * Mathf.Sin(angRad2));
            CBulletManager.inst().add(bullet2);
        }

        // Posicionar el fuego atras de la nave.
        float angFire = CMath.degToRad(getRotation() + 180);

        mFire.setXY(getX() + Mathf.Cos(angFire) * 26.0f, getY() + Mathf.Sin(angFire) * 26.0f);
        mFire.setRotation(getRotation());
        mFire.update();

        CVector a = new CVector(10, 20);
        CVector b = new CVector(-10, -20);
    }