stuff
parent
172ffbc4aa
commit
a69dfac55c
|
|
@ -0,0 +1 @@
|
|||
/MAndApps/
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.0 MiB |
|
|
@ -10,8 +10,9 @@ import java.awt.Rectangle;
|
|||
import java.awt.RenderingHints;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Random;
|
||||
import java.util.Stack;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
|
@ -27,11 +28,10 @@ public class SpaceWars implements BasicApp {
|
|||
|
||||
//
|
||||
private static boolean paused = false, debug = false;
|
||||
private static int redPoints = 0, bluePoints = 0, greenPoints = 0, time = 0;
|
||||
private static final int WIDTH = 1024, HEIGHT = 600;
|
||||
private static int time = 0;
|
||||
private static int WIDTH = 1024, HEIGHT = 600;
|
||||
private static Player player = new Player();
|
||||
private static Image background;
|
||||
private static Random r = new Random();
|
||||
private static Stack<Enemy> enemies = new Stack<Enemy>();
|
||||
private static Stack<Explosion> explosions = new Stack<Explosion>();
|
||||
private static Stack<String> logs = new Stack<String>();
|
||||
|
|
@ -47,7 +47,7 @@ public class SpaceWars implements BasicApp {
|
|||
|
||||
@Override
|
||||
public void tick() {
|
||||
addEXP(1);
|
||||
//addEXP(1);
|
||||
if (!paused && !shopping) {
|
||||
time++;
|
||||
// ticks enemy stack
|
||||
|
|
@ -66,18 +66,7 @@ public class SpaceWars implements BasicApp {
|
|||
int i = 0;
|
||||
while (i < enemies.size()) {
|
||||
if (!enemies.elementAt(i).getAlive()) {
|
||||
/*
|
||||
* BOOM( 75, 1.2,
|
||||
* enemies.elementAt(i).getColor().getRed()-50,
|
||||
* enemies.elementAt(i).getColor().getGreen()-50,
|
||||
* enemies.elementAt(i).getColor().getBlue()-50, 50,
|
||||
* (int)enemies.elementAt(i).getX(),
|
||||
* (int)enemies.elementAt(i).getY(), 550, true, true, 10 );
|
||||
*/
|
||||
|
||||
addRedPoints(enemies.elementAt(i).getColor().getRed());
|
||||
addGreenPoints(enemies.elementAt(i).getColor().getGreen());
|
||||
addBluePoints(enemies.elementAt(i).getColor().getBlue());
|
||||
|
||||
log("You gained " + enemies.elementAt(i).getWorth() + " exp.");
|
||||
addEXP(enemies.elementAt(i).getWorth());
|
||||
|
||||
|
|
@ -99,10 +88,6 @@ public class SpaceWars implements BasicApp {
|
|||
expBar += ((int) (((double) xp / (double) xpToNextLVL) * 424) - expBar) / 10;
|
||||
}
|
||||
shop.tick();
|
||||
// check if there are any new items to log
|
||||
int cap = logs.size();
|
||||
for (int i = 0; i < cap; i++)
|
||||
Engine.log(logs.pop());
|
||||
}
|
||||
|
||||
public static void log(String s) {
|
||||
|
|
@ -122,7 +107,7 @@ public class SpaceWars implements BasicApp {
|
|||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
g.setFont(defaultFont);
|
||||
g.drawImage(background, 0, 0, WIDTH, HEIGHT, null);
|
||||
g.drawImage(background, 0, 0, null);
|
||||
|
||||
for (int i = 0; i < explosions.size(); i++)
|
||||
explosions.elementAt(i).render(g, i);
|
||||
|
|
@ -131,16 +116,6 @@ public class SpaceWars implements BasicApp {
|
|||
for (int i = 0; i < enemies.size(); i++)
|
||||
enemies.elementAt(i).render(g);
|
||||
|
||||
// render points
|
||||
g.setFont(moneyFont);
|
||||
g.setColor(Color.RED);
|
||||
g.drawString(redPointsToString(), 10, HEIGHT - 10 - (20 * 3));
|
||||
g.setColor(Color.GREEN);
|
||||
g.drawString(greenPointsToString(), 10, HEIGHT - 10 - (20 * 2));
|
||||
g.setColor(Color.BLUE);
|
||||
g.drawString(bluePointsToString(), 10, HEIGHT - 10 - (20 * 1));
|
||||
g.setFont(defaultFont);
|
||||
|
||||
// render level and xp bar.
|
||||
g.setFont(levelFont);
|
||||
g.setColor(Color.WHITE);
|
||||
|
|
@ -181,18 +156,21 @@ public class SpaceWars implements BasicApp {
|
|||
|
||||
@Override
|
||||
public Dimension getResolution() {
|
||||
return new Dimension(WIDTH, HEIGHT);
|
||||
System.out.println("WIDTHasdf: " + WIDTH);
|
||||
System.out.println("HEIGHTsdf: " + HEIGHT);
|
||||
return new Dimension(WIDTH = 1024, HEIGHT = 600);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
try {
|
||||
background = ImageIO.read(new URL("http://wallpapersus.com/wallpapers/2012/10/Cool-Wave-600x1024.jpg"));
|
||||
background = ImageIO.read(new FileInputStream(new File("res/background.png")));
|
||||
|
||||
} catch (Exception e) {
|
||||
background = (Image) new BufferedImage(1024, 600, BufferedImage.TRANSLUCENT);
|
||||
Graphics g = background.getGraphics();
|
||||
g.setColor(Color.BLUE);
|
||||
g.fillRect(0, 0, 1024, 600);
|
||||
g.fillRect(0, 0, 3000, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,39 +224,6 @@ public class SpaceWars implements BasicApp {
|
|||
explosions.peek().goBoom(x, y, size, bubble, sizeOfParticles);
|
||||
}
|
||||
|
||||
public void addRedPoints(int d) {
|
||||
redPoints += d;
|
||||
}
|
||||
|
||||
public void addGreenPoints(int d) {
|
||||
greenPoints += d;
|
||||
}
|
||||
|
||||
public void addBluePoints(int d) {
|
||||
bluePoints += d;
|
||||
}
|
||||
|
||||
private String redPointsToString() {
|
||||
String _return = "$" + redPoints / 100d;
|
||||
if (_return.length() == ("" + redPoints).length() + 1 || _return.length() == ("" + redPoints).length() + 3)
|
||||
_return += "0";
|
||||
return _return;
|
||||
}
|
||||
|
||||
private String greenPointsToString() {
|
||||
String _return = "$" + greenPoints / 100d;
|
||||
if (_return.length() == ("" + greenPoints).length() + 1 || _return.length() == ("" + greenPoints).length() + 3)
|
||||
_return += "0";
|
||||
return _return;
|
||||
}
|
||||
|
||||
private String bluePointsToString() {
|
||||
String _return = "$" + bluePoints / 100d;
|
||||
if (_return.length() == ("" + bluePoints).length() + 1 || _return.length() == ("" + bluePoints).length() + 3)
|
||||
_return += "0";
|
||||
return _return;
|
||||
}
|
||||
|
||||
private static int getMaxXPForLvl(int lvl) {
|
||||
return (int) (Math.pow(lvl, 1.618));
|
||||
}
|
||||
|
|
@ -343,4 +288,12 @@ public class SpaceWars implements BasicApp {
|
|||
BOOM(75, 1.2, 100, 100, 100, 50, Engine.mouseX, Engine.mouseY, 550, true, true, 10);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDimensions(int width, int height) {
|
||||
System.out.println("" + WIDTH);
|
||||
System.out.println("" + HEIGHT);
|
||||
WIDTH = width;
|
||||
HEIGHT = height;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package MAndApps.apps.spacewars.tools;
|
||||
package MAndApps.apps.spacewars.entity;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.util.Random;
|
||||
|
||||
import MAndApps.apps.spacewars.SpaceWars;
|
||||
import MAndApps.apps.spacewars.tools.Entity;
|
||||
|
||||
|
||||
public class Particle extends Entity{
|
||||
|
|
@ -9,6 +9,7 @@ public class Shop {
|
|||
private final int ON = 17, OFF = 64, BOX_WIDTH = 500, BOX_HEIGHT = 200, BOX_Y_OFFSET = 50, BOX_Y_MULTIPLIER = 250, MAX_ANIMATION_TIME = BOX_WIDTH;
|
||||
private int state = OFF, selection = 0;
|
||||
private double animationTime = 0;
|
||||
|
||||
public void render(Graphics g, final int WIDTH){
|
||||
g.setColor(selection == 0 ? Color.CYAN : Color.BLUE);
|
||||
g.fillRect((int)animationTime-BOX_WIDTH, BOX_Y_OFFSET, BOX_WIDTH, BOX_HEIGHT);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import java.awt.Graphics;
|
|||
import java.util.Random;
|
||||
import java.util.Stack;
|
||||
|
||||
import MAndApps.apps.spacewars.entity.Particle;
|
||||
|
||||
|
||||
public class Explosion {
|
||||
private Stack<Particle> bits = new Stack<Particle>();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import MAndEngine.Engine;
|
|||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Engine engine = new Engine(new String[] {"MAndApps.apps.spacewars.SpaceWars"}, false);
|
||||
Engine engine = new Engine(new String[] {"MAndApps.apps.spacewars.SpaceWars"}, false, true);
|
||||
engine.run();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue