code day done

This commit is contained in:
ksjdragon 2015-02-15 07:38:55 -05:00
parent 70fe05ca91
commit b3c8b1f7d0
87 changed files with 757 additions and 102 deletions

2
millennium-legacy/.classpath Executable file → Normal file
View File

@ -1,6 +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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
millennium-legacy/.project Executable file → Normal file
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>millennium-legacy</name>
<name>EYSnotBroken</name>
<comment></comment>
<projects>
</projects>

6
millennium-legacy/.settings/org.eclipse.jdt.core.prefs Executable file → Normal file
View File

@ -1,11 +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.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.8
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
org.eclipse.jdt.core.compiler.source=1.8

0
millennium-legacy/README.md Executable file → Normal file
View File

Binary file not shown.

View File

@ -0,0 +1,16 @@
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww

BIN
millennium-legacy/bin/milleniumlegacy/Algorithm.class Executable file → Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/GUI$1.class Executable file → Normal file

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/GUI.class Executable file → Normal file

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/ImageLoader.class Executable file → Normal file

Binary file not shown.

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/Item.class Executable file → Normal file

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/KeyManager.class Executable file → Normal file

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/MapLoader.class Executable file → Normal file

Binary file not shown.

BIN
millennium-legacy/bin/milleniumlegacy/OptionsPane.class Executable file → Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,100 @@
---------------------g-------------------------------------------------------------------------www--
---------------------rr-----------------------------------------------------------------------wwwww-
--------------------rrr---------------------www-----------------------------------------------wwwww-
--------------------rr---------------------wwwww----------rr----------------------------------wwwww-
--------------------gr---------------------wwwww----------rr-----------------------------------www--
-------------------------------------------wwwww---------grr----------------------------------------
--------------------------------------------wwwcc---------------------------------------------------
-----------------------------------------------c----------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
--------------------------------------------c-------------------------------------------------------
-------------------------------------------ccwww----------------------------------------------------
--------------------------------------------wwwww---------------------------------------------------
--------------------------------------------wwwww---------------------------------------------------
--------------------------------------------wwwww---------------------------------------------------
---------------------------------------------www----------------------------------------------------
----------------------------------------------------------------------------------------------------
-----rr---------------------------------------------------------------------------------------------
-------r--------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------c-www-------
---------------------------------------------------------------------------------------ccwwwww------
----------------------------------------------------------------------------------------cwwwww------
-----------------------------------------------------------------------------------------wwwww------
------------------------------------------------------------------------------------------www-------
---------------------------------------------g------------------------------------------------------
---------------------------------------------rr----------www----------------------------------------
----------------------------------------------rr--------wwwwwc--------------www---------------------
--------------------------------------------grr---------wwwwwcc------------wwwww--------------------
--------------------------------------------------------wwwwwc------------cwwwww--------------------
---------------------------------------------------------www-------------ccwwwww--------------------
--------------------------------------------------------------------------c-www---------------------
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------g---------------------------
------------------------------------------------------------------------rr--------------------------
-----------------------------------------------------------------------rrg--------------------------
-----------------------------------------------------------------------grr--------------------------
---------------------------------------------rg-----------------------------------------------------
-------------------------------------------grrr-----------------------------------------------------
-------------------------------------------grr------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------rrrg------------------
-------------------------------------------------------r----------------------rrg-------------------
-----------------------------------------------------grrr---------------------grr-------------------
-------------------------------------------rr--------grrrg------------------------------------------
-------------------------------------------rr----------g--------------------------------------------
rr-----------------------------------------rr-------------------------------------------------------
rrr----------www------------------------------------------------------------------------------------
-rg---------wwwww-----------------------------------------------------------------------------------
-g---------cwwwww-----------------------------------------------------------------------------------
----------ccwwwww-----------------------------------------------------------------------------------
-----------ccwww------------------------------------------------------------------------------------
------------c---------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------rrr---------------------------------------------------------------------------------------
----------rrr------------------rrr------------------------------------------------------------------
----------rrr-----------------wrrrw-----------------------------------------------------------------
------------g-----------------wwrrw-----------------------------------------------------------------
------------------------------wwwww-----------------------------------------------------------------
-------------------------------www------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
---------------------------------------------------c------------------------------------------------
------------------------------------------------wwwcc-----------------------------------------------
-----------------------------------------------wwwwwc-----------------------------------------------
-----------------------------------------------wwwwwcc----------------------------------------------
-----------------------------------------------wwwwwc-----------------------------------------------
------------------------------------------------www-------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
------------------c----------------------------c-------------------c--------------------------------
-----------------gcg---------g------g---------ccc-----------------ccc-------g--g----c---------------
----gwwwww-----wwwww----gwwwww----gwwwww-----wwwww-----wwwwwg---gwwwww-----wwwww---ccwwwww-----wwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwg----wwwwwg-gggwwwww-----wwwwwcc---wwwww-----wwwww----gwwwww-g---wwwwwg----wwwww-----wwwwwg----
-----------------------------------c-----------------------ccg--------------------------------------
------------------------------------------------------------c---------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-----------------------------------rr---------------------------------------------------------------
-----------------------------------grr--------------------------------------------------------------
-----------------------------------rrr--------------------------------------------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

0
millennium-legacy/resources/sprites/player.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 440 B

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
millennium-legacy/resources/textures/grass.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,16 @@
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww
ggggggggggggggggggggggg
wwwwwwwwwwwwwwwwwwwwwww

79
millennium-legacy/src/milleniumlegacy/Algorithm.java Executable file → Normal file
View File

@ -1,35 +1,60 @@
package milleniumlegacy;
public class Algorithm
{
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
public static void research(int pSelect1, int pSelect2)
{
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
}*/
for (int i = 1; i <= keyArray.length; i++)
{
String[] Craftable = (String[])Item.items.get(i);
int Craft1int = Integer.parseInt(Craftable[4]);
int Craft2int = Integer.parseInt(Craftable[6]);
int rand = (int) (Math.random() * (100));
int Prob = rand;
if ((Craft1int == pSelect1 || Craft1int == pSelect2) &&
(Craft2int == pSelect1 || Craft2int == pSelect2))
{
String[] requisite = (String[]) Item.items.get(i);
int current1 = Inventory.inventory.get(pSelect1);
int current2 = Inventory.inventory.get(pSelect2);
int requisite1 = Integer.parseInt(requisite[3]);
int requisite2 = Integer.parseInt(requisite[5]);
if ((current1 >= requisite1 && current2 >= requisite2) )
{
if ((current1 -= requisite1) <= 0)
{
Inventory.inventory.remove(pSelect1);
Research.squareOffset+=2;
}
else{
Inventory.inventory.put(pSelect1, current1 -= requisite1);
}
if ((current2 -= requisite2) <= 0)
{
Inventory.inventory.remove(pSelect2);
Research.squareOffset+=2;
}
else{
Inventory.inventory.put(pSelect2, current2 -= requisite2);
}
int craftability = Integer.parseInt(requisite[2]);
if (Prob <= craftability)
{
int outputnum = Integer.parseInt(requisite[7]);
Inventory.addItem(i, outputnum);
break;
} else {
break;
}
} else {
break;
}
}
}
int rand = (int)(Math.random() * (100));
int Prob = rand;
return Name2;
}
}
}

View File

@ -0,0 +1,32 @@
package milleniumlegacy;
import java.awt.image.BufferedImage;
public class Animation
{
BufferedImage[] imagearray;
int[] time;
int counter;
public Animation(BufferedImage[] imagearray, int[] time)
{
this.imagearray = imagearray;
this.time = time;
}
public Animation(BufferedImage[] imagearray)
{
this.imagearray = imagearray;
}
public BufferedImage animate()
{
if (counter < imagearray.length - 1)
{
counter++;
}
else
{
counter = 0;
}
BufferedImage temp = imagearray[counter];
return temp;
}
}

View File

@ -0,0 +1,61 @@
package milleniumlegacy;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
public class Button
{
int x,y,width,height,ButtonID;
public boolean selected1;
public Button(int x, int y, int width, int height, int ButtonID)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.ButtonID = ButtonID;
}
public Rectangle getBounds()
{
return new Rectangle(x,y,width,height);
}
public void clicked(Rectangle MouseRectangle)
{
if (MouseRectangle.intersects(this.getBounds()))
{
if (!Research.selected1)
{
if (Inventory.inventory.size() >= ButtonID)
{
Research.selectionOne(Inventory.getIdFromButton(ButtonID));
selected1 =true;
}
}
else if (Research.selected1)
{
if (Inventory.inventory.size() >= ButtonID)
{
Research.selectionTwo(Inventory.getIdFromButton(ButtonID));
}
}
}
}
public void ResearchButton(Rectangle MouseRect)
{
if (MouseRect.intersects(this.getBounds()))
{
if (Research.selected1 && Research.selected2)
{
Algorithm.research(Research.selection1, Research.selection2);
Research.reset();
}
}
}
public void render(Graphics g)
{
g.setColor(Color.GRAY);
g.fillRect(x,y,width,height);
}
}

View File

@ -0,0 +1,5 @@
package milleniumlegacy;
public class ClanHandler {
}

24
millennium-legacy/src/milleniumlegacy/GUI.java Executable file → Normal file
View File

