org.newdawn.slick.Animation Java Examples
The following examples show how to use
org.newdawn.slick.Animation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PackedSheetTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST); rocket = sheet.getSprite("rocket"); SpriteSheet anim = sheet.getSpriteSheet("runner"); runner = new Animation(); for (int y=0;y<2;y++) { for (int x=0;x<6;x++) { runner.addFrame(anim.getSprite(x,y), 50); } } }
Example #2
Source File: AnimationTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { this.container = container; SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65); animation = new Animation(); for (int i=0;i<8;i++) { animation.addFrame(sheet.getSprite(i,0), 150); } limited = new Animation(); for (int i=0;i<8;i++) { limited.addFrame(sheet.getSprite(i,0), 150); } limited.stopAt(7); manual = new Animation(false); for (int i=0;i<8;i++) { manual.addFrame(sheet.getSprite(i,0), 150); } pingPong = new Animation(sheet, 0,0,7,0,true,150,true); pingPong.setPingPong(true); container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f)); }
Example #3
Source File: MenuButton.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Creates a new button from an Animation. * @param anim the animation * @param x the center x coordinate * @param y the center y coordinate */ public MenuButton(Animation anim, float x, float y) { this.anim = anim; this.x = x; this.y = y; this.xRadius = anim.getWidth() / 2f; this.yRadius = anim.getHeight() / 2f; }
Example #4
Source File: MenuButton.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Creates a new button from an Animation. * @param anim the animation * @param x the center x coordinate * @param y the center y coordinate */ public MenuButton(Animation anim, float x, float y) { this.anim = anim; this.x = x; this.y = y; this.xRadius = anim.getWidth() / 2f; this.yRadius = anim.getHeight() / 2f; }
Example #5
Source File: SlickCallableTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { image = new Image("testdata/rocket.png"); back = new Image("testdata/sky.jpg"); font = new AngelCodeFont("testdata/hiero.fnt","testdata/hiero.png"); SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65); homer = new Animation(sheet, 0,0,7,0,true,150,true); }
Example #6
Source File: GameData.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * Loads all game score images. */ public void loadImages() { // gameplay-specific images if (isGameplay()) { // combo burst images if (GameImage.COMBO_BURST.hasBeatmapSkinImages() || (!GameImage.COMBO_BURST.hasBeatmapSkinImage() && GameImage.COMBO_BURST.getImages() != null)) comboBurstImages = GameImage.COMBO_BURST.getImages(); else comboBurstImages = new Image[]{ GameImage.COMBO_BURST.getImage() }; // scorebar-colour animation Image[] scorebar = GameImage.SCOREBAR_COLOUR.getImages(); scorebarColour = (scorebar != null) ? new Animation(scorebar, 60) : null; // default symbol images defaultSymbols = new Image[10]; defaultSymbols[0] = GameImage.DEFAULT_0.getImage(); defaultSymbols[1] = GameImage.DEFAULT_1.getImage(); defaultSymbols[2] = GameImage.DEFAULT_2.getImage(); defaultSymbols[3] = GameImage.DEFAULT_3.getImage(); defaultSymbols[4] = GameImage.DEFAULT_4.getImage(); defaultSymbols[5] = GameImage.DEFAULT_5.getImage(); defaultSymbols[6] = GameImage.DEFAULT_6.getImage(); defaultSymbols[7] = GameImage.DEFAULT_7.getImage(); defaultSymbols[8] = GameImage.DEFAULT_8.getImage(); defaultSymbols[9] = GameImage.DEFAULT_9.getImage(); } // score symbol images scoreSymbols = new HashMap<Character, Image>(14); scoreSymbols.put('0', GameImage.SCORE_0.getImage()); scoreSymbols.put('1', GameImage.SCORE_1.getImage()); scoreSymbols.put('2', GameImage.SCORE_2.getImage()); scoreSymbols.put('3', GameImage.SCORE_3.getImage()); scoreSymbols.put('4', GameImage.SCORE_4.getImage()); scoreSymbols.put('5', GameImage.SCORE_5.getImage()); scoreSymbols.put('6', GameImage.SCORE_6.getImage()); scoreSymbols.put('7', GameImage.SCORE_7.getImage()); scoreSymbols.put('8', GameImage.SCORE_8.getImage()); scoreSymbols.put('9', GameImage.SCORE_9.getImage()); scoreSymbols.put(',', GameImage.SCORE_COMMA.getImage()); scoreSymbols.put('.', GameImage.SCORE_DOT.getImage()); scoreSymbols.put('%', GameImage.SCORE_PERCENT.getImage()); scoreSymbols.put('x', GameImage.SCORE_X.getImage()); // hit result images hitResults = new Image[HIT_MAX]; hitResults[HIT_MISS] = GameImage.HIT_MISS.getImage(); hitResults[HIT_50] = GameImage.HIT_50.getImage(); hitResults[HIT_100] = GameImage.HIT_100.getImage(); hitResults[HIT_300] = GameImage.HIT_300.getImage(); hitResults[HIT_100K] = GameImage.HIT_100K.getImage(); hitResults[HIT_300K] = GameImage.HIT_300K.getImage(); hitResults[HIT_300G] = GameImage.HIT_300G.getImage(); hitResults[HIT_SLIDER10] = GameImage.HIT_SLIDER10.getImage(); hitResults[HIT_SLIDER30] = GameImage.HIT_SLIDER30.getImage(); }
Example #7
Source File: Scroller.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer) */ public void init(GameContainer container) throws SlickException { // load the sprites and tiles, note that underneath the texture // will be shared between the sprite sheet and tilemap SpriteSheet sheet = new SpriteSheet("testdata/scroller/sprites.png",32,32); // load the tilemap created the TileD tool map = new TiledMap("testdata/scroller/map.tmx"); // build a collision map based on tile properties in the TileD map blocked = new boolean[map.getWidth()][map.getHeight()]; for (int x=0;x<map.getWidth();x++) { for (int y=0;y<map.getHeight();y++) { int tileID = map.getTileId(x, y, 0); String value = map.getTileProperty(tileID, "blocked", "false"); if ("true".equals(value)) { blocked[x][y] = true; } } } // caculate some layout values for rendering the tilemap. How many tiles // do we need to render to fill the screen in each dimension and how far is // it from the centre of the screen widthInTiles = container.getWidth() / TILE_SIZE; heightInTiles = container.getHeight() / TILE_SIZE; topOffsetInTiles = heightInTiles / 2; leftOffsetInTiles = widthInTiles / 2; // create the player sprite based on a set of sprites from the sheet loaded // above (tank tracks moving) player = new Animation(); for (int frame=0;frame<7;frame++) { player.addFrame(sheet.getSprite(frame,1), 150); } player.setAutoUpdate(false); // update the vector of movement based on the initial angle updateMovementVector(); Log.info("Window Dimensions in Tiles: "+widthInTiles+"x"+heightInTiles); }
Example #8
Source File: MenuButton.java From opsu-dance with GNU General Public License v3.0 | 2 votes |
/** * Returns the associated animation. */ public Animation getAnimation() { return anim; }
Example #9
Source File: Utils.java From opsu-dance with GNU General Public License v3.0 | 2 votes |
/** * Draws an animation based on its center. * @param anim the animation to draw * @param x the center x coordinate * @param y the center y coordinate */ public static void drawCentered(Animation anim, float x, float y) { anim.draw(x - (anim.getWidth() / 2f), y - (anim.getHeight() / 2f)); }
Example #10
Source File: MenuButton.java From opsu with GNU General Public License v3.0 | 2 votes |
/** * Returns the associated animation. */ public Animation getAnimation() { return anim; }
Example #11
Source File: Utils.java From opsu with GNU General Public License v3.0 | 2 votes |
/** * Draws an animation based on its center. * @param anim the animation to draw * @param x the center x coordinate * @param y the center y coordinate */ public static void drawCentered(Animation anim, float x, float y) { anim.draw(x - (anim.getWidth() / 2f), y - (anim.getHeight() / 2f)); }