|
|
|
@ -1,12 +1,20 @@
|
|
|
|
package com.trs.game.model;
|
|
|
|
package com.trs.game.model;
|
|
|
|
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.Color;
|
|
|
|
import com.badlogic.gdx.graphics.Color;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.Pixmap;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.Texture;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.PolygonRegion;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.PolygonSprite;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
|
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
|
|
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.math.Intersector;
|
|
|
|
|
|
|
|
import com.badlogic.gdx.math.Polygon;
|
|
|
|
import com.trs.game.StaticMath;
|
|
|
|
import com.trs.game.StaticMath;
|
|
|
|
|
|
|
|
|
|
|
|
public class Monster {
|
|
|
|
public class Monster {
|
|
|
|
|
|
|
|
|
|
|
|
private final int SPEED = 3;
|
|
|
|
private final int SPEED = 5;
|
|
|
|
|
|
|
|
|
|
|
|
private int xPos;
|
|
|
|
private int xPos;
|
|
|
|
private int yPos;
|
|
|
|
private int yPos;
|
|
|
|
@ -18,12 +26,12 @@ public class Monster {
|
|
|
|
public Monster(int xPos, int yPos){
|
|
|
|
public Monster(int xPos, int yPos){
|
|
|
|
this.xPos = xPos;
|
|
|
|
this.xPos = xPos;
|
|
|
|
this.yPos = yPos;
|
|
|
|
this.yPos = yPos;
|
|
|
|
|
|
|
|
generateNewTarget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void drawMonster(ShapeRenderer renderer){
|
|
|
|
public void drawMonster(ShapeRenderer renderer, PolygonSpriteBatch polygonSpriteBatch){
|
|
|
|
if(renderer.isDrawing()) renderer.end();
|
|
|
|
if(renderer.isDrawing()) renderer.end();
|
|
|
|
renderer.begin(ShapeRenderer.ShapeType.Filled);
|
|
|
|
renderer.begin(ShapeRenderer.ShapeType.Line);
|
|
|
|
//BODY
|
|
|
|
//BODY
|
|
|
|
renderer.setColor(Color.BLACK);
|
|
|
|
renderer.setColor(Color.BLACK);
|
|
|
|
renderer.rect(xPos, yPos, 50,50);
|
|
|
|
renderer.rect(xPos, yPos, 50,50);
|
|
|
|
@ -36,21 +44,61 @@ public class Monster {
|
|
|
|
renderer.rect(xPos + 10, yPos + 10, 30, 10);
|
|
|
|
renderer.rect(xPos + 10, yPos + 10, 30, 10);
|
|
|
|
//TEETH
|
|
|
|
//TEETH
|
|
|
|
renderer.setColor(Color.RED);
|
|
|
|
renderer.setColor(Color.RED);
|
|
|
|
renderer.triangle(xPos+15,yPos+20,xPos+23,yPos+20,xPos+19,yPos+13);
|
|
|
|
// TOP
|
|
|
|
renderer.triangle(xPos+27,yPos+20,xPos+35,yPos+20,xPos+31,yPos+13);
|
|
|
|
renderer.triangle(xPos+10,yPos+20,xPos+10,yPos+15,xPos+13,yPos+20);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+13,yPos+20,xPos+16,yPos+15,xPos+19,yPos+20);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+19,yPos+20,xPos+22,yPos+15,xPos+25,yPos+20);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+25,yPos+20,xPos+28,yPos+15,xPos+31,yPos+20);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+31,yPos+20,xPos+34,yPos+15,xPos+37,yPos+20);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+37,yPos+20,xPos+40,yPos+15,xPos+40,yPos+20);
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|
|
|
|
renderer.triangle(xPos+10,yPos+10,xPos+13,yPos+15,xPos+16,yPos+10);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+16,yPos+10,xPos+19,yPos+15,xPos+22,yPos+10);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+22,yPos+10,xPos+25,yPos+15,xPos+28,yPos+10);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+28,yPos+10,xPos+31,yPos+15,xPos+34,yPos+10);
|
|
|
|
|
|
|
|
renderer.triangle(xPos+34,yPos+10,xPos+37,yPos+15,xPos+40,yPos+10);
|
|
|
|
|
|
|
|
|
|
|
|
renderer.end();
|
|
|
|
renderer.end();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* POLYGON LOGIC (DRAWING)
|
|
|
|
|
|
|
|
PolygonSprite poly;
|
|
|
|
|
|
|
|
Texture textureSolid;
|
|
|
|
|
|
|
|
// Creating the color filling (but textures would work the same way)
|
|
|
|
|
|
|
|
Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
|
|
|
|
|
|
|
|
pix.setColor(Color.BLACK); // DE is red, AD is green and BE is blue.
|
|
|
|
|
|
|
|
pix.fill();
|
|
|
|
|
|
|
|
textureSolid = new Texture(pix);
|
|
|
|
|
|
|
|
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
|
|
|
|
|
|
|
|
new float[] { // Four vertices
|
|
|
|
|
|
|
|
200, 200, // Vertex 0 3--2
|
|
|
|
|
|
|
|
300, 200, // Vertex 1 | /|
|
|
|
|
|
|
|
|
400, 500, // Vertex 2 |/ |
|
|
|
|
|
|
|
|
300, 500 // Vertex 3 0--1
|
|
|
|
|
|
|
|
}, new short[] {
|
|
|
|
|
|
|
|
0, 1, 2, // Two triangles using vertex indices.
|
|
|
|
|
|
|
|
0, 2, 3 // Take care of the counter-clockwise direction.
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
poly = new PolygonSprite(polyReg);
|
|
|
|
|
|
|
|
polygonSpriteBatch.begin();
|
|
|
|
|
|
|
|
poly.draw(polygonSpriteBatch);
|
|
|
|
|
|
|
|
polygonSpriteBatch.end();
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void move(){
|
|
|
|
public void move(){
|
|
|
|
checkTarget();
|
|
|
|
checkTarget();
|
|
|
|
|
|
|
|
|
|
|
|
this.xPos += this.movementX;
|
|
|
|
//this.xPos += this.movementX;
|
|
|
|
this.yPos += this.movementY;
|
|
|
|
//this.yPos += this.movementY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void checkTarget(){
|
|
|
|
private void checkTarget(){
|
|
|
|
if(this.xPos == this.xPosTarget && this.yPos == this.yPosTarget){
|
|
|
|
//if(this.xPos == this.xPosTarget && this.yPos == this.yPosTarget){
|
|
|
|
|
|
|
|
// this.generateNewTarget();
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
if(Math.random() >= 0.9){
|
|
|
|
this.generateNewTarget();
|
|
|
|
this.generateNewTarget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|