Merge branch 'jonathan'

Projectile movement working, buttons working
master
Jonathan Hager 5 years ago
commit 1a4793d22f

@ -47,9 +47,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
wallTimer.scheduleTask(new Timer.Task() {
@Override
public void run() {
model.timerStep();
if(screen.getId() == 1) {
model.timerStep();
}
}
}, 0, 1f);
}, 0, 0.05f);
font = new BitmapFont();
// BITMAP FONT
@ -81,7 +83,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
renderer.rect(wall.getRect().getX(), wall.getRect().getY(),0,0, wall.getRect().getWidth(), wall.getRect().getHeight(),1,1, (float)wall.getRotation());
}
for(Projectile projectile : model.getProjectiles()){
renderer.circle(projectile.getxPos(),projectile.getyPos(),5);
renderer.circle(projectile.getxPos(), projectile.getyPos(), projectile.getRadius());
}
renderer.end();
model.getMonster().drawMonster(renderer);

@ -16,6 +16,7 @@ public class Model {
walls.add(new PermWall(20,new Rectangle(250,250,50,25)));
projectiles = new ArrayList<>();
projectiles.add(new Projectile(200, 200, 1000, 600));
}
public void timerStep(){

@ -1,22 +1,22 @@
package com.trs.game.model;
import com.badlogic.gdx.math.Circle;
import com.trs.game.StaticMath;
public class Projectile {
private final int SPEED = 3;
private int xPos;
private int yPos;
private double movementX;
private double movementY;
private Circle circle;
public Projectile(int xPos, int yPos, int xPosMonster, int yPosMonster){
this.xPos = xPos;
this.yPos = yPos;
this.circle = new Circle(xPos, yPos, 5);
// calculating values for movementX and movementY
double angle = StaticMath.calculateAngle(this.xPos, this.yPos, xPosMonster, yPosMonster);
double angle = StaticMath.calculateAngle((int) circle.x, (int) circle.y, xPosMonster, yPosMonster);
movementX = Math.cos(angle) * SPEED;
movementY = Math.sin(angle) * SPEED;
@ -27,15 +27,23 @@ public class Projectile {
}
public void move(){
this.xPos += this.movementX;
this.yPos += this.movementY;
circle.x += this.movementX;
circle.y += this.movementY;
}
public int getxPos() {
return xPos;
return (int) circle.x;
}
public int getyPos() {
return yPos;
return (int) circle.y;
}
public int getRadius(){
return (int) circle.radius;
}
public Circle getCircle() {
return circle;
}
}

Loading…
Cancel
Save