@Override public void processKeysDown(IntSet keysDown) { IntSet.IntSetIterator iter = keysDown.iterator(); int key; while(iter.hasNext) { key = iter.next(); if(key==Config.Keys.UP[0] || key==Config.Keys.UP[1]) { player.axisY(1f); } else if (key==Config.Keys.DOWN[0] || key==Config.Keys.DOWN[1]) { player.axisY(-1f); } else if (key==Config.Keys.LEFT[0] || key==Config.Keys.LEFT[1]) { player.axisX(-1f); } else if (key==Config.Keys.RIGHT[0] || key==Config.Keys.RIGHT[1]) { player.axisX(1f); } else if (key==Config.Keys.JUMP[0] || key==Config.Keys.JUMP[1]) { player.jump = true; } else if (key==Config.Keys.QUIT[0] || key==Config.Keys.QUIT[1]) { Gdx.app.exit(); } } }
/** Utility. * * @param parser parses template. * @param actor contains the listener. * @param rawAttributeData unparsed attribute data. * @param keys handled keys set. */ public static void processKeysAttribute(final LmlParser parser, final Actor actor, final String rawAttributeData, final IntSet keys) { final String[] keyNames = parser.parseArray(rawAttributeData, actor); for (final String keyName : keyNames) { final int key = Keys.valueOf(keyName); if (key <= Keys.UNKNOWN) { if (Strings.isInt(keyName)) { keys.add(Integer.parseInt(keyName)); } else { parser.throwErrorIfStrict("Unable to determine key for name: " + keyName + ". Note that key name should match the EXACT name from Keys class (see Keys#valueOf(String)) or be the desired int value of key code."); } } else { keys.add(key); } } }
public CaveGenerator(int x, int z, SmoothWorld smoothWorld) { this.caveStartX = x; this.caveStartY = smoothWorld.getSurfaceHeight(x, z); this.caveStartZ = z; this.smoothWorld = smoothWorld; long l = x + z + (x * (x - 1)) + (z * (z + 1)) + (long) Math.pow(x, z > 0 ? z : (z < 0 ? -z : 1)); this.numbers = new RandomXS128(smoothWorld.baseSeed, murmurHash3(smoothWorld.baseSeed + murmurHash3(l))); this.intSet = new IntSet(roomNodesMax); }
@Override public void write(Kryo kryo, Output output, IntSet set) { output.writeVarInt(set.size, true); IntSet.IntSetIterator iter = set.iterator(); while (iter.hasNext) { output.writeInt(iter.next()); } }
@Override public IntSet read(Kryo kryo, Input input, Class<IntSet> type) { int length = input.readVarInt(true); IntSet array = new IntSet(length); for (int i = 0; i < length; i++) { array.add(input.readInt()); } return array; }
/** * Sandbox method for getting the entity under the mouse-pointer. * * @return entity under mousep-ointer */ public int getEntityAtMouse() { Vector2 mousePos = getMousePos(); Tile t = getTile(Math.round(mousePos.x), Math.round(mousePos.y)); if (t.getEntities().size == 0) return -1; IntSet.IntSetIterator iterator = t.getEntities().iterator(); ComponentMapper<StatComponent> statMapper = arcadeWorld.getEntityWorld().getMapper(StatComponent.class); while (iterator.hasNext) { int entity = iterator.next(); if (statMapper.has(entity)) return entity; } return -1; }
public void setOffsetID(int[] offset) { IntSet a = new IntSet(offset.length); for(int o : offset) { if(o > 0 && o < SkinProperty.OFFSET_MAX + 1) { a.add(o); } } if(a.size > 0) { this.offset = a.iterator().toArray().toArray(); this.off = new SkinOffset[this.offset.length]; } }
@Override public void processKeysTyped(IntSet keys) { IntSet.IntSetIterator iter = keys.iterator(); int key; while(iter.hasNext) { key = iter.next(); if (key==Config.Keys.XRAY[0]) { Config.WIREFRAME = !Config.WIREFRAME; } } }
public InputHandler() { Gdx.input.setInputProcessor(this); Gdx.input.setCatchBackKey(true); updateScreenDimensions(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); inputObjects = new ArrayList<>(); keysDown = new IntSet(); touchList = new IntMap<>(); garbage = new ArrayList<>(); }
@Override protected void process(final LmlParser parser, final AbstractListenerLmlTag tag, final ActorStorage actor, final String rawAttributeData) { if (!(tag instanceof InputListenerLmlTag)) { parser.throwErrorIfStrict("'keys' attribute can be used only for input listeners."); return; } final IntSet keys = ((InputListenerLmlTag) tag).getKeys(); processKeysAttribute(parser, actor, rawAttributeData, keys); }
@Override protected Actor getNewInstanceOfActor(final LmlActorBuilder builder) { keys = new IntSet(); listener = new KeysListener(keys) { @Override protected void handleEvent(final Actor actor) { doOnEvent(actor); } }; return super.getNewInstanceOfActor(builder); }
public CompleteEvaluator(TaflBoard board) { tempBitBoard = new BitBoard(board.boardSize); allPiecesBoard = new BitBoard(board.boardSize); cornerProtection = new BitBoard(board.boardSize); for (int element : board.boardType.barricades) { cornerProtection.set(element); } int half = board.dimensions / 2; north = new BitBoard(board.boardSize); south = new BitBoard(board.boardSize); east = new BitBoard(board.boardSize); west = new BitBoard(board.boardSize); for (int i = 0; i < board.dimensions; i++) { for (int j = 0; j < board.dimensions; j++) { if (i < half) { south.set(i * board.dimensions + j); } else if (i > half) { north.set(i * board.dimensions + j); } if (j < half) { west.set(i * board.dimensions + j); } else if (j > half) { east.set(i * board.dimensions + j); } } } barricadeStack = new IntArray(); barricadeSet = new IntSet(); moves = new Array<Move>(Constants.GameConstants.DRAW_MOVE_THRESHHOLD); }
public Tile(int x, int y) { this.x = x; this.y = y; traversable = true; entities = new IntSet(); }
public TileSet(int mapWidth) { this.mapWidth = mapWidth; set = new IntSet(); array = new PositionArray(); }
/** @return direct reference to handled keys. * @see #addKey(int) */ public IntSet getKeys() { return keys; }
/** @param keys supported keys. */ public KeysListener(final IntSet keys) { this.keys = keys; }
/** @return direct reference to internal set of blocked indexes. */ public IntSet getBlockedIndexes() { return blockedIndexes; }
/** * For handling keys currently held down. * @param keysDown Array of keys held down. */ public void processKeysDown(IntSet keysDown);
/** * For handling keys that were pressed and then released. * @param keysTyped Array of keys pressed and released. */ public void processKeysTyped(IntSet keysTyped);