@ -1,19 +1,23 @@
package milleniumlegacy;
import java.awt.Component;
import java.awt.Graphics;
import java.util.HashMap;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
public class GUI {
public static JFrame f;
public static void main(String[] args) {
Algorithm.research();
try
{
Process process = new ProcessBuilder("WorldGenerator.exe","","").start();
}
catch (IOException e)
{
e.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
@ -23,7 +27,7 @@ public class GUI {
}
public static void createAndShowGUI()
{
JFrame f = new JFrame("Millenium Legacy");
f = new JFrame("Millenium Legacy");
MainGame draw = new MainGame();
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.getContentPane().add(draw);

View File

@ -0,0 +1,62 @@
package milleniumlegacy;
import java.awt.image.BufferedImage;
public class ImageHandler
{
static ImageLoader IL = new ImageLoader();
static BufferedImage[] imageArray = {
IL.loadImage("resources/sprites/dirt.png"),
IL.loadImage("resources/sprites/water.png"),
IL.loadImage("resources/sprites/clay.png"),
IL.loadImage("resources/textures/gravel.png"),
IL.loadImage("resources/textures/rock.png"),
IL.loadImage("resources/sprites/plant.png"),
IL.loadImage("resources/sprites/iron.png"),
IL.loadImage("resources/sprites/fire.png"),
IL.loadImage("resources/sprites/fridge.png"),
IL.loadImage("resources/sprites/ice.png"),
IL.loadImage("resources/sprites/fire.png"),
IL.loadImage("resources/sprites/flower.png"),
IL.loadImage("resources/sprites/garden.png"),
IL.loadImage("resources/sprites/metal.png"),
IL.loadImage("resources/sprites/plastic.png"),
IL.loadImage("resources/sprites/sugar.png"),
IL.loadImage("resources/sprites/arsenic.png"),
IL.loadImage("resources/sprites/food.png"),
IL.loadImage("resources/sprites/house.png"),
IL.loadImage("resources/sprites/suburb.png"),
IL.loadImage("resources/sprites/city.png"),
IL.loadImage("resources/sprites/garden.png"),
IL.loadImage("resources/sprites/electricity.png"),
IL.loadImage("resources/sprites/supercomputer.png"),
IL.loadImage("resources/sprites/supercomputer.png"),
IL.loadImage("resources/sprites/quantumcomputer.png"),
IL.loadImage("resources/sprites/timemachine.png")
};
static BufferedImage[] waterArray = {
IL.loadImage("resources/textures/water0.png"),
IL.loadImage("resources/textures/water1.png"),
IL.loadImage("resources/textures/water2.png"),
IL.loadImage("resources/textures/water3.png"),
IL.loadImage("resources/textures/water4.png"),
IL.loadImage("resources/textures/water5.png"),
IL.loadImage("resources/textures/water6.png"),
IL.loadImage("resources/textures/water7.png"),
IL.loadImage("resources/textures/water8.png"),
IL.loadImage("resources/textures/water9.png")
};
public static BufferedImage Grass = IL.loadImage("resources/textures/grass.png");
public static BufferedImage Gravel = IL.loadImage("resources/textures/gravel.png");
public static BufferedImage Rock = IL.loadImage("resources/textures/rock.png");
public static BufferedImage Clay = IL.loadImage("resources/textures/clay.png");
public static BufferedImage Water = IL.loadImage("resources/textures/water.gif");
public static BufferedImage Hotbar = IL.loadImage("resources/gui/hotbar.png");
public static BufferedImage researchMenu = IL.loadImage("resources/gui/research.png");
public static BufferedImage getImage(int num)
{
return imageArray[num];
}
}

View File

@ -11,7 +11,7 @@ public class ImageLoader
public BufferedImage loadImage (String path)
{
try {
BufferedImage bi = ImageIO.read(new FileInputStream("resources/sprites/player.png"));
BufferedImage bi = ImageIO.read(new FileInputStream(path));
return bi;
} catch (IOException e) {
System.out.println("Error loading Image");

View File

@ -1,16 +1,89 @@
package milleniumlegacy;
import java.util.HashMap;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Hashtable;
public class Inventory {
public static final HashMap<Integer, String[]> items;
public static final Hashtable<Integer, Integer> inventory;
public static boolean shouldRender = true;
static
{
//Putting items
items = new HashMap<Integer, String[]>();
items.put(1, new String[] {"1","Dirt", "Universal",null,null,null});
items.put(2, new String[] {"2","Water","Universal",null,null,null});
items.put(3, new String[] {"3","Clay","Medieval", "99","Dirt","Water"});
inventory = new Hashtable<Integer, Integer>();
}
public static void addItem(int id, int amount)
{
if (inventory.containsKey(id))
{
int current = inventory.get(id);
if (current <= 998)
{
inventory.put(id, current+=1);
}
else
{
inventory.put(id, 999);
}
}
else
{
inventory.put(id, amount);
}
}
public static int getIdFromButton(int Button)
{
int counter = 0;
if (inventory.size() >= Button)
{
for (int i = 0; i <= 100; i++)
{
if (inventory.containsKey(i))
{
counter++;
if (counter == Button)
{
return i;
}
}
}
}
return Button;
}
public static void render(Graphics g)
{
if (shouldRender)
{
g.drawImage(ImageHandler.Hotbar, 180, 548, 464, 48, null);
int offset = 0;
for (int i = 0; i <= 100; i++)
{
if (inventory.containsKey(i))
{
g.drawImage(ImageHandler.getImage(i - 1), 188 + offset, 556, 32, 32, null);
g.setColor(Color.cyan);
if (inventory.get(i) > 99)
{
g.drawString("" + inventory.get(i), 188+offset + 4, 564);
}
else if (inventory.get(i) > 9)
{
g.drawString("" + inventory.get(i), 188+offset + 8, 564);
}
else
{
g.drawString("" + inventory.get(i), 188+offset + 12, 564);
}
offset += (41 + 1);
}
}
}
}
}

30
millennium-legacy/src/milleniumlegacy/Item.java Executable file → Normal file
View File

@ -8,9 +8,33 @@ public class Item {
{
//Putting items
items = new HashMap<Integer, String[]>();
items.put(1, new String[] {"1","Dirt", "Universal",null,null,null});
items.put(2, new String[] {"2","Water","Universal",null,null,null});
items.put(3, new String[] {"3","Clay","Medieval", "99","Dirt","Water"});
items.put(1, new String[] {"1","Dirt","0","0","0","0","0","0"});
items.put(2, new String[] {"2","Water","0","0","0","0","0","0"});
items.put(3, new String[] {"3","Clay", "99","1","1","1","2","1"});
items.put(4, new String[] {"4","Gravel", "0","0","0","0","0","0"});
items.put(5, new String[] {"5","Rock", "0","0","0","0","0","0"});
items.put(6, new String[] {"6","Plant", "90","1","1","1","4","1"});
items.put(7, new String[] {"7","Iron", "70","1","3","3","2","1"});
items.put(8, new String[] {"8","Fire", "90","1","6","2","2","1"});
items.put(9, new String[] {"9","Fridge", "50","3","8","1","7","1"});
items.put(10, new String[] {"10","Ice", "70","4","5","5","8","1"});
items.put(11, new String[] {"11","Furnace", "60","3","10","2","6","1"});
items.put(12, new String[] {"12","Flower", "80","3","7","1","6","1"});
items.put(13, new String[] {"13","Garden", "75","12","12","10","3","1"});
items.put(14, new String[] {"14","Metal", "70","4","13","1","20","50"});
items.put(15, new String[] {"15","Plastic", "60","3","14","5","2","1"});
items.put(16, new String[] {"16","Sugar", "90","2","15","7","5","10"});
items.put(17, new String[] {"17","Arsenic", "80","3","16","6","3","1"});
items.put(18, new String[] {"18","Food", "90","1","17","6","22","10"});
items.put(19, new String[] {"19","House", "90","3","10","4","8","1"});
items.put(20, new String[] {"20","Suburb", "65","30","19","3","13","1"});
items.put(21, new String[] {"21","City", "75","1","20","20","19","1"});
items.put(22, new String[] {"22","Farm", "100","5","13","25","6","1"});
items.put(23, new String[] {"23","Electricity", "90","32","18","2","7","20"});
items.put(24, new String[] {"24","Computer", "85","60","23","3","10","1"});
items.put(25, new String[] {"25","Super Computer", "90","100","24","10","21","1"});
items.put(26, new String[] {"26","Quantum Computer", "90","10","25","4","11","1"});
items.put(27, new String[] {"27","Time Machine", "30","20","26","45","8","1"});
}
}

View File

@ -27,7 +27,19 @@ public class KeyManager implements KeyListener
}
if (e.getKeyCode() == KeyEvent.VK_SPACE)
{
MainGame.getPlayer().Add();
}
if (e.getKeyCode() == KeyEvent.VK_R){
if (Research.shouldRender)
{
Research.shouldRender = false;
Inventory.shouldRender = true;
}
else
{
Research.shouldRender = true;
Inventory.shouldRender = false;
}
}
}

View File

@ -5,24 +5,28 @@ 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();
KeyManager km;
player ply = new player(375, 300, IL);
ArrayList<Tile> map = Map.readyMap();
Thread main;
public static Tile[][] map = Map.readyMap();
public static boolean up, down, left, right, running;
public static int offsetx, offsety;
public static int offsetx = 50 * -48, offsety = 50 * -48, speed = 10;;
static ImageLoader IL = new ImageLoader();
static player ply = new player(375, 300, IL);
KeyManager km;
MouseManager mm;
Thread main;
Research re = new Research();
public void init()
{
km = new KeyManager();
this.addKeyListener(km);
mm = new MouseManager();
this.addMouseListener(mm);
}
public void render()
@ -38,32 +42,46 @@ public class MainGame extends Canvas implements Runnable
g.fillRect(0, 0, Toolkit.getDefaultToolkit().getScreenSize().width,
Toolkit.getDefaultToolkit().getScreenSize().height);
g.setColor(Color.BLACK);
for (Tile t : map)
for (Tile[] ta : map)
{
t.Render(g, offsetx, offsety);
for (Tile t : ta)
{
t.Render(g, offsetx, offsety);
}
}
ply.render(g);
Inventory.render(g);
re.render(g);
g.dispose();
bs.show();
}
public void tick()
{
if (up)
ply.tick();
if (up && offsety <= 0)
{
offsety += 3;
offsety += speed;
}
if (down)
if (down && offsety >= 86*-48)
{
offsety -= 3;
offsety -= speed;
}
if (left)
if (left && offsetx <= 0)
{
offsetx += 3;
offsetx += speed;
}
if (right)
if (right && offsetx >= 81*-48)
{
offsetx -= 3;
offsetx -= speed;
}
if (ply.getTile() != "1")
{
speed = 5;
}
else
{
speed = 10;
}
}
@ -103,8 +121,6 @@ public class MainGame extends Canvas implements Runnable
if (System.currentTimeMillis() - timer > 1000)
{
timer += 1000;
System.out.println(updates + " Ticks, Fps " + frames);
ply.getPosition();
updates = 0;
frames = 0;
}
@ -112,4 +128,9 @@ public class MainGame extends Canvas implements Runnable
}
}
public static player getPlayer()
{
return ply;
}
}

View File

@ -4,23 +4,27 @@ import java.util.ArrayList;
public class Map
{
static ImageLoader IL = MainGame.IL;
static MapLoader ml = new MapLoader();
public static ArrayList<Tile> readyMap()
public static Tile[][] readyMap()
{
ArrayList<Tile> tiles = new ArrayList<Tile>();
char[][] map = ml.LoadMap("resources/maps/map.txt");
Tile[][] mappp;
ArrayList<ArrayList<Tile>> tilesy = new ArrayList<ArrayList<Tile>>();
ArrayList<Tile> tilesx = new ArrayList<Tile>();
char[][] map = ml.LoadMap("milleniumWorld.txt");
mappp = new Tile[map.length][map[0].length];
int countery = 0, counterx = 0;
for (char[] chararr : map)
{
countery++;
for (char c: chararr)
{
mappp[counterx][countery] = new Tile(counterx, countery, c, IL);
counterx++;
System.out.println(counterx);
tiles.add(new Tile(counterx, countery, c));
}
countery++;
counterx = 0;
}
return tiles;
return mappp;
}
}

2
millennium-legacy/src/milleniumlegacy/MapLoader.java Executable file → Normal file
View File

@ -27,10 +27,8 @@ public class MapLoader {
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];
}
}

View File

@ -0,0 +1,56 @@
package milleniumlegacy;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class MouseManager implements MouseListener
{
@Override
public void mouseClicked(MouseEvent e)
{
}
@Override
public void mouseEntered(MouseEvent e)
{
}
@Override
public void mouseExited(MouseEvent e)
{
}
@Override
public void mousePressed(MouseEvent e)
{
Research.button.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button2.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button3.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button4.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button5.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button6.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button7.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button8.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button9.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.button10.clicked(new Rectangle(e.getX(),e.getY(),1,1));
Research.rb.ResearchButton(new Rectangle(e.getX(),e.getY(),1,1));
if (Research.selected1 && !Research.button.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button3.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button4.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button5.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button6.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button7.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button8.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button9.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button2.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) && !Research.button10.getBounds().intersects(new Rectangle(e.getX(),e.getY(),1,1)) )
{
Research.reset();
}
}
@Override
public void mouseReleased(MouseEvent e)
{
}
}

0
millennium-legacy/src/milleniumlegacy/OptionsPane.java Executable file → Normal file
View File

View File

@ -0,0 +1,91 @@
package milleniumlegacy;
import java.awt.Color;
import java.awt.Graphics;
public class Research
{
public static boolean shouldRender, selected1, selected2;
static int x = 80;
public static int squareOffset = 1;
static int selection1;
static int selection2;
String update = "";
static String SelectOne = "";
static String SelectTwo = "";
public static Button button = new Button(x,433,48,48, 1);
public static Button button2 = new Button(x += 69,433,48,48, 2);
public static Button button3 = new Button(x += 69,433,48,48, 3);
public static Button button4 = new Button(x += 70,433,48,48, 4);
public static Button button5 = new Button(x += 70,433,48,48, 5);
public static Button button6 = new Button(x += 70,433,48,48, 6);
public static Button button7 = new Button(x += 69,433,48,48, 7);
public static Button button8 = new Button(x += 69,433,48,48, 8);
public static Button button9 = new Button(x += 69,433,48,48, 9);
public static Button button10 = new Button(x += 70,433,48,48, 10);
public static Button rb = new Button(75, 120, 260,260, 11);
public void render(Graphics g)
{
if (shouldRender)
{
g.drawImage(ImageHandler.researchMenu, 25, 25, 775, 500, null);
int offset = 0;
button.render(g);
button2.render(g);
button3.render(g);
button4.render(g);
button5.render(g);
button6.render(g);
button7.render(g);
button8.render(g);
button9.render(g);
button10.render(g);
rb.render(g);
for (int i = 0; i <= 100; i++)
{
if (Inventory.inventory.containsKey(i))
{
g.drawImage(ImageHandler.getImage(i - 1), 80 + offset, 433, 48, 48, null);
g.setColor(Color.WHITE);
g.drawString("Amount: " + Inventory.inventory.get(i), 80 + offset, 430);
if (offset == 0)
{
offset += 68;
}
else
{
offset+=70;
}
}
}
g.setColor(Color.WHITE);
g.drawString(SelectOne, 385, 180);
g.drawString(SelectTwo, 385, 300);
g.drawString("Research", 100,200);
}
}
public static void selectionOne(int id)
{
selection1 = id;
selected1 = true;
SelectOne =Item.items.get(id)[1];
System.out.println(id);
}
public static void selectionTwo(int id)
{
selection2 = id;
selected2 = true;
SelectTwo =Item.items.get(id)[1];
//Algorithm.research(selection1, selection2);
}
public static void reset()
{
selected2 = false;
selected1 = false;
SelectTwo = "";
SelectOne = "";
}
}

