Commit 9e38a113 authored by Melissa Tjong's avatar Melissa Tjong
Browse files

Main Menu

parent 434941b7
......@@ -53,6 +53,4 @@ public abstract class Entity extends Box {
}*/
}
public abstract void update(GameContainer gc, int delta);
}
......@@ -36,20 +36,20 @@ public class Laser extends Entity {
}
@Override
public void update(GameContainer gc, int delta) {
}
@Override
public void init() {
width = Level1.WIDTH;
height = 50;
x = 0;
y = (float) (Math.random() * (Level1.HEIGHT - height));
width = 370;
height = 39;
x = Level1.WIDTH;
//y = (float) (Math.random() * (Level1.HEIGHT - height));
y = 650;
try {
image = new Image("Images/laser_on.png");
image = image.getScaledCopy(Level1.WIDTH, image.getHeight());
//image = image.getScaledCopy(100, 50);
} catch (SlickException ex) {
Logger.getLogger(Laser.class.getName()).log(Level.SEVERE, null, ex);
}
......
......@@ -21,6 +21,7 @@ import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import project.Level1;
......@@ -58,9 +59,11 @@ public class Player extends Entity {
}
@Override
public void update(GameContainer gc, int delta) {
Input input = gc.getInput();
if (Input.isKeyDown(Input.KEY_SPACE)) {
y -= 0.75;
}
}
@Override
......
......@@ -102,7 +102,9 @@ public class Box {
boolean rightX = this.getEndX() >= b.x;
boolean bottomX = this.getEndY() >= b.y;
return (rightB && bottomB && rightX && bottomX);
// boolean hitsX = this.x >= b.x;
// boolean hitsY = this.y == b.y;
// return (hitsX && hitsY);
}
}
......@@ -65,7 +65,7 @@ public abstract class Level extends BasicGameState {
Laser laser;
public static final int levelLength = 5000;
public static final int levelLength = 50000;
public int getTopScore() {
return topScore;
......
......@@ -17,6 +17,7 @@ package project;
import entities.Laser;
import entities.Player;
import java.util.ArrayList;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
......@@ -62,6 +63,7 @@ public class Level1 extends Level {
private boolean isRising = false;
private boolean isFalling = false;
ArrayList<Laser> lasers;
Laser laser;
public int getTopScore() {
......@@ -118,9 +120,19 @@ public class Level1 extends Level {
backgroundX2 += dX;
backgroundX += dX;
// for (Laser l : lasers) {
// l.x -= dX;
// l.image.draw(laser.x, laser.y);
// }
laser.x -= dX;
laser.image.draw(laser.x, laser.y);
if (character.hasSprite()) {
character.getAnimation().update(delta);
}
// if (character.hitTest(laser) == true) {
// sbg.enterState(Main.LOSE);
// }
if (input.isKeyDown(Input.KEY_SPACE)) {
startY -= 0.75;
......@@ -168,6 +180,11 @@ public class Level1 extends Level {
g.drawString(Integer.toString(getTopScore()) + meters, 0, 20);
g.drawString("Level " + Integer.toString(this.getID()), WIDTH - 70, 0);
g.drawString("Char x: " + character.x, WIDTH - 100, 20);
g.drawString("Char y: " + character.y, WIDTH - 100, 40);
g.drawString("laser x:" + laser.x, WIDTH - 100, 60);
g.drawString("laser y:" + laser.y, WIDTH - 100, 80);
Input input = container.getInput();
if (character.hasSprite()) {
......@@ -188,7 +205,22 @@ public class Level1 extends Level {
fireImage.draw(startX + 10, startY + 80);
}
}
//laser.image.draw(100, 100);
laser.image.draw(laser.x, laser.y);
// if (pointCounter % 100 == 0) {
// lasers.add(new Laser());
// for (Laser l : lasers) {
// l.image.draw(l.x, l.y);
// }
// }
//xeonSheet.draw();
}
public float getStartY() {
return startY;
}
public float getStartX() {
return startX;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment