Ucigame - Gallery - FoiledAgain

Home | Getting Started | Reference | Introduction to Java | Gallery

Your browser cannot show Java applets. Move the cursor over the program area to see how the cursor image changes in response to its position. In the top half the cursor will display based on the custom image in images/cursor1.png. In the bottom half, the cursor takes on one of many standard alternatives.

FoiledAgain.java
import ucigame.*;

public class FoiledAgain extends Ucigame
{
    Image cursorImage;

    public void setup()
    {
        window.size(250, 250);
        window.title("Curses, Foiled Again");
        framerate(20);

        cursorImage = getImage("images/cursor1.png", 192);

        canvas.background(200, 100, 255);
    }

    public void draw()
    {
        canvas.clear();

        if (mouse.y() < 125)
            mouse.setCursor(cursorImage, 16, 16);
        else if (mouse.x() < 20)
            mouse.setCursor(mouse.DEFAULT);
        else if (mouse.x() < 40)
            mouse.setCursor(mouse.CROSSHAIR);
        else if (mouse.x() < 60)
            mouse.setCursor(mouse.HAND);
        else if (mouse.x() < 80)
            mouse.setCursor(mouse.MOVE);
        else if (mouse.x() < 100)
            mouse.setCursor(mouse.TEXT);
        else if (mouse.x() < 120)
            mouse.setCursor(mouse.WAIT);
        else if (mouse.x() < 140)
            mouse.setCursor(mouse.N_RESIZE);
        else if (mouse.x() < 160)
            mouse.setCursor(mouse.E_RESIZE);
        else if (mouse.x() < 180)
            mouse.setCursor(mouse.S_RESIZE);
        else if (mouse.x() < 200)
            mouse.setCursor(mouse.W_RESIZE);
        else if (mouse.x() < 220)
            mouse.setCursor(mouse.NE_RESIZE);
        else if (mouse.x() < 230)
            mouse.setCursor(mouse.NW_RESIZE);
        else if (mouse.x() < 240)
            mouse.setCursor(mouse.SE_RESIZE);
        else if (mouse.x() < 250)
            mouse.setCursor(mouse.SW_RESIZE);
    }
}