diff --git a/LavaJava/.classpath b/LavaJava/.classpath new file mode 100644 index 0000000..133ed62 --- /dev/null +++ b/LavaJava/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/LavaJava/.project b/LavaJava/.project new file mode 100644 index 0000000..f8f6496 --- /dev/null +++ b/LavaJava/.project @@ -0,0 +1,17 @@ + + + LavaJava + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/LavaJava/.settings/org.eclipse.jdt.core.prefs b/LavaJava/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/LavaJava/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/LavaJava/bin/.gitignore b/LavaJava/bin/.gitignore new file mode 100644 index 0000000..4697f92 --- /dev/null +++ b/LavaJava/bin/.gitignore @@ -0,0 +1,10 @@ +/BoundingBox.class +/ColidableObject.class +/Game.class +/GameStateManager.class +/Level1.class +/ObjectArray.class +/Player.class +/Wall.class +/helpers/ +/res/ diff --git a/LavaJava/natives/OpenAL32.dll b/LavaJava/natives/OpenAL32.dll new file mode 100644 index 0000000..1f69e94 Binary files /dev/null and b/LavaJava/natives/OpenAL32.dll differ diff --git a/LavaJava/natives/OpenAL64.dll b/LavaJava/natives/OpenAL64.dll new file mode 100644 index 0000000..6f2a2fe Binary files /dev/null and b/LavaJava/natives/OpenAL64.dll differ diff --git a/LavaJava/natives/jinput-dx8.dll b/LavaJava/natives/jinput-dx8.dll new file mode 100644 index 0000000..6d27ad5 Binary files /dev/null and b/LavaJava/natives/jinput-dx8.dll differ diff --git a/LavaJava/natives/jinput-dx8_64.dll b/LavaJava/natives/jinput-dx8_64.dll new file mode 100644 index 0000000..6730589 Binary files /dev/null and b/LavaJava/natives/jinput-dx8_64.dll differ diff --git a/LavaJava/natives/jinput-raw.dll b/LavaJava/natives/jinput-raw.dll new file mode 100644 index 0000000..ce1d162 Binary files /dev/null and b/LavaJava/natives/jinput-raw.dll differ diff --git a/LavaJava/natives/jinput-raw_64.dll b/LavaJava/natives/jinput-raw_64.dll new file mode 100644 index 0000000..3d2b3ad Binary files /dev/null and b/LavaJava/natives/jinput-raw_64.dll differ diff --git a/LavaJava/natives/lwjgl.dll b/LavaJava/natives/lwjgl.dll new file mode 100644 index 0000000..bba9b3d Binary files /dev/null and b/LavaJava/natives/lwjgl.dll differ diff --git a/LavaJava/natives/lwjgl64.dll b/LavaJava/natives/lwjgl64.dll new file mode 100644 index 0000000..1267747 Binary files /dev/null and b/LavaJava/natives/lwjgl64.dll differ diff --git a/LavaJava/src/BoundingBox.java b/LavaJava/src/BoundingBox.java new file mode 100644 index 0000000..be477e1 --- /dev/null +++ b/LavaJava/src/BoundingBox.java @@ -0,0 +1,53 @@ +import java.awt.Point; + + +public class BoundingBox { + private double x1, y1; // lower left + private double x2, y2; // upper right + + public BoundingBox(double x1, double y1, double x2, double y2) { + this.x1 = Math.min(x1, x2); + this.x2 = Math.max(x1, x2); + this.y1 = Math.min(y1, y2); + this.y2 = Math.max(y1, y2); + } + + public BoundingBox(Point p, Point q) { + this(p.x, p.y, q.x, q.y); + } + + // random rectangle in unit square + public BoundingBox() { + this(new Point(), new Point()); + } + + // is Point p inside this BoundingBox? + public boolean contains(Point p) { + return (p.x >= x1 && p.x <= x2 && p.y >= y1 && p.y <= y2); + } + + // does this BoundingBox r intersect s? + public boolean intersects(BoundingBox s) { + BoundingBox r = this; + return (r.x2 >= s.x1 && r.y2 >= s.y1 && s.x2 >= r.x1 && s.y2 >= r.y1); + } + + + // return the area + public double area() { + return (x2 - x1) * (y2 - y1); + } + + // return the area + public String toString() { + return "[(" + x1 + ", " + y1 + ") (" + x2 + ", " + y2 + ")]"; + } + public void setBoundingBox(double x1, double y1, double x2, double y2){ + this.x1 = Math.min(x1, x2); + this.x2 = Math.max(x1, x2); + this.y1 = Math.min(y1, y2); + this.y2 = Math.max(y1, y2); + } + + +} diff --git a/LavaJava/src/ColidableObject.java b/LavaJava/src/ColidableObject.java new file mode 100644 index 0000000..c4f8332 --- /dev/null +++ b/LavaJava/src/ColidableObject.java @@ -0,0 +1,27 @@ + +public abstract class ColidableObject { + + public void init(){ + + } + public void render(){ + + } + public int x1(){ + return 0; + + } + public int x2(){ + return 0; + } + public int y1(){ + return 0; + + } + public int y2(){ + return 0; + } + + + +} diff --git a/LavaJava/src/Game.java b/LavaJava/src/Game.java new file mode 100644 index 0000000..ff46ac4 --- /dev/null +++ b/LavaJava/src/Game.java @@ -0,0 +1,31 @@ +import static helpers.Artist.SetUp; + +import java.util.ArrayList; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; + + +public class Game { + + public static void main(String[] args) { + + SetUp(800, 600); + Level1 m = new Level1(); + + while(!Display.isCloseRequested()){ + Display.setTitle("Bounding"); + Display.update(); + Display.sync(60); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + m.render(); + + + + + } + Display.destroy(); + } + +} diff --git a/LavaJava/src/GameStateManager.java b/LavaJava/src/GameStateManager.java new file mode 100644 index 0000000..d5466cf --- /dev/null +++ b/LavaJava/src/GameStateManager.java @@ -0,0 +1,18 @@ +import java.util.ArrayList; + + +public class GameStateManager { + private int currentState; + private ArrayList states; + public static final int MENUSTATE = 0; + + // add more state integers here + + public GameStateManager() { + states = new ArrayList(); + states.add(new MenuState()); + + } + + +} diff --git a/LavaJava/src/Level1.java b/LavaJava/src/Level1.java new file mode 100644 index 0000000..8c84dac --- /dev/null +++ b/LavaJava/src/Level1.java @@ -0,0 +1,59 @@ +import org.lwjgl.input.Mouse; +import org.newdawn.slick.opengl.Texture; +import static helpers.Artist.DrawQuadTex; + +import static helpers.Artist.QuickLoadTexture; + +public class Level1 { + Texture Background,blockers; + private String grass = "Grass64"; + private String dirt = "Dirt64"; + Player player = new Player(400,300); + ObjectArray w = new ObjectArray(); + Wall w1 = new Wall(400,400); + ColidableObject x = new Wall(0, 0); + + public Level1() { + init(); + } + void init(){ + Background = QuickLoadTexture(grass); + blockers = QuickLoadTexture(dirt); + + } + void render(){ + for (int i = 0; i < 800; i+= 64) { + for (int j = 0; j < 600; j+=64) { + DrawQuadTex(Background,i,j,64,64); + DrawQuadTex(blockers, 0, j, 64, 64); + } + + } + + for (int i = 0; i lvl1 = new ArrayList(); + static int increment = 10; + + public ObjectArray() { + for (int i = 0; i < 5; i++) { + lvl1.add(new Wall(200,increment)); + increment+=64; + } + } + + public int size(){ + return lvl1.size(); + + } + public ColidableObject getWall(int i){ + return lvl1.get(i); + } + public ArrayList returnList(){ + return lvl1; + } + +} diff --git a/LavaJava/src/Player.java b/LavaJava/src/Player.java new file mode 100644 index 0000000..f127a80 --- /dev/null +++ b/LavaJava/src/Player.java @@ -0,0 +1,121 @@ +import static helpers.Artist.DrawQuadTex; +import static helpers.Artist.QuickLoadTexture; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.newdawn.slick.opengl.Texture; + + + +public class Player { + + public final String charTexture = "Character64"; + public final String charTextureLeft = "Character64_Left"; + public final String charTextureRight = "Character64_Right"; + public final String charTextureUp = "Character64_Up"; + public static final int PLAYER_DIM = 64; + private int x, y ; + public int dx ,dy ; + public int motionX,motionY; + + Texture Button; + boolean isCollided = false; + + public Player(int startx, int starty) { + x = startx; + y = starty; + init(); + + } + public void init(){ + Button = QuickLoadTexture(charTexture); + + } + + public void render(){ + DrawQuadTex(Button,x,y,64,64); + + + } + + public void checkCollsionAndMove(Wall b1){ + + if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) && x > 0) { + dx = -4; + Button = QuickLoadTexture(charTextureLeft); + } + + if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && x < 736) { + dx = 4; + Button = QuickLoadTexture(charTextureRight); + } + if (Keyboard.isKeyDown(Keyboard.KEY_UP) && y > 0) { + dy = -4; + Button = QuickLoadTexture(charTextureUp); + } + if (Keyboard.isKeyDown(Keyboard.KEY_DOWN) && y < 536) { + dy = 4; + Button = QuickLoadTexture(charTexture); + } + //System.out.println(dx + " " + dy); + + + if(b1.x2() >= x + dx && b1.x1() <= x + dx + PLAYER_DIM && b1.y2() >= y + dy&& b1.y1() <= y + dy + PLAYER_DIM){ + isCollided = true; + } + else { + isCollided = false; + } + //System.out.println(isCollided); + + } + + public void stop(){ + dx = 0; + dy = 0; + } + + public void update(){ + if (!isCollided) { + x+=dx; motionX = dx; + y+=dy; motionY = dy; + stop(); + + } + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + public int getMotionX(){ + return motionX; + } + public int getMotionY(){ + return motionY; + } + + +} + + + + diff --git a/LavaJava/src/Wall.java b/LavaJava/src/Wall.java new file mode 100644 index 0000000..ca1bc85 --- /dev/null +++ b/LavaJava/src/Wall.java @@ -0,0 +1,38 @@ +import static helpers.Artist.DrawQuadTex; +import static helpers.Artist.QuickLoadTexture; +import org.newdawn.slick.opengl.Texture; + +public class Wall extends ColidableObject { + private final String WALL_TEX = "Wall64"; + public final int WALL_DIM = 64; + Texture wall; + int x,y; + + public Wall(int x, int y) { + //super(); + this.x = x; + this.y = y; + init(); + } + public void init(){ + wall = QuickLoadTexture(WALL_TEX); + } + public void render(){ + DrawQuadTex(wall, x, y, WALL_DIM, WALL_DIM); + } + + //Corners of wall for collision detection + public int x1(){ + return x; + } + public int x2(){ + return x + WALL_DIM; + } + public int y1(){ + return y; + + } + public int y2(){ + return y + WALL_DIM; + } +} diff --git a/LavaJava/src/helpers/Artist.java b/LavaJava/src/helpers/Artist.java new file mode 100644 index 0000000..4065190 --- /dev/null +++ b/LavaJava/src/helpers/Artist.java @@ -0,0 +1,102 @@ +package helpers; + +import static org.lwjgl.opengl.GL11.GL_MODELVIEW; +import static org.lwjgl.opengl.GL11.GL_PROJECTION; +import static org.lwjgl.opengl.GL11.GL_QUADS; +import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; +import static org.lwjgl.opengl.GL11.glBegin; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL11.glEnd; +import static org.lwjgl.opengl.GL11.glLoadIdentity; +import static org.lwjgl.opengl.GL11.glMatrixMode; +import static org.lwjgl.opengl.GL11.glOrtho; +import static org.lwjgl.opengl.GL11.glTexCoord2f; +import static org.lwjgl.opengl.GL11.glTranslatef; +import static org.lwjgl.opengl.GL11.glVertex2f; + +import java.io.IOException; +import java.io.InputStream; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.newdawn.slick.opengl.Texture; +import org.newdawn.slick.opengl.TextureLoader; +import org.newdawn.slick.util.ResourceLoader; + +public class Artist +{ + //Draws a rectangle + public static void DrawQuad(float x, float y, float width, float height) + { + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2f(x, y); + GL11.glVertex2f(x+width, y); + GL11.glVertex2f(x+width, y+height); + GL11.glVertex2f(x, y+height); + GL11.glEnd(); + + } + + //Draws a rectangle with a texture on it + public static void DrawQuadTex(Texture tex, float x, float y, float width, float height) + { + tex.bind(); + glTranslatef(x, y, 0); + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(0, 0); + glTexCoord2f(1, 0); + glVertex2f(width, 0); + glTexCoord2f(1, 1); + glVertex2f(width, height); + glTexCoord2f(0, 1); + glVertex2f(0, height); + glEnd(); + glLoadIdentity(); + + } + + public static Texture LoadTexture(String path, String fileType) + { + Texture tex=null; + InputStream in=ResourceLoader.getResourceAsStream(path); + try { + tex=TextureLoader.getTexture(fileType, in); + } catch (IOException e) { + e.printStackTrace(); + } + return tex; + } + + public static Texture QuickLoadTexture(String name) + { + Texture tex=null; + tex=LoadTexture("res/" + name + ".png", "PNG"); + return tex; + } + + //sets up the screen + public static void SetUp(int width, int height) + { + + final int WIDTH=width, HEIGHT=height; + + Display.setTitle("Bounding"); + try { + Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); + Display.create(); + } catch (LWJGLException e) { + e.printStackTrace(); + } + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, WIDTH, HEIGHT, 0, 1, -1); + glMatrixMode(GL_MODELVIEW); + glEnable(GL_TEXTURE_2D); + glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } +} \ No newline at end of file diff --git a/LavaJava/src/res/Character64.png b/LavaJava/src/res/Character64.png new file mode 100644 index 0000000..6f0bef8 Binary files /dev/null and b/LavaJava/src/res/Character64.png differ diff --git a/LavaJava/src/res/Character64_Left.png b/LavaJava/src/res/Character64_Left.png new file mode 100644 index 0000000..a05c211 Binary files /dev/null and b/LavaJava/src/res/Character64_Left.png differ diff --git a/LavaJava/src/res/Character64_Right.png b/LavaJava/src/res/Character64_Right.png new file mode 100644 index 0000000..b1b594a Binary files /dev/null and b/LavaJava/src/res/Character64_Right.png differ diff --git a/LavaJava/src/res/Character64_Up.png b/LavaJava/src/res/Character64_Up.png new file mode 100644 index 0000000..d7dacdb Binary files /dev/null and b/LavaJava/src/res/Character64_Up.png differ diff --git a/LavaJava/src/res/Dirt64.png b/LavaJava/src/res/Dirt64.png new file mode 100644 index 0000000..5eca288 Binary files /dev/null and b/LavaJava/src/res/Dirt64.png differ diff --git a/LavaJava/src/res/Finish64.png b/LavaJava/src/res/Finish64.png new file mode 100644 index 0000000..b5c825a Binary files /dev/null and b/LavaJava/src/res/Finish64.png differ diff --git a/LavaJava/src/res/Grass64.png b/LavaJava/src/res/Grass64.png new file mode 100644 index 0000000..3825454 Binary files /dev/null and b/LavaJava/src/res/Grass64.png differ diff --git a/LavaJava/src/res/Lava64.png b/LavaJava/src/res/Lava64.png new file mode 100644 index 0000000..214d133 Binary files /dev/null and b/LavaJava/src/res/Lava64.png differ diff --git a/LavaJava/src/res/MonsterA64.png b/LavaJava/src/res/MonsterA64.png new file mode 100644 index 0000000..f0cc4f5 Binary files /dev/null and b/LavaJava/src/res/MonsterA64.png differ diff --git a/LavaJava/src/res/MonsterB64.png b/LavaJava/src/res/MonsterB64.png new file mode 100644 index 0000000..2c744d7 Binary files /dev/null and b/LavaJava/src/res/MonsterB64.png differ diff --git a/LavaJava/src/res/MonsterC64.png b/LavaJava/src/res/MonsterC64.png new file mode 100644 index 0000000..9d4f38f Binary files /dev/null and b/LavaJava/src/res/MonsterC64.png differ diff --git a/LavaJava/src/res/Player64.png b/LavaJava/src/res/Player64.png new file mode 100644 index 0000000..a182bf0 Binary files /dev/null and b/LavaJava/src/res/Player64.png differ diff --git a/LavaJava/src/res/Snow64.png b/LavaJava/src/res/Snow64.png new file mode 100644 index 0000000..c55f1e3 Binary files /dev/null and b/LavaJava/src/res/Snow64.png differ diff --git a/LavaJava/src/res/Spawn64.png b/LavaJava/src/res/Spawn64.png new file mode 100644 index 0000000..6d352c3 Binary files /dev/null and b/LavaJava/src/res/Spawn64.png differ diff --git a/LavaJava/src/res/Stone64.png b/LavaJava/src/res/Stone64.png new file mode 100644 index 0000000..3b6e156 Binary files /dev/null and b/LavaJava/src/res/Stone64.png differ diff --git a/LavaJava/src/res/Wall64.PNG b/LavaJava/src/res/Wall64.PNG new file mode 100644 index 0000000..8814486 Binary files /dev/null and b/LavaJava/src/res/Wall64.PNG differ