Esempio n. 1
0
  @Override
  public void init(GameContainer gameContainer, StateBasedGame stateBasedGame)
      throws SlickException {
    this.stateBasedGame = stateBasedGame;

    center =
        new Dimension(
            AsaGame.SOURCE_RESOLUTION.width / 2 - 100, AsaGame.SOURCE_RESOLUTION.height / 2);

    resetGame();

    tandwiel1 = new Image(Resource.getPath(Resource.TANDWIEL5));
    tandwiel2 = new Image(Resource.getPath(Resource.TANDWIEL6));
    spinner = new Image(Resource.getPath(Resource.SPINNER));
    spinneroverlay = new Image(Resource.getPath(Resource.SPINNER_OVERLAY));
    background_spinner = new Image(Resource.getPath(Resource.BACKGROUND_SPINNER));
    background_spinner_half = new Image(Resource.getPath(Resource.BACKGROUND_SPINNER_HALF));
    background_spinner_half.setAlpha(0.7f);
    background = new Image(Resource.getPath(Resource.GAME_BACKGROUND));
    selectImage = new Image(Resource.getPath(Resource.SAVE_SCORE));
    choise = new Image(Resource.getPath(Resource.MAKE_YOUR_CHOISE));

    fontBlack = Resource.getFont(Resource.FONT_SANCHEZ, 30, Color.BLACK);

    lens = new Animation();
    lens.setLooping(false);
    for (int i = 0; i < 33; i++) {
      if ((i + "").length() == 1) {
        lens.addFrame(new Image(Resource.getPath("LENS/lens1_0000" + i + ".png")), 550 / 33);
      } else if ((i + "").length() == 2) {
        lens.addFrame(new Image(Resource.getPath("LENS/lens1_000" + i + ".png")), 550 / 33);
      }
    }
    lens.stop();
  }
Esempio n. 2
0
  private void initializeAssets() throws SlickException {
    // Maps anlegen
    maps.put(0, "Testmap.tmx");
    // Sheet für die Bilder der Animation anlegen + Bilder zur Animation
    // hinzufügen
    playerSheet = new SpriteSheet("res/animations/character_top.png", 130, 120);
    playerTop = new Animation();
    for (int col = 0; col < 15; ++col) {
      playerTop.addFrame(playerSheet.getSprite(col, 0), 80);
    }

    playerSide = new Animation();
    playerSide.addFrame(new Image("res/animations/character_side.png"), 80);
  }
Esempio n. 3
0
/*     */   public Animation(SpriteSheet frames, int x1, int y1, int x2, int y2, boolean horizontalScan, int duration, boolean autoUpdate)
/*     */   {
/* 144 */     this.autoUpdate = autoUpdate;
/*     */ 
/* 146 */     if (!horizontalScan) {
/* 147 */       for (int x = x1; x <= x2; x++) {
/* 148 */         for (int y = y1; y <= y2; y++)
/* 149 */           addFrame(frames.getSprite(x, y), duration);
/*     */       }
/*     */     }
/*     */     else
/* 153 */       for (int y = y1; y <= y2; y++)
/* 154 */         for (int x = x1; x <= x2; x++)
/* 155 */           addFrame(frames.getSprite(x, y), duration);
/*     */   }
Esempio n. 4
0
/*     */   public Animation(Image[] frames, int duration, boolean autoUpdate)
/*     */   {
/*  91 */     for (int i = 0; i < frames.length; i++) {
/*  92 */       addFrame(frames[i], duration);
/*     */     }
/*  94 */     this.currentFrame = 0;
/*  95 */     this.autoUpdate = autoUpdate;
/*     */   }
Esempio n. 5
0
/*     */   public Animation(SpriteSheet ss, int[] frames, int[] duration)
/*     */   {
/* 168 */     this.spriteSheet = ss;
/* 169 */     int x = -1;
/* 170 */     int y = -1;
/*     */ 
/* 172 */     for (int i = 0; i < frames.length / 2; i++) {
/* 173 */       x = frames[(i * 2)];
/* 174 */       y = frames[(i * 2 + 1)];
/* 175 */       addFrame(duration[i], x, y);
/*     */     }
/*     */   }
Esempio n. 6
0
/*     */   public Animation(Image[] frames, int[] durations, boolean autoUpdate)
/*     */   {
/* 107 */     this.autoUpdate = autoUpdate;
/* 108 */     if (frames.length != durations.length) {
/* 109 */       throw new RuntimeException("There must be one duration per frame");
/*     */     }
/*     */ 
/* 112 */     for (int i = 0; i < frames.length; i++) {
/* 113 */       addFrame(frames[i], durations[i]);
/*     */     }
/* 115 */     this.currentFrame = 0;
/*     */   }
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {

    gc.setTargetFrameRate(60);

    gc.setShowFPS(false);

    // *******************

    // Scenerey Stuff

    // ****************
    grassMap = new TiledMap("res/coral.tmx");
    // grassMap = new TiledMap("res/coral.tmx");

    // Ongoing checks are useful

    System.out.println("Tile map is this wide: " + grassMap.getWidth());

    camera = new Camera(gc, grassMap);

    // *********************************************************************************

    // Player stuff --- these things should probably be chunked into methods
    // and classes

    // *********************************************************************************

    SpriteSheet runningSS = new SpriteSheet("res/skeletonpritesheet.png", 64, 64, 0);

    // System.out.println("Horizontal count: "
    // +runningSS.getHorizontalCount());

    // System.out.println("Vertical count: " +runningSS.getVerticalCount());

    up = new Animation();

    up.setAutoUpdate(true);

    up.addFrame(runningSS.getSprite(0, 8), 330);

    up.addFrame(runningSS.getSprite(1, 8), 330);

    up.addFrame(runningSS.getSprite(2, 8), 330);

    up.addFrame(runningSS.getSprite(3, 8), 330);

    up.addFrame(runningSS.getSprite(4, 8), 330);

    up.addFrame(runningSS.getSprite(5, 8), 330);

    up.addFrame(runningSS.getSprite(6, 8), 330);

    up.addFrame(runningSS.getSprite(7, 8), 330);

    up.addFrame(runningSS.getSprite(8, 8), 330);

    down = new Animation();

    down.setAutoUpdate(false);

    down.addFrame(runningSS.getSprite(0, 10), 330);

    down.addFrame(runningSS.getSprite(1, 10), 330);

    down.addFrame(runningSS.getSprite(2, 10), 330);

    down.addFrame(runningSS.getSprite(3, 10), 330);

    down.addFrame(runningSS.getSprite(4, 10), 330);

    down.addFrame(runningSS.getSprite(5, 10), 330);

    down.addFrame(runningSS.getSprite(6, 10), 330);

    down.addFrame(runningSS.getSprite(7, 10), 330);

    down.addFrame(runningSS.getSprite(8, 10), 330);

    left = new Animation();

    left.setAutoUpdate(false);

    left.addFrame(runningSS.getSprite(0, 9), 330);

    left.addFrame(runningSS.getSprite(1, 9), 330);

    left.addFrame(runningSS.getSprite(2, 9), 330);

    left.addFrame(runningSS.getSprite(3, 9), 330);

    left.addFrame(runningSS.getSprite(4, 9), 330);

    left.addFrame(runningSS.getSprite(5, 9), 330);

    left.addFrame(runningSS.getSprite(6, 9), 330);

    left.addFrame(runningSS.getSprite(7, 9), 330);

    left.addFrame(runningSS.getSprite(8, 9), 330);

    right = new Animation();

    right.setAutoUpdate(false);

    right.addFrame(runningSS.getSprite(0, 11), 330);

    right.addFrame(runningSS.getSprite(1, 11), 330);

    right.addFrame(runningSS.getSprite(2, 11), 330);

    right.addFrame(runningSS.getSprite(3, 11), 330);

    right.addFrame(runningSS.getSprite(4, 11), 330);

    right.addFrame(runningSS.getSprite(5, 11), 330);

    right.addFrame(runningSS.getSprite(6, 11), 330);

    right.addFrame(runningSS.getSprite(7, 11), 330);

    right.addFrame(runningSS.getSprite(8, 11), 330);

    wait = new Animation();

    wait.setAutoUpdate(true);

    wait.addFrame(runningSS.getSprite(0, 14), 733);

    wait.addFrame(runningSS.getSprite(1, 14), 733);

    wait.addFrame(runningSS.getSprite(2, 14), 733);

    wait.addFrame(runningSS.getSprite(3, 14), 733);

    // wait.addFrame(runningSS.getSprite(2, 14), 733);

    // wait.addFrame(runningSS.getSprite(5, 14), 333);

    sprite = wait;

    // *****************************************************************

    // Obstacles etc.

    // build a collision map based on tile properties in the TileD map

    Blocked.blocked = new boolean[grassMap.getWidth()][grassMap.getHeight()];

    // System.out.println("Map height:" + grassMap.getHeight());

    // System.out.println("Map width:" + grassMap.getWidth());

    // There can be more than 1 layer. You'll check whatever layer has the
    // obstacles.

    // You could also use this for planning traps, etc.

    // System.out.println("Number of tile layers: "
    // +grassMap.getLayerCount());

    System.out.println("The grassmap is " + grassMap.getWidth() + "by " + grassMap.getHeight());

    for (int xAxis = 0; xAxis < grassMap.getWidth(); xAxis++) {

      for (int yAxis = 0; yAxis < grassMap.getHeight(); yAxis++) {

        // int tileID = grassMap.getTileId(xAxis, yAxis, 0);

        // Why was this changed?

        // It's a Different Layer.

        // You should read the TMX file. It's xml, i.e.,human-readable
        // for a reason

        int tileID = grassMap.getTileId(xAxis, yAxis, 1);

        String value = grassMap.getTileProperty(tileID, "blocked", "false");

        if ("true".equals(value)) {

          System.out.println("The tile at x " + xAxis + " andy axis " + yAxis + " is blocked.");

          Blocked.blocked[xAxis][yAxis] = true;
        }
      }
    }

    System.out.println("Array length" + Blocked.blocked[0].length);

    // A remarkably similar process for finding hostiles

    hostiles = new boolean[grassMap.getWidth()][grassMap.getHeight()];

    /*		for (int xAxis = 0; xAxis < grassMap.getWidth(); xAxis++) {
    			for (int yAxis = 0; yAxis < grassMap.getHeight(); yAxis++) {
    				int xBlock = (int) xAxis;
    				int yBlock = (int) yAxis;
    				if (!Blocked.blocked[xBlock][yBlock]) {
    					if (yBlock % 7 == 0 && xBlock % 15 == 0 ) {
    						Item i = new Item(xAxis * SIZE, yAxis * SIZE);
    						stuff.add(i);
    						//stuff1.add(h);
    						hostiles[xAxis][yAxis] = true;
    					}
    				}
    			}
    		}
                    for (int xAxis = 0; xAxis < grassMap.getWidth(); xAxis++) {
    			for (int yAxis = 0; yAxis < grassMap.getHeight(); yAxis++) {
    				int xBlock = (int) xAxis;
    				int yBlock = (int) yAxis;
    				if (!Blocked.blocked[xBlock][yBlock]) {
    					if (yBlock % 7 == 0 && xBlock % 15 == 0 ) {
    						Item i = new Item(xAxis * SIZE, yAxis * SIZE);
    						stuff.add(i);
    						//stuff1.add(h);
    						hostiles[xAxis][yAxis] = true;
    					}
    				}
    			}
    		}
    */

    // healthpotion = new Item(100, 100);
    // healthpotion1 = new Item(450, 400);
    // stuff.add(healthpotion);
    // stuff.add(healthpotion1);

    // stormy = new Ninja(0,0);
    // daniel = new Ninja(124,254);
    // dojo.add(stormy);
    // dojo.add(daniel);

    flava = new Enemy(1500, 2500);
    flav = new Enemy(1000, 1000);
    bonez.add(flava);
    bonez.add(flav);

    bone1 = new Bone(655, 70);
    bone2 = new Bone(1750, 800);
    doghouse.add(bone1);
    doghouse.add(bone2);

    // speedpotion = new Item1(100,150);
    // speedpotion1 = new Item1(450,100);
    // stuff1.add(speedpotion);
    // stuff1.add(speedpotion1);

    //		antidote = new Itemwin(3004,92);
    //		stuffwin.add(antidote);

    BoneMaker.Makethebones();
  }
Esempio n. 8
0
  Enemy(int a, int b) throws SlickException {

    Bx = a;

    By = b;

    hitboxX = this.getskhitboxX();

    hitboxY = this.getskhitboxY();
    rect = new Rectangle(hitboxX, hitboxY, width, height);

    int BHealth;

    boolean isBAlive = true;

    canmove = true;

    currentanime = skwait;

    id = ++numberOfEnemies;

    this.mydirection = Direction.WAIT;

    SpriteSheet skeletonSS = new SpriteSheet("res/enemy.png", 64, 64, 0);

    skup = new Animation();

    skup.setAutoUpdate(true);

    skup.addFrame(skeletonSS.getSprite(0, 8), 75);

    skup.addFrame(skeletonSS.getSprite(1, 8), 75);

    skup.addFrame(skeletonSS.getSprite(2, 8), 75);

    skup.addFrame(skeletonSS.getSprite(3, 8), 75);

    skup.addFrame(skeletonSS.getSprite(4, 8), 75);

    skup.addFrame(skeletonSS.getSprite(5, 8), 75);

    skup.addFrame(skeletonSS.getSprite(6, 8), 75);

    skup.addFrame(skeletonSS.getSprite(7, 8), 75);

    skup.addFrame(skeletonSS.getSprite(8, 8), 75);

    skdown = new Animation();

    skdown.setAutoUpdate(false);

    skdown.addFrame(skeletonSS.getSprite(0, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(1, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(2, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(3, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(4, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(5, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(6, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(7, 10), 75);

    skdown.addFrame(skeletonSS.getSprite(8, 10), 75);

    skleft = new Animation();

    skleft.setAutoUpdate(false);

    skleft.addFrame(skeletonSS.getSprite(0, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(1, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(2, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(3, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(4, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(5, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(6, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(7, 9), 75);

    skleft.addFrame(skeletonSS.getSprite(8, 9), 75);

    skright = new Animation();

    skright.setAutoUpdate(false);

    skright.addFrame(skeletonSS.getSprite(0, 11), 75);

    skright.addFrame(skeletonSS.getSprite(1, 11), 75);

    skright.addFrame(skeletonSS.getSprite(2, 11), 75);

    skright.addFrame(skeletonSS.getSprite(3, 11), 75);

    skright.addFrame(skeletonSS.getSprite(4, 11), 75);

    skright.addFrame(skeletonSS.getSprite(5, 11), 75);

    skright.addFrame(skeletonSS.getSprite(6, 11), 75);

    skright.addFrame(skeletonSS.getSprite(7, 11), 75);

    skright.addFrame(skeletonSS.getSprite(8, 11), 75);

    skwait = new Animation();

    skwait.setAutoUpdate(true);

    skwait.addFrame(skeletonSS.getSprite(0, 14), 75);

    skwait.addFrame(skeletonSS.getSprite(1, 14), 75);

    skwait.addFrame(skeletonSS.getSprite(2, 14), 75);

    skwait.addFrame(skeletonSS.getSprite(3, 14), 75);

    skdead = new Animation();

    skdead.setAutoUpdate(false);

    skdead.addFrame(skeletonSS.getSprite(2, 20), 75);

    skdead.addFrame(skeletonSS.getSprite(3, 20), 75);

    skdead.addFrame(skeletonSS.getSprite(4, 20), 75);

    skdead.addFrame(skeletonSS.getSprite(5, 20), 75);

    currentanime = skwait;
  }
Esempio n. 9
0
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {

    gc.setTargetFrameRate(60);

    gc.setShowFPS(false);

    // *******************

    // Scenerey Stuff

    // ****************

    forestMap = new TiledMap("res/agivens_4_map.tmx");

    // Ongoing checks are useful

    System.out.println("Tile map is this wide: " + forestMap.getWidth());

    camera = new Camera(gc, forestMap);

    // *********************************************************************************

    // Player stuff --- these things should probably be chunked into methods
    // and classes

    // *********************************************************************************

    SpriteSheet proMoving = new SpriteSheet("res/ProtagonistSpriteSheet.png", 64, 64, 0);

    // System.out.println("Horizontal count: "
    // +runningSS.getHorizontalCount());

    // System.out.println("Vertical count: " +runningSS.getVerticalCount());

    proup = new Animation();

    proup.setAutoUpdate(true);

    proup.addFrame(proMoving.getSprite(0, 8), 330);

    proup.addFrame(proMoving.getSprite(1, 8), 330);

    proup.addFrame(proMoving.getSprite(2, 8), 330);

    proup.addFrame(proMoving.getSprite(3, 8), 330);

    proup.addFrame(proMoving.getSprite(4, 8), 330);

    proup.addFrame(proMoving.getSprite(5, 8), 330);

    proup.addFrame(proMoving.getSprite(6, 8), 330);

    proup.addFrame(proMoving.getSprite(7, 8), 330);

    proup.addFrame(proMoving.getSprite(8, 8), 330);

    prodown = new Animation();

    prodown.setAutoUpdate(false);

    prodown.addFrame(proMoving.getSprite(0, 10), 330);

    prodown.addFrame(proMoving.getSprite(1, 10), 330);

    prodown.addFrame(proMoving.getSprite(2, 10), 330);

    prodown.addFrame(proMoving.getSprite(3, 10), 330);

    prodown.addFrame(proMoving.getSprite(4, 10), 330);

    prodown.addFrame(proMoving.getSprite(5, 10), 330);

    prodown.addFrame(proMoving.getSprite(6, 10), 330);

    prodown.addFrame(proMoving.getSprite(7, 10), 330);

    prodown.addFrame(proMoving.getSprite(8, 10), 330);

    proleft = new Animation();

    proleft.setAutoUpdate(false);

    proleft.addFrame(proMoving.getSprite(0, 9), 330);

    proleft.addFrame(proMoving.getSprite(1, 9), 330);

    proleft.addFrame(proMoving.getSprite(2, 9), 330);

    proleft.addFrame(proMoving.getSprite(3, 9), 330);

    proleft.addFrame(proMoving.getSprite(4, 9), 330);

    proleft.addFrame(proMoving.getSprite(5, 9), 330);

    proleft.addFrame(proMoving.getSprite(6, 9), 330);

    proleft.addFrame(proMoving.getSprite(7, 9), 330);

    proleft.addFrame(proMoving.getSprite(8, 9), 330);

    proright = new Animation();

    proright.setAutoUpdate(false);

    proright.addFrame(proMoving.getSprite(0, 11), 330);

    proright.addFrame(proMoving.getSprite(1, 11), 330);

    proright.addFrame(proMoving.getSprite(2, 11), 330);

    proright.addFrame(proMoving.getSprite(3, 11), 330);

    proright.addFrame(proMoving.getSprite(4, 11), 330);

    proright.addFrame(proMoving.getSprite(5, 11), 330);

    proright.addFrame(proMoving.getSprite(6, 11), 330);

    proright.addFrame(proMoving.getSprite(7, 11), 330);

    proright.addFrame(proMoving.getSprite(8, 11), 330);

    prowait = new Animation();

    prowait.setAutoUpdate(true);

    prowait.addFrame(proMoving.getSprite(0, 14), 733);

    prowait.addFrame(proMoving.getSprite(1, 14), 733);

    prowait.addFrame(proMoving.getSprite(2, 14), 733);

    prowait.addFrame(proMoving.getSprite(3, 14), 733);

    // wait.addFrame(runningSS.getSprite(2, 14), 733);

    // wait.addFrame(runningSS.getSprite(5, 14), 333);

    sprite = prowait;

    // *****************************************************************

    // Obstacles etc.

    // build a collision map based on tile properties in the TileD map

    blocked.blocked = new boolean[forestMap.getWidth()][forestMap.getHeight()];

    // System.out.println("Map height:" + grassMap.getHeight());

    // System.out.println("Map width:" + grassMap.getWidth());

    // There can be more than 1 layer. You'll check whatever layer has the
    // obstacles.

    // You could also use this for planning traps, etc.

    // System.out.println("Number of tile layers: "
    // +grassMap.getLayerCount());

    System.out.println("The grassmap is " + forestMap.getWidth() + " by " + forestMap.getHeight());

    for (int xAxis = 0; xAxis < forestMap.getWidth(); xAxis++) {

      for (int yAxis = 0; yAxis < forestMap.getHeight(); yAxis++) {

        // int tileID = grassMap.getTileId(xAxis, yAxis, 0);

        // Why was this changed?

        // It's a Different Layer.

        // You should read the TMX file. It's xml, i.e.,human-readable
        // for a reason

        int tileID = forestMap.getTileId(xAxis, yAxis, 1);

        String value = forestMap.getTileProperty(tileID, "blocked", "false");

        if ("true".equals(value)) {

          System.out.println(
              "The tile at x axis " + xAxis + " and y axis " + yAxis + " is blocked.");

          blocked.blocked[xAxis][yAxis] = true;
        }
      }
    }

    System.out.println("Array length " + blocked.blocked[0].length);

    // A remarkably similar process for finding hostiles

    hostiles = new boolean[forestMap.getWidth()][forestMap.getHeight()];

    grabtowin = new itemwin(4400, 4400);
    stuffwin.add(grabtowin);

    numberone = new Enemy(300, 300);
    monster.add(numberone);
  }