private void handleCollisions() { for (int i = 0; i < enemyList.size(); i++) { Enemy enemy = enemyList.get(i); guy.enemyCollision(enemy); for (int j = 0; j < tileList.size(); j++) { Tile tile = tileList.get(j); TileType type = tile.tileType(); if (type == TileType.TILE_TOP || type == TileType.TILE_TOP_RIGHT || type == TileType.TILE_TOP_LEFT) { guy.tileCollision(tile); enemy.tileCollision(tile); } else if (type == TileType.TILE_FLAG) { guy.flagCollision(tile); } } } }
public void restart() { currentState = GameState.READY; guy.restart(); scrollHandler.restart(); for (int i = 0; i < enemyList.size(); i++) { enemyList.get(i).restart(); } for (int i = 0; i < tileList.size(); i++) { tileList.get(i).restart(); } }
public void updateRunning(float delta) { guy.update(delta); for (int i = 0; i < enemyList.size(); i++) { enemyList.get(i).update(delta, gameWidth); } for (int i = 0; i < tileList.size(); i++) { tileList.get(i).update(delta); } scrollHandler.update(delta); checkIfGameWon(); checkIfAlive(); handleCollisions(); }