Пример #1
0
  public void render(Screen screen) {
    /* our texture in the png file */
    int xt = 0; // X tile coordinate in the sprite-sheet
    int yt = 14; // Y tile coordinate in the sprite-sheet

    // change the 3 in (walkDist >> 3) to change the time it will take to switch sprites. (bigger
    // number = longer time).
    int flip1 =
        (walkDist >> 3)
            & 1; // This will either be a 1 or a 0 depending on the walk distance (Used for walking
                 // effect by mirroring the sprite)
    int flip2 =
        (walkDist >> 3)
            & 1; // This will either be a 1 or a 0 depending on the walk distance (Used for walking
                 // effect by mirroring the sprite)

    if (dir == 1) { // if facing up
      xt += 2; // change sprite to up
    }
    if (dir > 1) { // if facing left or down

      flip1 = 0; // controls flipping left and right
      flip2 =
          ((walkDist >> 4)
              & 1); // This will either be a 1 or a 0 depending on the walk distance (Used for
                    // walking effect by mirroring the sprite)
      if (dir == 2) { // if facing left
        flip1 = 1; // flip the sprite so it looks like we are facing left
      }
      xt += 4 + ((walkDist >> 3) & 1) * 2; // animation based on walk distance
    }

    /* where to draw the sprite relative to our position */
    int xo = x - 8; // the horizontal location to start drawing the sprite
    int yo = y - 11; // the vertical location to start drawing the sprite

    int col = Color.get(-1, 10, 252, 050); // lvl 1 colour green
    if (lvl == 2) col = Color.get(-1, 100, 522, 050); // lvl 2 colour pink
    if (lvl == 3) col = Color.get(-1, 111, 444, 050); // lvl 3 light gray
    if (lvl == 4) col = Color.get(-1, 000, 111, 020); // lvl 4 dark grey
    if (hurtTime > 0) { // if hurt
      col = Color.get(-1, 555, 555, 555); // make our colour white
    }

    /* Draws the sprite as 4 different 8*8 images instead of one 16*16 image */
    screen.render(xo + 8 * flip1, yo + 0, xt + yt * 32, col, flip1); // draws the top-left tile
    screen.render(
        xo + 8 - 8 * flip1, yo + 0, xt + 1 + yt * 32, col, flip1); // draws the top-right tile
    screen.render(
        xo + 8 * flip2, yo + 8, xt + (yt + 1) * 32, col, flip2); // draws the bottom-left tile
    screen.render(
        xo + 8 - 8 * flip2,
        yo + 8,
        xt + 1 + (yt + 1) * 32,
        col,
        flip2); // draws the bottom-right tile
  }
 @Override
 public void render(Screen screen, Level level, int x, int y) {
   int color = Color.get(level.dirtColor, 000, 333, 444);
   int xt = 0;
   if (leadsUp) xt = 2;
   screen.render(x * 16 + 0, y * 16 + 0, xt + 2 * 32, color, 0);
   screen.render(x * 16 + 8, y * 16 + 0, xt + 1 + 2 * 32, color, 0);
   screen.render(x * 16 + 0, y * 16 + 8, xt + 3 * 32, color, 0);
   screen.render(x * 16 + 8, y * 16 + 8, xt + 1 + 3 * 32, color, 0);
 }
Пример #3
0
 public void render(Screen screen, Level level, int x, int y) {
   int col = Color.get(20, 40, 50, level.sandColor); // colors of the cactus
   screen.render(
       x * 16 + 0, y * 16 + 0, 8 + 2 * 32, col, 0); // renders the top-left part of the cactus
   screen.render(
       x * 16 + 8, y * 16 + 0, 9 + 2 * 32, col, 0); // renders the top-right part of the cactus
   screen.render(
       x * 16 + 0, y * 16 + 8, 8 + 3 * 32, col, 0); // renders the bottom-left part of the cactus
   screen.render(
       x * 16 + 8, y * 16 + 8, 9 + 3 * 32, col, 0); // renders the bottom-right part of the cactus
 }
Пример #4
0
  public void render(Screen screen, Level level, int x, int y) {
    super.render(screen, level, x, y);

    int data = level.getData(x, y);
    int shape = (data / 16) % 2;
    int flowerCol = Color.get(10, level.grassColor, 555, 440);

    if (shape == 0) screen.render(x * 16 + 0, y * 16 + 0, 1 + 1 * 32, flowerCol, 0);
    if (shape == 1) screen.render(x * 16 + 8, y * 16 + 0, 1 + 1 * 32, flowerCol, 0);
    if (shape == 1) screen.render(x * 16 + 0, y * 16 + 8, 1 + 1 * 32, flowerCol, 0);
    if (shape == 0) screen.render(x * 16 + 8, y * 16 + 8, 1 + 1 * 32, flowerCol, 0);
  }
Пример #5
0
  public void render(Screen screen, Level level, int x, int y) {
    int col = Color.get(334, 334, 223, 223);
    int transitionColor = Color.get(001, 334, 445, level.dirtColor);

    boolean u = level.getTile(x, y - 1) != this;
    boolean d = level.getTile(x, y + 1) != this;
    boolean l = level.getTile(x - 1, y) != this;
    boolean r = level.getTile(x + 1, y) != this;

    boolean ul = level.getTile(x - 1, y - 1) != this;
    boolean dl = level.getTile(x - 1, y + 1) != this;
    boolean ur = level.getTile(x + 1, y - 1) != this;
    boolean dr = level.getTile(x + 1, y + 1) != this;

    if (!u && !l) {
      if (!ul) screen.render(x * 16 + 0, y * 16 + 0, 0, col, 0);
      else screen.render(x * 16 + 0, y * 16 + 0, 7 + 0 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 0, y * 16 + 0, (l ? 6 : 5) + (u ? 2 : 1) * 32, transitionColor, 3);

    if (!u && !r) {
      if (!ur) screen.render(x * 16 + 8, y * 16 + 0, 1, col, 0);
      else screen.render(x * 16 + 8, y * 16 + 0, 8 + 0 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 8, y * 16 + 0, (r ? 4 : 5) + (u ? 2 : 1) * 32, transitionColor, 3);

    if (!d && !l) {
      if (!dl) screen.render(x * 16 + 0, y * 16 + 8, 2, col, 0);
      else screen.render(x * 16 + 0, y * 16 + 8, 7 + 1 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 0, y * 16 + 8, (l ? 6 : 5) + (d ? 0 : 1) * 32, transitionColor, 3);
    if (!d && !r) {
      if (!dr) screen.render(x * 16 + 8, y * 16 + 8, 3, col, 0);
      else screen.render(x * 16 + 8, y * 16 + 8, 8 + 1 * 32, transitionColor, 3);
    } else
      screen.render(x * 16 + 8, y * 16 + 8, (r ? 4 : 5) + (d ? 0 : 1) * 32, transitionColor, 3);
  }