Skip to content
Snippets Groups Projects
Commit 4a650f2c authored by Eli Fjellbirkeland Johannesen's avatar Eli Fjellbirkeland Johannesen
Browse files

#10 fix projectile logic

parent 84a52496
No related branches found
No related tags found
1 merge request!20Resolve "Implement projectile logic"
Pipeline #206094 passed
......@@ -85,4 +85,5 @@ task run(type: Exec) {
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.game.tankwars/com.game.tankwars.AndroidLauncher'
}
eclipse.project.name = appName + "-android"
......@@ -50,7 +50,11 @@ project(":desktop") {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}
}
......@@ -66,7 +70,13 @@ project(":android") {
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}
......@@ -92,6 +102,8 @@ project(":core") {
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
......@@ -4,3 +4,5 @@ sourceCompatibility = 1.7
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project.name = appName + "-core"
......@@ -22,7 +22,7 @@ import com.game.tankwars.model.Tank;
public class TankWarsGame extends ApplicationAdapter {
public static int VIEWPORT_WIDTH = 100;
public static int VIEWPORT_WIDTH = 80;
public static int VIEWPORT_HEIGHT = 50;
int horizontalScaling;
......
......@@ -20,6 +20,7 @@ public class Bullet {
public Bullet(Tank tank) {
this.position = tank.getPosition();
position.y += 0.5;
this.tank = tank;
world = Box2dWorld.getWorld();
bodyDef.type = BodyDef.BodyType.DynamicBody;
......@@ -39,7 +40,7 @@ public class Bullet {
}
public void shoot() {
body.applyLinearImpulse(0.2f, 0.1f, position.x, position.y, true);
body.applyLinearImpulse(0.4f, 0.3f, position.x-1, position.y-2, true);
System.out.println(this.position);
}
......
......@@ -79,10 +79,12 @@ public class Tank {
public void moveRight() {
body.setLinearVelocity(TANK_MOVESPEED, 0);
position = body.getPosition();
}
public void moveLeft() {
body.setLinearVelocity(- TANK_MOVESPEED, 0);
position = body.getPosition();
}
public void stop() {body.setLinearVelocity(0, 0);}
......@@ -92,7 +94,7 @@ public class Tank {
}
public boolean detectCollisionRight() {
return Gdx.graphics.getWidth() / 2.0f - bounds.getWidth() / 2.0f - 50 < position.x;
return TankWarsGame.VIEWPORT_WIDTH - TANK_WIDTH < position.x;
}
......
package com.game.tankwars.view;
public class GameView {
}
......@@ -7,6 +7,8 @@ project.ext.assetsDir = new File("../assets")
import org.gradle.internal.os.OperatingSystem
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment