⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awtinput.java

📁 一个java的免费游戏引擎,里面有文档,和例子
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

package com.golden.gamedev.engine.input;

import com.golden.gamedev.engine.BaseInput;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.PrintStream;

public class AWTInput
    implements BaseInput
{

    private Component a;
    private InputListener b;
    private int c;
    private int d;
    private int e;
    private int f;
    private int g;
    private int h;
    private boolean i;
    private boolean j;
    private boolean k[];
    private int l;
    private int m;
    private boolean n[];
    private int o;
    private int p;

    public AWTInput(Component component)
    {
        a = component;
        a.requestFocus();
        b = createInputListener();
        a.addKeyListener(b);
        a.addMouseListener(b);
        a.addMouseMotionListener(b);
        a.addFocusListener(b);
        i = true;
        j = true;
        k = new boolean[4];
        l = m = 0x80000000;
        n = new boolean[255];
        o = p = 0x80000000;
        c = d = e = f = g = h = 0;
        try
        {
            DisplayMode displaymode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
            c = e = displaymode.getWidth() / 2 - 10;
            d = f = displaymode.getHeight() / 2 - 10;
            (new Robot()).mouseMove(c, d);
        }
        catch(Throwable _ex) { }
        component.setFocusTraversalKeysEnabled(false);
    }

    protected InputListener createInputListener()
    {
        return new InputListener();
    }

    public void update(long l1)
    {
        l = m = 0x80000000;
        g = c - e;
        h = d - f;
        e = c;
        f = d;
        o = p = 0x80000000;
    }

    public void refresh()
    {
        for(int i1 = 0; i1 < 4; i1++)
            k[i1] = false;

        l = m = 0x80000000;
        g = h = 0;
        for(int j1 = 0; j1 < 255; j1++)
            n[j1] = false;

        o = p = 0x80000000;
    }

    public void cleanup()
    {
        a.removeKeyListener(b);
        a.removeMouseListener(b);
        a.removeMouseMotionListener(b);
        a.removeFocusListener(b);
        return;
        printStackTrace();
    }

    public void mouseMove(int i1, int j1)
    {
        try
        {
            (new Robot()).mouseMove(i1, j1);
            return;
        }
        catch(Exception _ex)
        {
            System.err.println("WARNING: Can't move the mouse pointer to " + i1 + ", " + j1);
        }
    }

    public boolean isMouseExists()
    {
        return i;
    }

    public int getMouseX()
    {
        return c;
    }

    public int getMouseY()
    {
        return d;
    }

    public int getMouseDX()
    {
        return g;
    }

    public int getMouseDY()
    {
        return h;
    }

    public void setMouseVisible(boolean flag)
    {
        if(j != flag)
        {
            j = flag;
            if(!flag)
            {
                Toolkit toolkit;
                Dimension dimension;
                if((dimension = (toolkit = Toolkit.getDefaultToolkit()).getBestCursorSize(1, 1)).width == 0 || dimension.height == 0)
                    dimension.width = dimension.height = 1;
                BufferedImage bufferedimage = new BufferedImage(dimension.width, dimension.height, 2);
                Cursor cursor = toolkit.createCustomCursor(bufferedimage, new Point(0, 0), "null");
                a.setCursor(cursor);
                return;
            }
            a.setCursor(Cursor.getDefaultCursor());
        }
    }

    public boolean isMouseVisible()
    {
        return j;
    }

    public int getMouseReleased()
    {
        return m;
    }

    public boolean isMouseReleased(int i1)
    {
        return m == i1;
    }

    public int getMousePressed()
    {
        return l;
    }

    public boolean isMousePressed(int i1)
    {
        return l == i1;
    }

    public boolean[] getMouseDown()
    {
        return k;
    }

    public boolean isMouseDown(int i1)
    {
        return k[i1];
    }

    public int getKeyReleased()
    {
        return p;
    }

    public boolean isKeyReleased(int i1)
    {
        return p == i1;
    }

    public int getKeyPressed()
    {
        return o;
    }

    public boolean isKeyPressed(int i1)
    {
        return o == i1;
    }

    public boolean[] getKeyDown()
    {
        return n;
    }

    public boolean isKeyDown(int i1)
    {
        return n[i1 & 0xff];
    }

    public Component getComponent()
    {
        return a;
    }

    static boolean[] a(AWTInput awtinput)
    {
        return awtinput.n;
    }

    static int b(AWTInput awtinput, int i1)
    {
        return awtinput.o = i1;
    }

    static int c(AWTInput awtinput, int i1)
    {
        return awtinput.p = i1;
    }

    static boolean d(AWTInput awtinput, boolean flag)
    {
        return awtinput.i = flag;
    }

    static boolean[] e(AWTInput awtinput)
    {
        return awtinput.k;
    }

    static int f(AWTInput awtinput, int i1)
    {
        return awtinput.l = i1;
    }

    static int g(AWTInput awtinput)
    {
        return awtinput.l;
    }

    static int h(AWTInput awtinput, int i1)
    {
        return awtinput.m = i1;
    }

    static int i(AWTInput awtinput)
    {
        return awtinput.m;
    }

    static int j(AWTInput awtinput, int i1)
    {
        return awtinput.c = i1;
    }

    static int k(AWTInput awtinput, int i1)
    {
        return awtinput.d = i1;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -