parent
61a495e1d1
commit
428fbc7065
@ -0,0 +1,33 @@
|
|||||||
|
package com.throwgame.main;
|
||||||
|
|
||||||
|
public class ThrowMath {
|
||||||
|
private double tanA;
|
||||||
|
private double coefficient;
|
||||||
|
private double y0;
|
||||||
|
private boolean initialised;
|
||||||
|
|
||||||
|
public ThrowMath(){
|
||||||
|
this.tanA = 0;
|
||||||
|
this.coefficient = 0;
|
||||||
|
this.y0 = 0;
|
||||||
|
this.initialised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initThrow(double alpha, double g, double v0, double y0){
|
||||||
|
this.tanA = Math.tan(alpha);
|
||||||
|
this.coefficient = g / (2 * Math.pow(v0, 2) * Math.pow(Math.cos(alpha), 2));
|
||||||
|
this.y0 = y0;
|
||||||
|
this.initialised = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int calculateY(int xPos){
|
||||||
|
if(this.initialised){
|
||||||
|
double res = this.y0 + this.tanA * xPos - this.coefficient * Math.pow(xPos, 2);
|
||||||
|
return (int) res;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Der Wurf wurde nicht initialisiert!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public class Goal {
|
||||||
|
|
||||||
|
private int xPos;
|
||||||
|
private int yPos;
|
||||||
|
private int sizeX;
|
||||||
|
private int sizeY;
|
||||||
|
|
||||||
|
public Goal(int xPos, int yPos, int sizeX, int sizeY){
|
||||||
|
this.xPos = xPos;
|
||||||
|
this.yPos = yPos;
|
||||||
|
this.sizeX = sizeX;
|
||||||
|
this.sizeY = sizeY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getxPos() {
|
||||||
|
return xPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setxPos(int xPos) {
|
||||||
|
this.xPos = xPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getyPos() {
|
||||||
|
return yPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setyPos(int yPos) {
|
||||||
|
this.yPos = yPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSizeX() {
|
||||||
|
return sizeX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSizeX(int sizeX) {
|
||||||
|
this.sizeX = sizeX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSizeY() {
|
||||||
|
return sizeY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSizeY(int sizeY) {
|
||||||
|
this.sizeY = sizeY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
package model;
|
||||||
|
|
||||||
|
import com.throwgame.main.ThrowMath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jan
|
||||||
|
*/
|
||||||
|
public class Level {
|
||||||
|
|
||||||
|
private Goal goal;
|
||||||
|
private Projectile projectile;
|
||||||
|
private ThrowMath math;
|
||||||
|
|
||||||
|
public Level(Goal goal, Projectile projectile){
|
||||||
|
this.goal = goal;
|
||||||
|
this.projectile = projectile;
|
||||||
|
this.math = new ThrowMath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void projectileReleased(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void step(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Goal getGoal() {
|
||||||
|
return goal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Projectile getProjectile() {
|
||||||
|
return projectile;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Jan
|
|
||||||
*/
|
|
||||||
public class Model {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public class Projectile {
|
||||||
|
|
||||||
|
private int xPos;
|
||||||
|
private int yPos;
|
||||||
|
private int mass;
|
||||||
|
private int radius;
|
||||||
|
private double vX;
|
||||||
|
private double vY;
|
||||||
|
private final int type;
|
||||||
|
|
||||||
|
Projectile(int xPos, int yPos, int type){
|
||||||
|
this.xPos = xPos;
|
||||||
|
this.yPos = yPos;
|
||||||
|
this.type = type;
|
||||||
|
this.vX = 0;
|
||||||
|
this.vY = 0;
|
||||||
|
|
||||||
|
switch(type){
|
||||||
|
case 0:
|
||||||
|
mass = 5;
|
||||||
|
radius = 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getxPos() {
|
||||||
|
return xPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setxPos(int xPos) {
|
||||||
|
this.xPos = xPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getyPos() {
|
||||||
|
return yPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setyPos(int yPos) {
|
||||||
|
this.yPos = yPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMass() {
|
||||||
|
return mass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMass(int mass) {
|
||||||
|
this.mass = mass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRadius() {
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRadius(int radius) {
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getvX() {
|
||||||
|
return vX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setvX(double vX) {
|
||||||
|
this.vX = vX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getvY() {
|
||||||
|
return vY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setvY(double vY) {
|
||||||
|
this.vY = vY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue