commit 0abfc905e604bcecff338f9fdbf3e304ee8afb87 Author: ksjdragon Date: Sat Feb 14 17:48:55 2015 -0500 fix of git(hopefully) diff --git a/millennium-legacy/.classpath b/millennium-legacy/.classpath new file mode 100644 index 0000000..6c614bc --- /dev/null +++ b/millennium-legacy/.classpath @@ -0,0 +1,10 @@ + + + +<<<<<<< HEAD + +======= + +>>>>>>> 02c13080666632aea0bc8fa372361e43e18af2ef + + diff --git a/millennium-legacy/.project b/millennium-legacy/.project new file mode 100644 index 0000000..b29e032 --- /dev/null +++ b/millennium-legacy/.project @@ -0,0 +1,21 @@ + + +<<<<<<< HEAD + EYS +======= + Millenium Legacy +>>>>>>> 02c13080666632aea0bc8fa372361e43e18af2ef + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/millennium-legacy/.settings/org.eclipse.jdt.core.prefs b/millennium-legacy/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..acfe6af --- /dev/null +++ b/millennium-legacy/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,21 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +<<<<<<< HEAD +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +======= +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 +>>>>>>> 02c13080666632aea0bc8fa372361e43e18af2ef +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 +<<<<<<< HEAD +org.eclipse.jdt.core.compiler.source=1.8 +======= +org.eclipse.jdt.core.compiler.source=1.7 +>>>>>>> 02c13080666632aea0bc8fa372361e43e18af2ef diff --git a/millennium-legacy/README.md b/millennium-legacy/README.md new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/millennium-legacy/README.md @@ -0,0 +1 @@ +hi diff --git a/millennium-legacy/bin/map.txt b/millennium-legacy/bin/map.txt new file mode 100644 index 0000000..ec336db --- /dev/null +++ b/millennium-legacy/bin/map.txt @@ -0,0 +1,16 @@ +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww diff --git a/millennium-legacy/bin/milleniumlegacy/Algorithm.class b/millennium-legacy/bin/milleniumlegacy/Algorithm.class new file mode 100644 index 0000000..05cac0e Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/Algorithm.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/GUI.class b/millennium-legacy/bin/milleniumlegacy/GUI.class new file mode 100644 index 0000000..c32f3d7 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/GUI.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/ImageLoader.class b/millennium-legacy/bin/milleniumlegacy/ImageLoader.class new file mode 100644 index 0000000..f848d1d Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/ImageLoader.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/Item.class b/millennium-legacy/bin/milleniumlegacy/Item.class new file mode 100644 index 0000000..d04d6d7 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/Item.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/KeyManager.class b/millennium-legacy/bin/milleniumlegacy/KeyManager.class new file mode 100644 index 0000000..922a2b6 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/KeyManager.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/MainGame.class b/millennium-legacy/bin/milleniumlegacy/MainGame.class new file mode 100644 index 0000000..863932b Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/MainGame.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/Map.class b/millennium-legacy/bin/milleniumlegacy/Map.class new file mode 100644 index 0000000..dccb8e2 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/Map.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/MapLoader.class b/millennium-legacy/bin/milleniumlegacy/MapLoader.class new file mode 100644 index 0000000..d326678 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/MapLoader.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/OptionsPane.class b/millennium-legacy/bin/milleniumlegacy/OptionsPane.class new file mode 100644 index 0000000..cab53bc Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/OptionsPane.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/Tile.class b/millennium-legacy/bin/milleniumlegacy/Tile.class new file mode 100644 index 0000000..5b97d86 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/Tile.class differ diff --git a/millennium-legacy/bin/milleniumlegacy/player.class b/millennium-legacy/bin/milleniumlegacy/player.class new file mode 100644 index 0000000..6430540 Binary files /dev/null and b/millennium-legacy/bin/milleniumlegacy/player.class differ diff --git a/millennium-legacy/resources/sprites/player.png b/millennium-legacy/resources/sprites/player.png new file mode 100644 index 0000000..18e68e8 Binary files /dev/null and b/millennium-legacy/resources/sprites/player.png differ diff --git a/millennium-legacy/resources/textures/grass.png b/millennium-legacy/resources/textures/grass.png new file mode 100644 index 0000000..ae1fab0 Binary files /dev/null and b/millennium-legacy/resources/textures/grass.png differ diff --git a/millennium-legacy/src/map.txt b/millennium-legacy/src/map.txt new file mode 100644 index 0000000..ec336db --- /dev/null +++ b/millennium-legacy/src/map.txt @@ -0,0 +1,16 @@ +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww +ggggggggggggggggggggggg +wwwwwwwwwwwwwwwwwwwwwww diff --git a/millennium-legacy/src/milleniumlegacy/Algorithm.java b/millennium-legacy/src/milleniumlegacy/Algorithm.java new file mode 100644 index 0000000..d469134 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/Algorithm.java @@ -0,0 +1,35 @@ +package milleniumlegacy; + + +public class Algorithm { + + public static String research() { + String[] pSelect1 = Item.items.get(1); //1 = player input + String[] pSelect2 = Item.items.get(2); //2 = second player input + Object[] keyArray = Item.items.keySet().toArray(); + String Num1 = pSelect1[0]; + String Num2 = pSelect2[0]; + String Name1 = pSelect1[1]; + String Name2 = pSelect2[1]; + String TP1 = pSelect1[2]; + String TP2 = pSelect2[2]; + for(int i = 1; i <= keyArray.length;i++) { + String[] Craftable = Item.items.get(i); + String Craft1 = Craftable[4]; + String Craft2 = Craftable[5]; + if ((Craft1.equals(Name1) || Craft2.equals(Name2)) && + (Craft1.equals(Name2) || Craft2.equals(Name1))) { + String[] getNewItem = Item.items.get(i); + //TODO + + } + } + int rand = (int)(Math.random() * (100)); + int Prob = rand; + + return Name2; + } + + + +} diff --git a/millennium-legacy/src/milleniumlegacy/GUI.java b/millennium-legacy/src/milleniumlegacy/GUI.java new file mode 100644 index 0000000..d99a58f --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/GUI.java @@ -0,0 +1,52 @@ +package milleniumlegacy; + +<<<<<<< HEAD +import java.awt.Component; +import java.awt.Graphics; +import java.util.HashMap; + +import javax.imageio.ImageIO; +======= +>>>>>>> 357779b2c6cc94e69241d389a64fa3959453599f +import javax.swing.*; + +public class GUI { + + public static void main(String[] args) { +<<<<<<< HEAD + JFrame f = new JFrame("Millenium Legacy"); + f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + f.setContentPane(new JPanel() { + public void paintComponent(Graphics g) { + super.paintComponent(g); + } + }); + f.setResizable(false); + f.pack(); + f.setSize(825, 625); + f.setVisible(true); + Algorithm.research(); +======= + SwingUtilities.invokeLater(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + + } + public static void createAndShowGUI() + { + JFrame f = new JFrame("Millenium Legacy"); + MainGame draw = new MainGame(); + f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + f.getContentPane().add(draw); + f.setResizable(false); + f.pack(); + f.setSize(825, 625); + f.setVisible(true); + draw.start(); +>>>>>>> 357779b2c6cc94e69241d389a64fa3959453599f + } + +} + diff --git a/millennium-legacy/src/milleniumlegacy/ImageLoader.java b/millennium-legacy/src/milleniumlegacy/ImageLoader.java new file mode 100644 index 0000000..4845cb8 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/ImageLoader.java @@ -0,0 +1,21 @@ +package milleniumlegacy; + +import java.awt.image.BufferedImage; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageLoader +{ + public BufferedImage loadImage (String path) + { + try { + BufferedImage bi = ImageIO.read(getClass().getResourceAsStream(path)); + return bi; + } catch (IOException e) { + System.out.println("Error loading Image"); + } + return null; + + } +} diff --git a/millennium-legacy/src/milleniumlegacy/Item.java b/millennium-legacy/src/milleniumlegacy/Item.java new file mode 100644 index 0000000..89d827f --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/Item.java @@ -0,0 +1,16 @@ +package milleniumlegacy; +import java.util.*; + +public class Item { + + public static final Map items; + static + { + //Putting items + items = new HashMap(); + items.put(1, new String[] {"1","Dirt", "Universal"}); + items.put(2, new String[] {"2","Water","Universal"}); + items.put(3, new String[] {"3","Clay","Medieval", "99"}); + } + +} diff --git a/millennium-legacy/src/milleniumlegacy/KeyManager.java b/millennium-legacy/src/milleniumlegacy/KeyManager.java new file mode 100644 index 0000000..afcd42b --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/KeyManager.java @@ -0,0 +1,58 @@ +package milleniumlegacy; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class KeyManager implements KeyListener +{ + + @Override + public void keyPressed(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_W) + { + MainGame.up = true; + } + if (e.getKeyCode() == KeyEvent.VK_S) + { + MainGame.down = true; + } + if (e.getKeyCode() == KeyEvent.VK_A) + { + MainGame.left = true; + } + if (e.getKeyCode() == KeyEvent.VK_D) + { + MainGame.right = true; + } + } + + @Override + public void keyReleased(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_W) + { + MainGame.up = false; + } + if (e.getKeyCode() == KeyEvent.VK_S) + { + MainGame.down = false; + } + if (e.getKeyCode() == KeyEvent.VK_A) + { + MainGame.left = false; + } + if (e.getKeyCode() == KeyEvent.VK_D) + { + MainGame.right = false; + } + + } + + @Override + public void keyTyped(KeyEvent arg0) { + + + } + +} diff --git a/millennium-legacy/src/milleniumlegacy/MainGame.java b/millennium-legacy/src/milleniumlegacy/MainGame.java new file mode 100644 index 0000000..00bdb18 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/MainGame.java @@ -0,0 +1,82 @@ +package milleniumlegacy; + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Toolkit; +import java.awt.image.BufferStrategy; +import java.awt.image.BufferedImage; +import java.util.ArrayList; + +public class MainGame extends Canvas implements Runnable +{ + private static final long serialVersionUID = -1902119798739765822L; + ImageLoader IL = new ImageLoader(); + BufferedImage player = IL.loadImage("Untitled.png"); + KeyManager km; + ArrayList map = Map.readyMap(); + Thread main; + public static boolean up, down, left, right, running; + int offsetx, offsety; + public void init() + { + km = new KeyManager(); + this.addKeyListener(km); + } + public void paintComponent() + { + BufferStrategy bs = this.getBufferStrategy(); + if (bs == null) + { + createBufferStrategy(3); + return; + } + Graphics g = bs.getDrawGraphics(); + g.setColor(Color.blue); + g.fillRect(0, 0, Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); + g.setColor( Color.BLACK ); + for (Tile t : map) + { + t.Render(g, offsetx, offsety); + } + g.drawImage(player, 200,300, null); + g.dispose(); + bs.show(); + } + public void tick() + { + if (up) + { + offsety++; + } + if (down) + { + offsety--; + } + if (left) + { + offsetx++; + } + if (right) + { + offsetx--; + } + } + public void start() + { + main = new Thread(this); + main.start(); + running = true; + + } + @Override + public void run() { + init(); + while (running) + { + paintComponent(); + tick(); + } + + } +} diff --git a/millennium-legacy/src/milleniumlegacy/Map.java b/millennium-legacy/src/milleniumlegacy/Map.java new file mode 100644 index 0000000..81bf414 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/Map.java @@ -0,0 +1,26 @@ +package milleniumlegacy; + +import java.util.ArrayList; + +public class Map +{ + static MapLoader ml = new MapLoader(); + public static ArrayList readyMap() + { + ArrayList tiles = new ArrayList(); + char[][] map = ml.LoadMap("map.txt"); + int countery = 0, counterx = 0; + for (char[] chararr : map) + { + countery++; + for (char c: chararr) + { + counterx++; + System.out.println(counterx); + tiles.add(new Tile(counterx, countery, c)); + } + counterx = 0; + } + return tiles; + } +} diff --git a/millennium-legacy/src/milleniumlegacy/MapLoader.java b/millennium-legacy/src/milleniumlegacy/MapLoader.java new file mode 100644 index 0000000..9ee45d0 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/MapLoader.java @@ -0,0 +1,64 @@ +package milleniumlegacy; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +public class MapLoader { + + public char[][] LoadMap(String path) { + ArrayList lines = new ArrayList(); + BufferedReader br; + File map = new File(path); + + try { + FileReader fr = new FileReader(map); + br = new BufferedReader(fr); + String line; + while ((line = br.readLine()) != null) + { + lines.add(line); + } + char[][] maparr = new char[lines.size()][lines.get(0).toCharArray().length]; + for (int y = 0; y <= lines.size() - 1; y++) + { + char[] chararr = lines.get(y).toCharArray(); + for (int x = 0; x <= lines.get(0).toCharArray().length - 1; x++) + { + System.out.println("X: " + x + "Y: " + y); + maparr[y][x] = lines.get(y).toCharArray()[x]; + } + } + br.close(); + return maparr; + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + public static int countLines(String filename) throws IOException { + InputStream is = new BufferedInputStream(new FileInputStream(filename)); + try { + byte[] c = new byte[1024]; + int count = 0; + int readChars = 0; + boolean empty = true; + while ((readChars = is.read(c)) != -1) { + empty = false; + for (int i = 0; i < readChars; ++i) { + if (c[i] == '\n') { + ++count; + } + } + } + return (count == 0 && !empty) ? 1 : count; + } finally { + is.close(); + } + } // Thank you google +} diff --git a/millennium-legacy/src/milleniumlegacy/OptionsPane.java b/millennium-legacy/src/milleniumlegacy/OptionsPane.java new file mode 100644 index 0000000..9cbffaf --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/OptionsPane.java @@ -0,0 +1,5 @@ +package milleniumlegacy; + +public class OptionsPane { + +} diff --git a/millennium-legacy/src/milleniumlegacy/Tile.java b/millennium-legacy/src/milleniumlegacy/Tile.java new file mode 100644 index 0000000..91f941c --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/Tile.java @@ -0,0 +1,31 @@ +package milleniumlegacy; + +import java.awt.Color; +import java.awt.Graphics; + +public class Tile +{ + int x,y; + char terrain; + boolean up, down, left, right; + int offsetx; + int offsety; + public Tile(int x, int y, char terrain) + { + this.x = x; + this.y = y; + this.terrain = terrain; + } + public void Render(Graphics g, int offsetx, int offsety) + { + if (terrain == 'g') + { + g.setColor(Color.GREEN); + } + else + { + g.setColor(Color.BLUE); + } + g.fillRect(x*16 + offsetx, y*16 + offsety, 16,16); + } +} diff --git a/millennium-legacy/src/milleniumlegacy/player.java b/millennium-legacy/src/milleniumlegacy/player.java new file mode 100644 index 0000000..0234242 --- /dev/null +++ b/millennium-legacy/src/milleniumlegacy/player.java @@ -0,0 +1,20 @@ +package milleniumlegacy; + +import java.awt.Graphics; +import java.awt.image.BufferedImage; + +public class player +{ + int x, y; + BufferedImage player; + public player(int x, int y, ImageLoader IL) + { + this.x = x; + this.y = y; + player = IL.loadImage("Untitled.png"); + } + public void render(Graphics g) + { + g.drawImage(player, x, y, null); + } +}