Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.imackshun.games.pokemonfg.objects;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.TextureRegion;
- import com.badlogic.gdx.graphics.g3d.decals.Decal;
- import com.badlogic.gdx.graphics.g3d.decals.DecalBatch;
- import com.badlogic.gdx.math.Vector3;
- public class DecalObject {
- //Object Properties
- private String WhichObject;
- // Object Location
- public Vector3 Position;
- public Decal ObjectDecal;
- private Texture WhichTexture;
- public double DistanceFromPlayer;
- private double DistanceX;
- private double DistanceZ;
- //Constructor
- public DecalObject(float X, float Y, float Z, float Width, float Height, String WhichObject){
- this.Position = new Vector3(X, Y, Z);
- if(WhichObject.equals("Tree")){
- WhichTexture = new Texture("Textures/TreeTexture.png");
- ObjectDecal = Decal.newDecal(Width, Height, new TextureRegion(WhichTexture));
- ObjectDecal.setBlending(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
- }
- if(WhichObject.equals("Flower")){
- WhichTexture = new Texture("Textures/FlowerTexture.png");
- ObjectDecal = Decal.newDecal(Width, Height, new TextureRegion(WhichTexture));
- ObjectDecal.setBlending(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
- }
- if(WhichObject.equals("Grass")){
- WhichTexture = new Texture("Textures/GrassTexture.png");
- ObjectDecal = Decal.newDecal(Width, Height, new TextureRegion(WhichTexture));
- ObjectDecal.setBlending(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
- }
- ObjectDecal.translateX(X);
- ObjectDecal.translateY(Y);
- ObjectDecal.translateZ(Z);
- }
- public void Draw(DecalBatch batch, CustomCamera Camera3D){
- ObjectDecal.lookAt(Camera3D.Camera.position, Camera3D.Camera.up);
- batch.add(ObjectDecal);
- }
- public void CalculateDistance(Player player){
- DistanceX = Math.pow(Position.x - player.Position.x, 2);
- DistanceZ = Math.pow(-Position.z - player.Position.z, 2);
- DistanceFromPlayer = Math.sqrt(DistanceX + DistanceZ);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement