Change numeric type to float
This commit is contained in:
parent
b0083f0e58
commit
7beacc0385
@ -24,16 +24,16 @@ public class DrawUtils {
|
||||
return new Color(r, g, b, 1f);
|
||||
}
|
||||
|
||||
public static void drawPointer(ShapeRenderer renderer, int x, int y, int w, int h, int mode) {
|
||||
public static void drawPointer(ShapeRenderer renderer, float x, float y, float w, float h, int mode) {
|
||||
renderer.begin(ShapeType.Line);
|
||||
Color col1 = pointerColorByMode[mode][0];
|
||||
Color col2 = pointerColorByMode[mode][1];
|
||||
// Vertical
|
||||
final int h2 = h / 2;
|
||||
final float h2 = h / 2f;
|
||||
renderer.line(x, 0, x, h2, col1, col2);
|
||||
renderer.line(x, h2, x, h, col2, col1);
|
||||
// Horizontal
|
||||
final int w2 = w / 2;
|
||||
final float w2 = w / 2f;
|
||||
renderer.line(0, y, w2, y, col1, col2);
|
||||
renderer.line(w2, y, w, y, col2, col1);
|
||||
renderer.end();
|
||||
|
@ -9,7 +9,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
|
||||
public class EnemiesController {
|
||||
|
||||
private int screenWidth, screenHeight;
|
||||
private float screenWidth, screenHeight;
|
||||
private Array<Enemy> enemies;
|
||||
private int difficultMode;
|
||||
|
||||
@ -17,7 +17,7 @@ public class EnemiesController {
|
||||
enemies = new Array<Enemy>();
|
||||
}
|
||||
|
||||
public void setScreenParameters(int width, int height) {
|
||||
public void setScreenParameters(float width, float height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
}
|
||||
@ -35,10 +35,10 @@ public class EnemiesController {
|
||||
}
|
||||
|
||||
private Enemy generateNewEnemy() {
|
||||
int size = MathUtils.random(screenWidth / 24, screenWidth / 10);
|
||||
int x = MathUtils.random(screenWidth - size);
|
||||
int y = MathUtils.random(screenHeight - size);
|
||||
Color color = DrawUtils.random2Color(0x43, 0xff);
|
||||
float size = MathUtils.random(screenWidth / 24f, screenWidth / 10f);
|
||||
float x = MathUtils.random(screenWidth - size);
|
||||
float y = MathUtils.random(screenHeight - size);
|
||||
Color color = DrawUtils.random2Color(0x43, 0xFF);
|
||||
return new Enemy(x, y, size, new Vector2(), color);
|
||||
}
|
||||
}
|
@ -15,11 +15,11 @@ public class Enemy {
|
||||
private Vector2 dir;
|
||||
private Color color;
|
||||
|
||||
public Enemy(int x, int y, int size) {
|
||||
public Enemy(float x, float y, float size) {
|
||||
this(x, y, size, new Vector2(), Color.RED);
|
||||
}
|
||||
|
||||
public Enemy(int x, int y, int size, Vector2 dir, Color color) {
|
||||
public Enemy(float x, float y, float size, Vector2 dir, Color color) {
|
||||
rect = new Rectangle(x, y, size, size);
|
||||
this.dir = dir;
|
||||
this.color = color;
|
||||
|
@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
|
||||
public class InfluenceXXII implements ApplicationListener {
|
||||
|
||||
private Pointer pointer;
|
||||
private EnemiesController enemies;
|
||||
private ShapeRenderer renderer;
|
||||
|
||||
@ -17,12 +18,12 @@ public class InfluenceXXII implements ApplicationListener {
|
||||
|
||||
renderer = new ShapeRenderer();
|
||||
|
||||
pointer = new Pointer(width, height);
|
||||
enemies = new EnemiesController();
|
||||
enemies.setScreenParameters((int) width, (int) height);
|
||||
enemies.setScreenParameters(width, height);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
enemies.addEnemy();
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
@ -37,6 +38,10 @@ public class InfluenceXXII implements ApplicationListener {
|
||||
|
||||
// Draw enemies
|
||||
enemies.draw(renderer);
|
||||
// enemies.update(pointerX, pointerY);
|
||||
|
||||
// Draw pointer
|
||||
pointer.draw(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,16 +8,16 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
*/
|
||||
public class Pointer {
|
||||
|
||||
private int screenWidth, screenHeight;
|
||||
private int x, y;
|
||||
private float screenWidth, screenHeight;
|
||||
private float x, y;
|
||||
|
||||
public Pointer(int width, int height) {
|
||||
public Pointer(float width, float height) {
|
||||
x = width / 2;
|
||||
y = height / 2;
|
||||
setScreenParameters(width, height);
|
||||
}
|
||||
|
||||
public void setScreenParameters(int width, int height) {
|
||||
public void setScreenParameters(float width, float height) {
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user