private void setCountdownImage(int count) { try { countdown = new Image(Resource.getPath(count + ".png")); } catch (SlickException ex) { logger.error("Could not get countdownImage " + count + ".png: " + ex.getMessage()); } }
public ArrayList<Obstacle> update( float timePerFrame, float toCenterX, float toCenterY, float attract) { super.update(timePerFrame, toCenterX, toCenterY, attract); ArrayList<Obstacle> spawnedObstacles = new ArrayList<Obstacle>(); this.getImg().setRotation((float) (180 * this.getPolarPhi() / Math.PI)); this.timeFromLastSpawn += timePerFrame; if (timeFromLastSpawn >= timeBetweenSpawns) { timeFromLastSpawn = 0; try { spawnedObstacles.add( new PowerupHealth( this.getCenterX(), this.getCenterY(), 1, GlobalSettings.getGlobalSpeed(), new Image("res/images/lol.png"))); System.out.println("health-powerup spawned"); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return spawnedObstacles; }
@Override public void init(GameContainer container, StateBasedGame game) throws SlickException { super.init(container, game); try { // Get our background this.setBackground(new Image(BCKGRND_IMG)); // Add platforms this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(200, 450))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(400, 400))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(600, 300))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(810, 350))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(850, 350))); this.addPlatform(new Platform(new Image(PLATFORM_IMGC), new Vector2f(1140, 300))); this.addPlatform(new Platform(new Image(PLATFORM_IMGC), new Vector2f(1175, 300))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(1720, 400))); this.addPlatform(new Platform(new Image(PLATFORM_IMGC), new Vector2f(2000, 400))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(2450, 400))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(2510, 400))); this.addPlatform(new Platform(new Image(PLATFORM_IMGW), new Vector2f(2600, 450))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG), new Vector2f(0, 580))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG2), new Vector2f(900, 580))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG4), new Vector2f(1300, 580))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG2), new Vector2f(1800, 580))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG2), new Vector2f(2200, 580))); this.addPlatform(new Platform(new Image(MAIN_PLATFORM_IMG4), new Vector2f(2800, 580))); } catch (SlickException e) { e.printStackTrace(); } }
/** * Move the player automatically forwards, as well as (optionally) in a given direction. Prevents * the player from moving onto blocking terrain, or outside of the screen (camera) bounds. * * @param world The world the player is on (to check blocking). * @param cam The current camera (to check blocking). * @param dir_x The player's movement in the x axis (-1, 0 or 1). * @param dir_y The player's movement in the y axis (-1, 0 or 1). * @param delta Time passed since last frame (milliseconds). * @throws SlickException */ public void update( int delta, double dir_x, double dir_y, boolean missile, World world, Camera cam) throws SlickException { /* Calculate the amount to move in each direction, based on speed */ double amount = delta * getSpeed(); /* The new location */ double x = this.x + dir_x * amount; double y = this.y + dir_y * amount; if (!world.reachedTop()) y -= delta * getAutoSpeed(); // Check if the player is off the screen, and push back in if (x < cam.getLeft()) x = cam.getLeft(); if (x > cam.getRight() - 1) x = cam.getRight() - 1; if (y - 36 < cam.getTop()) y = cam.getTop() + 36; if (y + 36 + 68 > cam.getBottom() - 1) y = cam.getBottom() - 1 - 36 - 68; moveto(world, x, y, false); // Test that the player has not been bumped off the edge of the game if (world.terrainBlocks(this.x, this.y) && world.terrainBlocks(this.x, this.y - 1)) this.damage(9999); timeFromLast += delta; // Fires a missile if needed if (missile && timeFromLast > cooldown - firepower * firepowerLimit) { Image sprite = null; try { sprite = new Image(Game.ASSETS_PATH + "/units/missile-player.png"); } catch (SlickException e) { e.printStackTrace(); } world.addMissile(new Missile(10, -0.7, this.x, this.y - 50, sprite, true, true)); timeFromLast = 0; } }
public Screen(World world, int w, int h, float scale) { this.w = (int) (w / scale); this.h = (int) (h / scale); screenRegion = new Rectangle(0, 0, w, h); charSprites = new CharSprite[new File("res/img/chars").listFiles().length]; tileSprites = new TileSprite[new File("res/img/tiles").listFiles().length]; File[] charFiles = new File("res/img/chars").listFiles(); File[] tileFiles = new File("res/img/tiles").listFiles(); for (int i = 0; i < charSprites.length; i++) { try { charSprites[i] = new CharSprite(charFiles[i].getName()); } catch (SlickException e) { e.printStackTrace(); } } for (int i = 0; i < tileSprites.length; i++) { try { tileSprites[i] = new TileSprite(tileFiles[i].getName()); } catch (SlickException e) { e.printStackTrace(); } } }
public Skill( String name, int cd, int range, double speed, int aoe, int cost, int damage, StatusEffect SE) { this.name = name; cooldown = cd; this.range = range; areaOfEffect = aoe; this.cost = cost; this.damage = damage; spellEffect = SE; attackRange = range; if (speed < 100) { attSpeed = speed; } else { isProjectile = false; } // Backup image if it doesn't get one set by the extended skillClass try { attackImage = new Image("res/awesomeGreenSquare.png"); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } setImage(attackImage, 5, 4); }
public static void main(String[] args) { try { stateManager = new StateManager(); } catch (SlickException e) { e.printStackTrace(); } }
public void start() { try { container.start(); } catch (final SlickException e) { e.printStackTrace(); } }
public Menu(int state) { try { song = new Music("res/music/Somtin.wav"); } catch (SlickException e) { e.printStackTrace(); } }
public Lightning(float x, float y, String i, World world) { super(x, y, i, world); int numFrames = 4; Image sheet; try { sheet = new Image("assets/Art/Transformations/Animations/lightning.png"); projectileWidth = sheet.getWidth() / numFrames; projectileHeight = sheet.getHeight(); SpriteSheet ss = new SpriteSheet(sheet, projectileWidth, projectileHeight); projectileRightAnimation = new Animation(ss, 100); projectileRightAnimation.stopAt(projectileRightAnimation.getFrameCount() - 1); ss = new SpriteSheet(ss.getFlippedCopy(true, false), projectileWidth, projectileHeight); projectileLeftAnimation = new Animation(ss, 100); projectileLeftAnimation.stopAt(projectileLeftAnimation.getFrameCount() - 1); } catch (SlickException e) { e.printStackTrace(); } damage = 3; projectileRange = 600; projectileXVelocity = 3; dropChance = false; startUpTime = .01; reloadTime = 800; projectileOffsets = new Rectangle(10, 10, 20, 20); }
public Bullet( float x, float y, float manx, float many, int id, boolean moving, Player player, Human human) { angle = Math.atan2(y - many, x - manx); this.moving = moving; if (this.moving) { this.x = manx; this.y = many; } if (!this.moving) { this.x = x; this.y = y; } originX = manx; originY = many; this.human = human; this.player = player; this.ENTITYID = id; try { image = new Image("res/bullet.png"); image.setFilter(Image.FILTER_NEAREST); } catch (SlickException e) { e.printStackTrace(); } }
public GameOver() { try { this.background = new Image("res/titlescreen.png"); } catch (SlickException e) { e.printStackTrace(); } }
public ItemGun( String name, String texture, String gih, String description, int damage, int firerate, Sound onfire) { super(name, texture, description); this.damage = damage; this.firerate = firerate; try { this.gih = new Image(gih); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.onFire = onfire; if (onFire == null) { onFire = Sound1 .gun1; // might be the gun sound file? no it was working when i had it set in entity // play also its not printing playing in the console } }
@Override public void Update() { if (explodeTime < 0) { exploded = true; for (Bomb b : Game.getInstance().playground().getBombs()) { if (b == this) { Game.getInstance().playground().removeBombs1(b); } } for (Bomb b : Game.getInstance().playground().getBombs2()) { if (b == this) { Game.getInstance().playground().removeBombs2(b); } } try { createFlames(); } catch (SlickException ex) { ex.printStackTrace(); } } explodeTime--; ArrayList<Player> players = Game.getInstance().getAllPlayers(); for (Player p : players) { if (intersects(p)) { if (!moving) { // p.setKick(true); if (p.getKick() && isKicked == false) { kickBomb(p.getKickDirection()); } } } } }
private void initFont() { try { font = new SimpleFont("Courier New", Font.BOLD, 18); } catch (SlickException e) { e.printStackTrace(); } }
public void render(GameContainer arg0, StateBasedGame arg1, Graphics g) throws SlickException { g.drawString("Choose your Vehicle", 240, 30); try { base = new Image("sideView/base.png"); turret = new Image("sideView/turret.png"); gun = new Image("sideView/gun.png"); plane = new Image("sideView/plan.png"); boat = new Image("sideView/boat.png"); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (base != null) { base = base.getScaledCopy(3); turret = turret.getScaledCopy(3); gun = gun.getScaledCopy(3); plane = plane.getScaledCopy(3); boat = boat.getScaledCopy(3); g.drawImage(base, 50, 50); g.drawImage(turret, 150, 50); g.drawImage(gun, 250, 50); g.drawImage(plane, 350, 50); g.drawImage(boat, 450, 50); } }
static { try { typeSound = new Sound("sound/typing.wav"); } catch (SlickException ignore) { ignore.printStackTrace(); } }
public static void main(String[] args) { try { new Main().start(); } catch (final SlickException e) { e.printStackTrace(); } }
@SuppressWarnings("unchecked") public GameOver(String text, int score, boolean victory) { this.text = text; this.score = score; this.victory = victory; font = new UnicodeFont(Database.instance().getDefaultFont().getFont(), 50, true, false); font.addAsciiGlyphs(); font.getEffects().add(new ColorEffect()); try { font.loadGlyphs(); } catch (SlickException e1) { e1.printStackTrace(); } nameInput = new TextField( GameCore.getInstance().getApp(), Database.instance().getDefaultFont(), 150, 20, 500, Database.instance().getDefaultFont().getLineHeight() + 20, new ComponentListener() { public void componentActivated(AbstractComponent source) { input = nameInput.getText(); } }); nameInput.setFocus(true); nameInput.setBorderColor(Color.black); nameInput.setText("Anonymous"); nameInput.setMaxLength(20); }
public EntityRPKBullet(float x, float y, boolean dir) { super(x, y, dir, 65); try { this.texture = new Image("me/NB/gamtests/GUI/GIH/RPKBullet.png"); } catch (SlickException e) { e.printStackTrace(); } }
@Override public void run() { try { this.listen(); } catch (SlickException e) { e.printStackTrace(); } }
private void enterStateAndreinit(int stateID) { try { game.getState(stateID).init(game.getContainer(), game); } catch (SlickException e) { e.printStackTrace(); } game.enterState(stateID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); }
public FallingBlockView() { fallingBlock = null; try { fallingBlock = new Image("res/fallingBlock.png"); } catch (SlickException e) { e.printStackTrace(); } }
@Override protected Player initPlayer() { try { return new Player(new Image(PLAYER_IMG), new Vector2f(20, 500), 100); } catch (SlickException e) { e.printStackTrace(); return null; } }
public Circle(float x, float y, float radius) { super(x, y); this.radius = radius; try { img = new Image("res/earth2.png"); } catch (SlickException e) { e.printStackTrace(); } }
/** * Entry point to our test * * @param argv The arguments to pass into the test */ public static void main(String[] argv) { try { AppGameContainer container = new AppGameContainer(new DistanceFieldTest()); container.setDisplayMode(800, 600, false); container.start(); } catch (SlickException e) { e.printStackTrace(); } }
/** * Initialize the classes resources. All other methods in this class and a flag keep track so this * method is automatically if it hasn't been called yet. */ public static void init() { if (error_img != null) return; error_img = null; try { error_img = new Image("res/images/error.png"); } catch (SlickException e) { e.printStackTrace(); } }
@Override public void place(float x, float y) { try { entityCreator.createNewEntity(TypeEnum.RHINOBOT, x, y); } catch (SlickException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static void main(String args[]) { try { AppGameContainer app = new AppGameContainer(new OOWorld()); app.setDisplayMode(800, 600, false); app.start(); app.setVSync(false); } catch (SlickException e) { e.printStackTrace(); } }
public MapRender(Map m) { try { map = new Image(DataDirs.MapsDir.path + m.getName() + "/map.png"); map_offset_x = -(m.getWidthInTiles() * (TILE_DIMENSIONS[0] / 2)) + Display.getWidth() / 2; map_offset_y = Display.getHeight() / 2; } catch (SlickException e) { System.err.println("Could not load image of map " + m.getName()); e.printStackTrace(); } }