-
-
Save Fogest/36aba3e1a7fc30984e4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main; | |
import java.awt.geom.Point2D; | |
public class GameLogic { | |
private double time, deltaTime, endTime, x, y, speed, angle, ay, ax, vx, vy; | |
public GameLogic(double speed, double angle, double accerlationX, double startHeight) { | |
this.time = 0.0; | |
this.deltaTime = 0.0001; | |
this.endTime = 10.0; | |
this.x = 1.0; | |
this.y = startHeight; | |
this.speed = speed; | |
this.ay = -9.8; | |
this.angle = angle; | |
this.ax = accerlationX; | |
this.vx = this.speed*Math.cos(this.angle*(Math.PI/180.0)); | |
this.vy = this.speed*Math.sin(this.angle*(Math.PI/180.0)); | |
} | |
public Point2D getPoint() { | |
time += this.deltaTime; | |
this.x += this.vx*this.deltaTime; | |
this.y += this.vy*this.deltaTime; | |
this.vx += this.ax*this.deltaTime; | |
this.vy += this.ay*this.deltaTime; | |
Point2D p = new Point2D.Double(x,y); | |
return p; | |
} | |
public static void main(String[] args) { | |
GameLogic logic = new GameLogic(60.0, 45.0, 0.0, 10); | |
while(true) | |
System.out.println(logic.getPoint().getX() + " " + logic.getPoint().getY()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment