Skip to content

Commit

Permalink
TONS OF STUFF
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelik committed May 10, 2014
1 parent cc74e9c commit 4c9bb76
Show file tree
Hide file tree
Showing 82 changed files with 2,171 additions and 78 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
content_assist_lru_history=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"><lhs name\="java.awt.Paint"><rhs name\="java.awt.Color"/></lhs><lhs name\="java.awt.Transparency"><rhs name\="java.awt.Color"/></lhs><lhs name\="java.awt.Color"><rhs name\="java.awt.Color"/></lhs><lhs name\="com.mrizen.test.Tile"><rhs name\="com.mrizen.test.Tile"/></lhs><lhs name\="Tile"><rhs name\="Tile"/></lhs><lhs name\="Sprite"><rhs name\="Sprite"/></lhs><lhs name\="Checker"><rhs name\="Checker"/></lhs><lhs name\="java.lang.Runnable"><rhs name\="java.lang.Thread"/></lhs><lhs name\="java.lang.Thread"><rhs name\="java.lang.Thread"/></lhs><lhs name\="com.mrizen.gaming.Sprite"><rhs name\="com.mrizen.gaming.Sprite"/></lhs></history>
content_assist_lru_history=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"><lhs name\="java.awt.Paint"><rhs name\="java.awt.Color"/></lhs><lhs name\="java.awt.Transparency"><rhs name\="java.awt.Color"/></lhs><lhs name\="java.awt.Color"><rhs name\="java.awt.Color"/></lhs><lhs name\="com.mrizen.test.Tile"><rhs name\="com.mrizen.test.Tile"/></lhs><lhs name\="Tile"><rhs name\="Tile"/></lhs><lhs name\="Sprite"><rhs name\="Sprite"/></lhs><lhs name\="Checker"><rhs name\="Checker"/></lhs><lhs name\="java.lang.Runnable"><rhs name\="java.lang.Thread"/></lhs><lhs name\="java.lang.Thread"><rhs name\="java.lang.Thread"/></lhs><lhs name\="com.mrizen.gaming.Sprite"><rhs name\="com.mrizen.gaming.Sprite"/></lhs><lhs name\="com.mrizen.dungeoncrawler.Tile"><rhs name\="com.mrizen.dungeoncrawler.Tile"/></lhs></history>
content_assist_number_of_computers=13
content_assist_proposals_background=255,255,255
content_assist_proposals_foreground=0,0,0
Expand Down
Binary file modified .metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps
Binary file not shown.
4 changes: 3 additions & 1 deletion .metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ INDEX VERSION 1.126+C:\Users\insuperior\Desktop\github\JavaStuff\.metadata\.plug
4041092966.index
3974580528.index
3065916431.index
3887084256.index
30765161.index
1498219845.index
1115467115.index
4108727661.index
573543369.index
1636583986.index
3458850996.index
1697886153.index
1299022128.index
1995173708.index
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion AStar/src/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Game extends Main {
private Map map;

public Game(String title, int width, int height, double scale, double updatesPerSecond) {
super(title, width, height, scale, updatesPerSecond);
super(title, width, height, scale, scale, updatesPerSecond);
map = new Map(width / Tile.EMPTY.getSprite().getSize(), height / Tile.EMPTY.getSprite().getSize());
showCursor(false);
Sprites.makeSprites();
Expand Down
2 changes: 1 addition & 1 deletion AStar/src/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void pathfind() {
while (n.getFrom() != null) {
int i = n.getPosY() * getWidth() + n.getPosX(), i2 = n.getFromY() * getWidth() + n.getFromX();
if (i < 0 || i >= tiles.length || i2 < 0 || i2 >= tiles.length) {
continue;
break;
}
paths[i] = n.getCount();
n = nodes[n.getFromY() * getWidth() + n.getFromX()];
Expand Down
6 changes: 6 additions & 0 deletions Cube/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions Cube/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Cube</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Cube/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions Cube/src/Array2D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@


public class Array2D {
int[] array;
private int width;

public Array2D(int width, int height) {
this.width = width;
array = new int[width * height];
}

public boolean set(int x, int y, int value) {
if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
return false;
array[y * getWidth() + x] = value;
return true;
}

public int get(int x, int y) {
if (y < 0 || x < 0 || y >= getHeight() || x >= getWidth())
return -1;
return array[y * getWidth() + x];
}

public int getI(int i) {
if (i >= array.length || i < 0)
return -1;
return array[i];
}

public boolean setI(int i, int value) {
if (i >= array.length || i < 0)
return false;
array[i] = value;
return true;
}

public int getWidth() {
return width;
}

public int getHeight() {
return array.length / getWidth();
}

public int getLength() {
return array.length;
}

public int[] getArray() {
return array;
}
}
47 changes: 47 additions & 0 deletions Cube/src/KeyReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@


import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyReader implements KeyListener {
private boolean[] keys;

public KeyReader() {
keys = new boolean[120];
}

public boolean getUp() {
return keys[KeyEvent.VK_UP];
}

public boolean getDown() {
return keys[KeyEvent.VK_DOWN];
}

public boolean getLeft() {
return keys[KeyEvent.VK_LEFT];
}

public boolean getRight() {
return keys[KeyEvent.VK_RIGHT];
}

public boolean getSpace() {
return keys[KeyEvent.VK_SPACE];
}

@Override
public void keyPressed(KeyEvent e) {
keys[e.getKeyCode()] = true;
}

@Override
public void keyReleased(KeyEvent e) {
keys[e.getKeyCode()] = false;
}

@Override
public void keyTyped(KeyEvent e) {

}
}
159 changes: 159 additions & 0 deletions Cube/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import java.awt.Canvas;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;

import javax.swing.JFrame;

import com.mrizen.cube.d2.Point2d;

public class Main extends Canvas implements Runnable {
private static final long serialVersionUID = 4648172894076113183L;

private boolean running;
private String title;
private Screen screen;
private BufferedImage image;
private int[] pixels;
private JFrame frame;
private Thread thread;
private double updatesPerSecond;
private KeyReader keys;
private MouseReader mouse;

public Main(String title, int width, int height, double scale, double updatesPerSecond) {
this.title = title;
this.updatesPerSecond = updatesPerSecond;

frame = new JFrame();
frame.setResizable(false);
frame.setTitle(title);
frame.add(this);
setDimension(width, height, scale);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

screen = new Screen(width, height);

keys = new KeyReader();
addKeyListener(keys);

mouse = new MouseReader(scale);
addMouseMotionListener(mouse);
addMouseListener(mouse);

image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();

running = false;
}

public KeyReader getKeys() {
return keys;
}

public MouseReader getMouse() {
return mouse;
}

protected void setDimension(int width, int height, double scale) {
setPreferredSize(new Dimension((int) (width * scale), (int) (height * scale)));
frame.pack();
}

protected void update() {

}

protected void render() {
screen.drawLine2d(new Point2d(1, 1), new Point2d(1, 1), 0);
}

private void renderPrivate() {
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
screen.clear();
render();
for (int i = 0; i < screen.getPixels().getLength(); i++) {
pixels[i] = screen.getPixels().getI(i);
}
Graphics g = bs.getDrawGraphics();
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
g.dispose();
bs.show();
}

@Override
public void run() {
long lastTime = System.nanoTime();
long timer = System.currentTimeMillis();
final double ns = 1000000000.0 / updatesPerSecond;
double delta = 0;
int frames = 0;
int updates = 0;
requestFocus();
while (running) {
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime = now;
while (delta > 1) {
update();
updates++;
delta--;
}
renderPrivate();
frames++;
if (System.currentTimeMillis() - timer > 1000) {
timer += 1000;
frame.setTitle(title + " | " + updates + " ups, " + frames + " fps");
updates = 0;
frames = 0;
}
}
}

protected synchronized void start() {
running = true;
thread = new Thread(this, "Display");
thread.start();
}

protected synchronized void stop() {
running = false;
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
String title = "Test";
int width = 300;
int height = width / 16 * 9;
int scale = 6;
double updatesPerSecond = 60;

Main main = new Main(title, width, height, scale, updatesPerSecond);
main.start();
}

public Screen getScreen() {
return screen;
}

protected void showCursor(boolean show) {
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
frame.getContentPane().setCursor(blankCursor);
}
}
Loading

0 comments on commit 4c9bb76

Please sign in to comment.