Commit b06fa6eb authored by Melissa Tjong's avatar Melissa Tjong
Browse files

Main Menu

parent 1e383f32
......@@ -554,3 +554,70 @@
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
</log>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
</log>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2019-04-19T13:17:42</date>
<millis>1555694262538</millis>
<sequence>0</sequence>
<logger>project.Main</logger>
<level>SEVERE</level>
<class>project.Main</class>
<method>main</method>
<thread>1</thread>
<message>java.lang.RuntimeException: Resource not found: /home/accounts/student/n/njb013/csci205_FinalProject/Images/Link.png</message>
<exception>
<message>java.lang.RuntimeException: Resource not found: /home/accounts/student/n/njb013/csci205_FinalProject/Images/Link.png</message>
<frame>
<class>org.newdawn.slick.util.ResourceLoader</class>
<method>getResourceAsStream</method>
<line>69</line>
</frame>
<frame>
<class>org.newdawn.slick.opengl.InternalTextureLoader</class>
<method>getTexture</method>
<line>185</line>
</frame>
<frame>
<class>org.newdawn.slick.Image</class>
<method>&lt;init&gt;</method>
<line>192</line>
</frame>
<frame>
<class>org.newdawn.slick.Image</class>
<method>&lt;init&gt;</method>
<line>166</line>
</frame>
<frame>
<class>org.newdawn.slick.Image</class>
<method>&lt;init&gt;</method>
<line>154</line>
</frame>
<frame>
<class>org.newdawn.slick.Image</class>
<method>&lt;init&gt;</method>
<line>132</line>
</frame>
<frame>
<class>project.Main</class>
<method>initGL</method>
<line>104</line>
</frame>
<frame>
<class>project.Main</class>
<method>create</method>
<line>87</line>
</frame>
<frame>
<class>project.Main</class>
<method>main</method>
<line>54</line>
</frame>
</exception>
</record>
</log>
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=csci205FinalProject_SP19
application.vendor=av015
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/csci205FinalProject_SP19.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
includes=**
jar.compress=false
javac.classpath=\
${libs.LWJGL_-2.9.classpath}:\
${libs.Slick2D.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
project.licensePath=./nbproject/licenseheader.txt
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=-Djava.library.path="/home/accounts/student/n/njb013/csci205_FinalProject/LWJGL/native/linux"
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 16, 2019
* Time: 8:35:57 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: Main
* Description:
*
* ****************************************
*/
package project;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;
import org.newdawn.slick.Image;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class Main {
public class Main extends StateBasedGame {
public static final int DISPLAY_HEIGHT = 480;
public static final int DISPLAY_WIDTH = 640;
public static final Logger LOGGER = Logger.getLogger(Main.class.getName());
private static final int HEIGHT = 600;
private static final int WIDTH = 800;
private static final int MAINMENU = 0;
private static final int GAME = 1;
private int squareSize;
private int squareX;
private int squareY;
private int squareZ;
private Obstacle o;
private double spawnRate = 0.5;
private Image character = null;
static {
try {
LOGGER.addHandler(new FileHandler("errors.log", true));
} catch (IOException ex) {
LOGGER.log(Level.WARNING, ex.toString(), ex);
}
}
public static void main(String[] args) {
Main main = null;
try {
main = new Main();
main.create();
main.run();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, ex.toString(), ex);
} finally {
if (main != null) {
main.destroy();
}
}
}
public Main() {
squareSize = 50;
squareX = 26;
squareY = 26;
squareZ = 0;
}
public void create() throws LWJGLException, SlickException {
//Display
Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT));
Display.setFullscreen(false);
Display.setTitle("Hello LWJGL World!");
Display.create();
//Keyboard
Keyboard.create();
//Mouse
Mouse.setGrabbed(false);
Mouse.create();
//OpenGL
initGL();
resizeGL();
}
public void destroy() {
//Methods already check if created before destroying.
Mouse.destroy();
Keyboard.destroy();
Display.destroy();
}
public void initGL() throws SlickException {
//2D Initialization
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
character = new Image(
"/home/accounts/student/n/njb013/csci205_FinalProject/Images/Link.png");
}
public void processKeyboard() {
//Square's Size
if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
}
if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
squareY = (int) (squareY * Math.pow(Math.E, 0.05));
squareX += 1;
}
//Square's Z
if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
squareX += -3;
}
if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
squareX += 3;
}
}
public void processMouse() {
if (Mouse.isButtonDown(0)) {
squareY = (int) (squareY * Math.pow(Math.E, 0.05));
squareX += 1;
}
else if (squareY > (squareSize / 2)) {
squareY = (int) (squareY / Math.pow(Math.E, 0.03));
squareX += 1;
}
}
public void render() {
glClear(GL_COLOR_BUFFER_BIT);
/*glLoadIdentity();
//Draw a basic square
glTranslatef(squareX, squareY, 0.0f);
glTranslatef(-(squareSize >> 1), -(squareSize >> 1), 0.0f);
//glColor3f(1.0f, 1.0f, 0.5f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(squareSize, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(squareSize, squareSize);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(0.0f, squareSize);
glEnd();*/
character.draw((float) squareX, (float) squareY, 0.1f);
public Main(String name) {
super(name);
this.addState(new MainMenu(MAINMENU));
this.addState(new MainGame(GAME));
}
public void createObstacle(Obstacle o) {
//glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
double x1 = o.getObsX();
double x2 = o.getObsX() + o.getObsWidth() / 2;
double y1 = o.getObsY();
double y2 = o.getObsY() - o.getObsHeight() / 2;
//Draw a basic square
glColor3f(0.0f, 0.5f, 0.3f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2d(x1, y1);
glTexCoord2f(1.0f, 0.0f);
glVertex2d(x1, y2);
glTexCoord2f(1.0f, 1.0f);
glVertex2d(x2, y1);
glTexCoord2f(0.0f, 1.0f);
glVertex2d(x2, y2);
glEnd();
}
public void resizeGL() {
//2D Scene
glViewport(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, DISPLAY_WIDTH, 0.0f, DISPLAY_HEIGHT);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
@Override
public void initStatesList(GameContainer container) throws SlickException {
this.getState(MAINMENU).init(container, this);
this.getState(GAME).init(container, this);
this.enterState(MAINMENU);
}
public void run() throws InterruptedException {
while (!Display.isCloseRequested() && !Keyboard.isKeyDown(
Keyboard.KEY_ESCAPE)) {
if (Display.isVisible()) {
processKeyboard();
processMouse();
update();
render();
if (o == null) {
o = new Obstacle();
}
createObstacle(o);
}
else {
if (Display.isDirty()) {
render();
}
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
Display.update();
Display.sync(60);
}
}
public void update() {
if (squareY >= DISPLAY_HEIGHT - (squareSize / 2)) {
squareY = DISPLAY_HEIGHT - (squareSize / 2);
}
if (squareY <= (squareSize / 2)) {
squareY = squareSize / 2;
}
if (squareX >= DISPLAY_WIDTH - (squareSize / 2)) {
squareX = DISPLAY_WIDTH - (squareSize / 2);
}
if (squareX <= squareSize / 2) {
squareX = squareSize / 2;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws SlickException {
try {
o.setObsX(o.getObsX() - 1);
if (o.getObsX() + o.getObsWidth() < 0) {
o = null;
}
double squareRight = squareX;
double squareBottom = squareY - squareSize;
double oLeft = o.getObsX();
if ((squareRight == oLeft) && (squareY == o.getObsY())) {
squareX = 0;
squareY = 0;
}
} catch (NullPointerException e) {
AppGameContainer app = new AppGameContainer(new Main(
"Jetpack Joyride"));
app.setDisplayMode(WIDTH, HEIGHT, false);
app.setShowFPS(false);
app.start();
} catch (SlickException e) {
e.printStackTrace();
}
}
}
......@@ -46,17 +46,16 @@ public class MainGame extends BasicGameState {
private static int char_Width = 100;
private static int char_Height = 100;
public MainGame() {
public MainGame(int state) {
super();
}
public int getID() {
return 0;
return 1;
}
public void init(GameContainer container, StateBasedGame sbg) throws SlickException {
container.setShowFPS(true);
container.setSmoothDeltas(true);
character = new Image(
"Images/Link.png");
......
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 17, 2019
* Time: 7:20:05 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: MainMenu
* Description:
*
* ****************************************
*/
package project;
import org.lwjgl.input.Mouse;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
/**
*
* @author mt034
*/
public class MainMenu extends BasicGameState {
Image play;
Image exit;
Image background;
Image logo;
private static final int HEIGHT = 600;
private static final int WIDTH = 800;
MainMenu(int state) {
}
@Override
public int getID() {
return 0;
}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
play = new Image("Images/Play.png");
exit = new Image("Images/Exit.png");
logo = new Image("Images/logo.png");
background = new Image("Images/city.png");
background = background.getScaledCopy(WIDTH, HEIGHT);
logo = logo.getScaledCopy(300, 200);
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
background.draw();
logo.draw(250, 75);
play.draw(300, 300);
exit.draw(300, 415);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
int posX = Mouse.getX();
int posY = Mouse.getY();
Input input = container.getInput();
//Play button
if ((posX > 300 && posX < 500) && (posY > 300 && posY < 400)) {
if (input.isKeyDown(Input.MOUSE_LEFT_BUTTON)) {
game.enterState(1);
}
}
//Exit button
if ((posX > 300 && posX < 500) && (posY > 415 && posY < 515)) {
if (input.isKeyDown(Input.MOUSE_LEFT_BUTTON)) {
System.exit(0);
}
}
}
}
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