View File

@ -0,0 +1,20 @@
package milleniumlegacy;
import java.awt.Rectangle;
public class SolidTile extends Tile
{
int x, y;
public SolidTile(int x, int y, char terrain, ImageLoader IL )
{
super(x, y, terrain, IL);
this.x = x;
this.y = y;
}
public Rectangle getBounds()
{
return new Rectangle(x * 42, y * 42, 42,42);
}
}

View File

@ -2,6 +2,7 @@ package milleniumlegacy;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class Tile
{
@ -10,33 +11,55 @@ public class Tile
boolean up, down, left, right;
int offsetx;
int offsety;
public Tile(int x, int y, char terrain)
BufferedImage TileImage;
String name;
Animation waterAnimation = new Animation(ImageHandler.waterArray);
public Tile(int x, int y, char terrain, ImageLoader IL)
{
this.x = x;
this.y = y;
this.terrain = terrain;
switch(terrain)
{
case '-':
this.name="1";
TileImage = ImageHandler.Grass;
break;
case 'w':
this.name="2"; //get water
TileImage = ImageHandler.Water;
break;
case 'r':
this.name="5";
TileImage = ImageHandler.Rock;
break;
case 'g':
this.name="4";
TileImage = ImageHandler.Gravel;
break;
case 'c':
this.name="3";
TileImage = ImageHandler.Clay;
break;
}
}
public void Render(Graphics g, int offsetx, int offsety)
{
if (terrain == 'd')
if (name.equals("2"))
{
g.drawImage(waterAnimation.animate(), x*48 + offsetx- 48, y*48 + offsety - 48, 48,48, null);
}
else if (TileImage != null)
{
g.setColor(Color.GREEN);
}
else if (terrain == 'r')
{
g.setColor(Color.DARK_GRAY);
}
else if (terrain == 'c')
{
g.setColor(Color.gray);
g.drawImage(TileImage, x*48 + offsetx- 48, y*48 + offsety - 48, 48,48, null);
}
else
{
g.setColor(Color.blue);
g.drawRect(x*48 + offsetx - 48, y*48 + offsety - 48, 48,48);
}
g.fillRect(x*32 + offsetx - 32, y*32 + offsety - 32, 32,32);
String draw = "x" + x + "y" + y;
g.setColor(Color.black);
g.drawString(draw, x*32 + offsetx - 32, y*32 + 8 + offsety - 32);
g.setColor(Color.white);
//g.drawString(draw, x*48 + offsetx - 48, y*48 + 8 + offsety - 48);
}
}

View File

@ -1,6 +1,7 @@
package milleniumlegacy;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
public class player
@ -8,24 +9,35 @@ public class player
int x, y;
int drawx, drawy;
BufferedImage player;
Rectangle bounds;
public player(int x, int y, ImageLoader IL)
{
this.drawx = x;
this.drawy = y;
player = IL.loadImage("../resources/sprites/player.png");
player = IL.loadImage("resources/sprites/player.png");
}
public void tick()
{
x = ((MainGame.offsetx * -1)+ drawx);
y = ((MainGame.offsety * -1) + drawy);
bounds = new Rectangle(x - 27,y - 27, 54,54);
}
public void render(Graphics g)
{
g.drawImage(player, drawx, drawy, null);
}
public void getPosition()
public String getTile()
{
int x = ((MainGame.offsetx * -1)+ drawx + 16) / 32 + 1;
int y = ((MainGame.offsety * -1) + drawy + 16) / 32 + 1;
System.out.println("X: " + x + "Y: " + y);
int x = ((MainGame.offsetx * -1)+ drawx + 16) / 48 + 1;
int y = ((MainGame.offsety * -1) + drawy + 16) / 48 + 1;
return MainGame.map[x][y].name;
}
public String Add()
{
int x = ((MainGame.offsetx * -1)+ drawx + 16) / 48 + 1;
int y = ((MainGame.offsety * -1) + drawy + 16) / 48 + 1;
Inventory.addItem(Integer.parseInt(MainGame.map[x][y].name), 1);
System.out.println(Inventory.inventory);
return MainGame.map[x][y].name;
}
}