This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aea6788
Showing
73 changed files
with
3,944 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
*.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Herp Fortress | ||
|
||
This is an archived copy of the source code of Herp Fortress written by Minecraft's original developer, Markus "Notch" Persson, based on [the Internet Archive version](https://web.archive.org/web/20120601154736/0x10c.com/tmp/HerpFortress.zip), with only one code fix which causes the Java compiler to fail, the rest is unaffected. | ||
|
||
I am not the owner of this code, i'm just reuploading. | ||
|
||
## Getting the game | ||
|
||
Head to [the readme from Rewritten repo](https://github.com/TeutonicCode/HFRewritten#getting-the-game). | ||
|
||
<sub>This repository is not approved by or associated with Notch or Mojang.</sub> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.mojang.herpfortress; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.IOException; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
public class Art { | ||
public static Art i; | ||
|
||
public static void init() { | ||
i = new Art(); | ||
} | ||
|
||
public Bitmap[][] red = loadAndCut("/chars/red.png", 16, 16); | ||
public Bitmap[][] blu = loadAndCut("/chars/blu.png", 16, 16); | ||
public Bitmap[][] cursors = loadAndCut("/cursors.png", 16, 16); | ||
public Bitmap[][] particles = loadAndCut("/particles.png", 8, 8); | ||
public Bitmap[][] pickups = loadAndCut("/pickups.png", 8, 8); | ||
public Bitmap[][] missiles = loadAndCut("/missiles.png", 8, 8); | ||
public Bitmap[][] mapTiles = loadAndCut("/tiles.png", 24, 24); | ||
public Bitmap panel = load("/panel.png"); | ||
|
||
public static Bitmap[][] loadAndCut(String name, int sw, int sh) { | ||
BufferedImage img; | ||
try { | ||
img = ImageIO.read(Art.class.getResource(name)); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to load " + name); | ||
} | ||
|
||
int xSlices = img.getWidth() / sw; | ||
int ySlices = img.getHeight() / sh; | ||
|
||
Bitmap[][] result = new Bitmap[xSlices][ySlices]; | ||
for (int x = 0; x < xSlices; x++) { | ||
for (int y = 0; y < ySlices; y++) { | ||
result[x][y] = new Bitmap(sw, sh); | ||
img.getRGB(x * sw, y * sh, sw, sh, result[x][y].pixels, 0, sw); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public static Bitmap load(String name) { | ||
BufferedImage img; | ||
try { | ||
img = ImageIO.read(Art.class.getResource(name)); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to load " + name); | ||
} | ||
|
||
int sw = img.getWidth(); | ||
int sh = img.getHeight(); | ||
|
||
Bitmap result = new Bitmap(sw, sh); | ||
img.getRGB(0, 0, sw, sh, result.pixels, 0, sw); | ||
|
||
return result; | ||
} | ||
|
||
public static Bitmap[][] recolor(Bitmap[][] bitmaps, int a0, int b0, int a1, int b1) { | ||
for (int x = 0; x < bitmaps.length; x++) { | ||
for (int y = 0; y < bitmaps[x].length; y++) { | ||
Bitmap bm = bitmaps[x][y]; | ||
for (int i = 0; i < bm.pixels.length; i++) { | ||
if (bm.pixels[i] == a0) bm.pixels[i] = b0; | ||
if (bm.pixels[i] == a1) bm.pixels[i] = b1; | ||
} | ||
} | ||
} | ||
return bitmaps; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
package com.mojang.herpfortress; | ||
|
||
import java.awt.image.*; | ||
import java.util.*; | ||
|
||
public class Bitmap { | ||
public final int[] pixels; | ||
public final int w, h; | ||
public int xOffs; | ||
public int yOffs; | ||
public boolean xFlip = false; | ||
|
||
public Bitmap(int w, int h) { | ||
this.w = w; | ||
this.h = h; | ||
pixels = new int[w * h]; | ||
} | ||
|
||
public Bitmap(int w, int h, int[] pixels) { | ||
this.w = w; | ||
this.h = h; | ||
this.pixels = pixels; | ||
} | ||
|
||
public Bitmap(BufferedImage img) { | ||
this.w = img.getWidth(); | ||
this.h = img.getHeight(); | ||
pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData(); | ||
} | ||
|
||
public void draw(Bitmap b, int xp, int yp) { | ||
xp += xOffs; | ||
yp += yOffs; | ||
int x0 = xp; | ||
int x1 = xp + b.w; | ||
int y0 = yp; | ||
int y1 = yp + b.h; | ||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 > w) x1 = w; | ||
if (y1 > h) y1 = h; | ||
|
||
if (xFlip) { | ||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w + xp + b.w - 1; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp - x]; | ||
if (c < 0) pixels[dp + x] = b.pixels[sp - x]; | ||
} | ||
} | ||
} else { | ||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w - xp; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp + x]; | ||
if (c < 0) pixels[dp + x] = b.pixels[sp + x]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void blendDraw(Bitmap b, int xp, int yp, int col) { | ||
xp += xOffs; | ||
yp += yOffs; | ||
int x0 = xp; | ||
int x1 = xp + b.w; | ||
int y0 = yp; | ||
int y1 = yp + b.h; | ||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 > w) x1 = w; | ||
if (y1 > h) y1 = h; | ||
|
||
if (xFlip) { | ||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w + xp + b.w - 1; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp - x]; | ||
if (c < 0) pixels[dp + x] = ((b.pixels[sp - x] & 0xfefefefe) + (col & 0xfefefefe)) >> 1; | ||
} | ||
} | ||
} else { | ||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w - xp; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp + x]; | ||
if (c < 0) pixels[dp + x] = ((b.pixels[sp + x] & 0xfefefefe) + (col & 0xfefefefe)) >> 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void clear(int color) { | ||
Arrays.fill(pixels, color); | ||
} | ||
|
||
public void setPixel(int xp, int yp, int color) { | ||
xp += xOffs; | ||
yp += yOffs; | ||
if (xp >= 0 && yp >= 0 && xp < w && yp < h) { | ||
pixels[xp + yp * w] = color; | ||
} | ||
|
||
} | ||
|
||
public void shade(Bitmap shadows) { | ||
for (int i = 0; i < pixels.length; i++) { | ||
if (shadows.pixels[i] > 0) { | ||
int r = ((pixels[i] & 0xff0000) * 200) >> 8 & 0xff0000; | ||
int g = ((pixels[i] & 0xff00) * 200) >> 8 & 0xff00; | ||
int b = ((pixels[i] & 0xff) * 200) >> 8 & 0xff; | ||
pixels[i] = 0xff000000 | r | g | b; | ||
} | ||
} | ||
} | ||
|
||
public void fill(int x0, int y0, int x1, int y1, int color) { | ||
x0 += xOffs; | ||
y0 += yOffs; | ||
x1 += xOffs; | ||
y1 += yOffs; | ||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 >= w) x1 = w - 1; | ||
if (y1 >= h) y1 = h - 1; | ||
for (int y = y0; y <= y1; y++) { | ||
for (int x = x0; x <= x1; x++) { | ||
pixels[x + y * w] = color; | ||
} | ||
} | ||
} | ||
|
||
public void box(int x0, int y0, int x1, int y1, int color) { | ||
x0 += xOffs; | ||
y0 += yOffs; | ||
x1 += xOffs; | ||
y1 += yOffs; | ||
int xx0 = x0; | ||
int yy0 = y0; | ||
int xx1 = x1; | ||
int yy1 = y1; | ||
|
||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 >= w) x1 = w - 1; | ||
if (y1 >= h) y1 = h - 1; | ||
|
||
for (int y = y0; y <= y1; y++) { | ||
for (int x = x0; x <= x1; x++) { | ||
if (x == xx0 || y == yy0 || x == xx1 || y == yy1) pixels[x + y * w] = color; | ||
if (y > yy0 && y < yy1 && x < xx1 - 1) { | ||
x = xx1 - 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void blend(Bitmap b, int xp, int yp) { | ||
xp += xOffs; | ||
yp += yOffs; | ||
int x0 = xp; | ||
int x1 = xp + b.w; | ||
int y0 = yp; | ||
int y1 = yp + b.h; | ||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 > w) x1 = w; | ||
if (y1 > h) y1 = h; | ||
|
||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w - xp; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp + x]; | ||
int a = (c >> 24) & 0xff; | ||
if (a != 0) { | ||
int ia = 255 - a; | ||
|
||
int rr = (pixels[dp + x] >> 16) & 0xff; | ||
int gg = (pixels[dp + x] >> 8) & 0xff; | ||
int bb = (pixels[dp + x]) & 0xff; | ||
|
||
int ir = ((x ^ y) & 1) * 10 + 10; | ||
int ig = ir; | ||
int ib = ir; | ||
|
||
rr = (rr * ia + ir * a) / 255; | ||
gg = (gg * ia + ig * a) / 255; | ||
bb = (bb * ia + ib * a) / 255; | ||
|
||
pixels[dp + x] = 0xff000000 | rr << 16 | gg << 8 | bb; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void fogBlend(Bitmap b, int xp, int yp) { | ||
xp += xOffs; | ||
yp += yOffs; | ||
int x0 = xp; | ||
int x1 = xp + b.w; | ||
int y0 = yp; | ||
int y1 = yp + b.h; | ||
if (x0 < 0) x0 = 0; | ||
if (y0 < 0) y0 = 0; | ||
if (x1 > w) x1 = w; | ||
if (y1 > h) y1 = h; | ||
|
||
for (int y = y0; y < y1; y++) { | ||
int sp = (y - yp) * b.w - xp; | ||
int dp = (y) * w; | ||
|
||
for (int x = x0; x < x1; x++) { | ||
int c = b.pixels[sp + x]; | ||
if (c != 0) { | ||
c = c & 0xff; | ||
int ic = 255 - c; | ||
int rr = (pixels[dp + x] >> 16) & 0xff; | ||
int gg = (pixels[dp + x] >> 8) & 0xff; | ||
int bb = (pixels[dp + x]) & 0xff; | ||
int gray = (rr * 30 + gg * 59 + bb * 11) / 255; | ||
|
||
rr = (rr * c + gray * ic) / 255; | ||
gg = (gg * c + gray * ic) / 255; | ||
bb = (bb * c + gray * ic) / 255; | ||
|
||
pixels[dp + x] = 0xff000000 | rr << 16 | gg << 8 | bb; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.mojang.herpfortress; | ||
|
||
import com.mojang.herpfortress.level.Level; | ||
|
||
public class Game { | ||
|
||
public Level level; | ||
private Bitmap shadows; | ||
|
||
public Game() { | ||
level = new Level(); | ||
} | ||
|
||
public void render(Bitmap screen, int xScroll, int yScroll, int[] visMap) { | ||
if (shadows == null) shadows = new Bitmap(screen.w, screen.h); | ||
shadows.clear(0); | ||
|
||
screen.xOffs = -xScroll; | ||
screen.yOffs = -yScroll; | ||
level.renderBg(screen, xScroll, yScroll, visMap); | ||
|
||
shadows.xOffs = -xScroll; | ||
shadows.yOffs = -yScroll; | ||
level.renderShadows(shadows, visMap); | ||
screen.xOffs = 0; | ||
screen.yOffs = 0; | ||
screen.shade(shadows); | ||
|
||
screen.xOffs = -xScroll; | ||
screen.yOffs = -yScroll; | ||
level.renderSprites(screen, visMap); | ||
|
||
level.renderInvis(screen, xScroll, yScroll, visMap); | ||
} | ||
|
||
public void tick() { | ||
level.tick(); | ||
} | ||
} |
Oops, something went wrong.