Skip to content
Snippets Groups Projects
Commit bc75588f authored by Oscar Wiberg's avatar Oscar Wiberg
Browse files

Ändring av meny, cleanup i filer, tillagda kommentarer för javadoc

parent a7983ea5
No related branches found
No related tags found
1 merge request!2Newmode
Showing
with 17 additions and 155 deletions
src/Images1/car.png

55.2 KiB

src/Images1/cloud.png

3.03 KiB

src/Images1/dinosaur.png

115 KiB

src/Images1/fly.png

72.2 KiB

src/Images1/h-banana.png

33.2 KiB

src/Images1/heart.png

886 B

src/Images1/player2_sliding.png

99 KiB

src/Images1/player_sliding.png

124 KiB

src/Images1/runner.png

18.5 KiB

src/Images1/smiley.png

37.5 KiB

src/Images1/tree.png

5.11 KiB

src/Images1/woman-running.png

19.4 KiB

package constants;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.scene.image.Image;
/**
* @author oscarwiberg, filipyhde
* Definerar globala konstanter som vi använder återkommande i andra klasser.
*/
public interface Constants {
/**
* In this file we define some global constants.
*
* An interface is one way to store variables that are truly constants and not
* subject to change during run time.
*
* Please note that the problem with global variables is that anyone can change
* them whenever. This makes it extremely hard to reason about your code. But
* for constants, this is not a problem since we cannot change them, and
* therefore they stay the same during the entire execution of the program.
*/
/*
* Define the size of the window
*/
final int screenWidth = 1000;
final int screenHeight = 500;
......
package main;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import states.GameModel;
/**
* @author oscarwiberg, filipyhde
* This class Wraps a HBox: A HBox is a second level JavaFX container used
* organize contents in the window (Stage/Scene).
*
* The GameFrame, in this case, has the job of creating the game panel, and
* adding it to itself in order for it to show.
*
*/
public class GameFrame extends HBox {
private GamePanel g;
......
package main;
import states.GameModel;
import javafx.scene.canvas.Canvas;
/**
* @author oscarwiberg, filipyhde
* The GamePanel wraps a Canvas
*
* The main responsibilities of the GamePanel are:
......
package main;
import states.GameModel;
import constants.Constants;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.input.KeyEvent;
import javafx.stage.Stage;
//FFfffffffff
/**
* This Class is the entry point of the application.
* <p>
......@@ -33,11 +30,6 @@ import javafx.stage.Stage;
* @author magni54, alomi60
*/
public class Main extends Application {
private GameModel model;
private Scene gameScene;
private GameFrame frame;
public static void main(String[] args) {
launch(args);
......
package states;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.scene.image.Image;
public abstract class Antagonist {
protected double x;
protected double y;
protected Image img;
protected boolean collisionDetected;
public Antagonist(String image, double x, double y) {
this.x = x;
this.y = y;
this.collisionDetected = false;
try {
this.img = new Image(new FileInputStream(image));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Antagonist(String image) {
this.collisionDetected = false;
try {
this.img = new Image(new FileInputStream(image));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public abstract boolean playerAntagonistCollision(Player player);
public void setAntagonistX(double pos) {
this.x = pos;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public Image getImage() {
return img;
}
}
package states;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import constants.Constants;
import javafx.geometry.Bounds;
import javafx.scene.image.Image;
import javafx.scene.shape.Rectangle;
public class Bomb extends Object{
public Bomb(String bombImg, double x, double y, double h, double w) {
super(bombImg, x, y, h, w);
}
// public Bounds getBoundingBox() {
// return new Rectangle(startX, posY, Constants.bombWidth, Constants.bombHeight).getBoundsInParent();
// }
//
//
//
// public double getX() {
// return startX;
// }
//
//
//
//
// public double getY() {
// return posY;
// }
//
//
//
//
// public Image getImage() {
// return image;
// }
//
public void render(int speed) {
this.posY += speed;
}
}
package states;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import constants.Constants;
import javafx.geometry.Bounds;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.Rectangle;
/**
* @author oscarwiberg, filipyhde
* Enemy(groundenemy), gör inte så mycket unikt och använder mest den fördefinierade funktionaliteten som finns objekt classen
* Bomben som flyingenemy är en instan av enemy.
*/
public class Enemy extends Object{
......
package states;
/**
* @author oscarwiberg, filipyhde
* Usefunktionen är abstract eftersom powerupsen ger olika fördelar, denna återställer spelarens liv, oberoende hur många den har sen innan.
* Du kan därmed aldrig få mer liv än 3 som du startar med.
*/
public class ExtraLifePowerUp extends PowerUp {
public ExtraLifePowerUp(String image, double x, double y, double h, double w) {
super(image, x, y, h, w);
// TODO Auto-generated constructor stub
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment