• 大小: 2.23MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-09
  • 语言: Java
  • 标签: 魔塔  java  

资源简介

便宜实惠

资源截图

代码片段和文件信息

package me.deathjockey.tod;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import java.util.List;

public class InputHandler implements KeyListener {

public class Key {
public int presses absorbs;
public boolean down pressed;

public Key() {
keys.add(this);
}

public void toggle(boolean pressed) {
if(pressed != down)  {
down = pressed;
}
if(pressed) {
presses++;
}
}

public void tick() {
if(absorbs < presses) {
absorbs++;
pressed = true;
} else {
pressed = false;
}
}
}

public List keys = new ArrayList();

public Key up = new Key();
public Key down = new Key();
public Key left = new Key();
public Key right = new Key();
public Key enter = new Key();
public Key use_rod = new Key();
public Key cursor_up = new Key();
public Key cursor_down = new Key();
public Key confirm = new Key();
public Key escape = new Key();

public InputHandler(TowerComponent game) {
game.addKeyListener(this);
}

@Override
public void keyPressed(KeyEvent e) {
toggle(e true);
}

@Override
public void keyReleased(KeyEvent e) {
toggle(e false);
}

@Override
public void keyTyped(KeyEvent e) {

}

public void toggle(KeyEvent ke boolean pressed) {
int k = ke.getKeyCode();
if(k == KeyEvent.VK_UP) up.toggle(pressed);
if(k == KeyEvent.VK_DOWN) down.toggle(pressed);
if(k == KeyEvent.VK_LEFT) left.toggle(pressed);
if(k == KeyEvent.VK_RIGHT) right.toggle(pressed);

if(k == KeyEvent.VK_W) up.toggle(pressed);
if(k == KeyEvent.VK_S) down.toggle(pressed);
if(k == KeyEvent.VK_A) left.toggle(pressed);
if(k == KeyEvent.VK_D) right.toggle(pressed);

if(k == KeyEvent.VK_2) cursor_up.toggle(pressed);
if(k == KeyEvent.VK_8) cursor_down.toggle(pressed);
if(k == KeyEvent.VK_SPACE) confirm.toggle(pressed);
if(k == KeyEvent.VK_ESCAPE) escape.toggle(pressed);
if(k == KeyEvent.VK_ENTER) enter.toggle(pressed);

if(k == KeyEvent.VK_L) use_rod.toggle(pressed);
}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\
     文件         545  2012-12-24 09:09  Tower-of-the-Deathmaster-master\.classpath
     文件         383  2012-12-24 09:09  Tower-of-the-Deathmaster-master\.project
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\.settings\
     文件         587  2012-12-24 09:09  Tower-of-the-Deathmaster-master\.settings\org.eclipse.jdt.core.prefs
     文件        1083  2012-12-24 09:09  Tower-of-the-Deathmaster-master\README.md
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\
     文件        1000  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\InputHandler$Key.class
     文件        2170  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\InputHandler.class
     文件         844  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\Towerapplet.class
     文件        7753  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\TowerComponent.class
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\dy\
     文件        9576  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\dy\DynamicsLoader.class
     文件        1824  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\dy\xmlFile.class
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\
     文件        1351  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Combat.class
     文件        4148  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Door.class
     文件        4184  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Entity.class
     文件        3685  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Item.class
     文件        3100  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Level.class
     文件        1627  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\NPC.class
     文件        6037  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Player.class
     文件        2469  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Shop.class
     文件        1579  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Stairs.class
     文件        2218  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\level\Tile.class
     目录           0  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\screen\
     文件        3293  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\screen\Art.class
     文件        3060  2012-12-24 09:09  Tower-of-the-Deathmaster-master\bin\me\deathjockey\tod\screen\Bitmap.class
............此处省略66个文件信息

评论

共有 条评论