Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Andre on 16.01.2017.
- */
- import org.newdawn.slick.*;
- public class Game extends BasicGame
- {
- private Animation a;
- public Game() throws SlickException {
- super("HTL-RUN");
- }
- public static void main(String[] args) throws SlickException {
- AppGameContainer container = new AppGameContainer(new
- Game());
- //Fenster mit 1024 x 786 im Fenstermodus (false)
- container.setDisplayMode(1024, 768, false);
- container.start();
- }
- public Animation getAnimation ( Image i , int spritesX, int spritesY , int spriteWidth , int spriteHeight, int frames, int duration )
- {
- Animation a = new Animation(false);
- int c = 0;
- for( int y = 0 ; y < spritesY; y++)
- {
- for( int x = 0 ; x < spritesX; x++)
- {
- if( c < frames ) a.addFrame( i.getSubImage(x*spriteWidth, y*spriteHeight, spriteWidth, spriteHeight), duration);
- c++;
- }
- }
- return a;
- }
- public void init(GameContainer gc) throws SlickException {
- Image i = new Image("res/dude_animation_sheet.png");
- a = getAnimation ( i, 5 , 4 , 130, 150, 27, 100 );
- }
- public void render(GameContainer gc, Graphics g) throws SlickException {
- a.draw(410, 330);
- }
- public void update(GameContainer gc, int delta) throws SlickException {
- a.update(delta);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement