mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-06-28 04:04:42 +02:00
Sletter ubrukt kode og omstruktuerer klasser
Fjerner AppTest.java Fjerner HelloWorld.java Fjerner GameBoard.java Flytter alle filer fra inf112.skeleton.app til inf112.fiasko.roborally Flytter IDrawableGame og Game til en egen pakke Flytter IDrawableObject og DrawableObject til en egen pakke Flytter GameTexture til en egen pakke
This commit is contained in:
@ -0,0 +1,91 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.abstractions.GameTexture;
|
||||
|
||||
/**
|
||||
* This class represents an object that can be drawn using libgdx
|
||||
*/
|
||||
public class DrawableObject implements IDrawableObject {
|
||||
private int xPos;
|
||||
private int yPos;
|
||||
private int width = 64;
|
||||
private int height = 64;
|
||||
private int rotation = 0;
|
||||
private GameTexture texture;
|
||||
private boolean flipX = false;
|
||||
private boolean flipY = false;
|
||||
|
||||
/**
|
||||
* Initializes a drawable object
|
||||
* @param xPos The pixel to start drawing on for the x axis
|
||||
* @param yPos The pixel to start drawing on for the y axis
|
||||
* @param texture The texture to use for drawing the element
|
||||
* @param rotation The amount of degrees to rotate the element counterclockwise
|
||||
* @param width The width of the element
|
||||
* @param height The height of the element
|
||||
* @param flipX Whether to flip/mirror the element over the x axis
|
||||
* @param flipY Whether to flip/mirror the element over the y axis
|
||||
*/
|
||||
public DrawableObject(int xPos, int yPos, GameTexture texture, int rotation, int width, int height, boolean flipX, boolean flipY) {
|
||||
this.xPos = xPos;
|
||||
this.yPos = yPos;
|
||||
this.rotation = rotation;
|
||||
this.texture = texture;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.flipX = flipX;
|
||||
this.flipY = flipY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new drawable object
|
||||
* @param xPos The pixel to start drawing on for the x axis
|
||||
* @param yPos The pixel to start drawing on for the y axis
|
||||
* @param texture The texture to use for drawing the element
|
||||
*/
|
||||
public DrawableObject(int xPos, int yPos, GameTexture texture) {
|
||||
this.xPos = xPos;
|
||||
this.yPos = yPos;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameTexture getTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getXPosition() {
|
||||
return xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYPosition() {
|
||||
return yPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flipX() {
|
||||
return flipX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flipY() {
|
||||
return flipY;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package inf112.fiasko.roborally.objects;
|
||||
|
||||
import inf112.fiasko.roborally.abstractions.GameTexture;
|
||||
|
||||
/**
|
||||
* This interface describes an object drawable using libgdx
|
||||
*/
|
||||
public interface IDrawableObject {
|
||||
|
||||
/**
|
||||
* Gets the texture to use for drawing the object
|
||||
* @return The texture of the object
|
||||
*/
|
||||
GameTexture getTexture();
|
||||
|
||||
/**
|
||||
* Gets the x position the object should be drawn on
|
||||
*
|
||||
* The x position should be in terms of the actual pixel position on the rendered game, not the position according
|
||||
* to the game tile. E.g. (128,64) not (2,1).
|
||||
*
|
||||
* @return An x position libgdx
|
||||
*/
|
||||
int getXPosition();
|
||||
|
||||
/**
|
||||
* Gets the y position the object should be drawn on
|
||||
*
|
||||
* The y position should be in terms of the actual pixel position on the rendered game, not the position according
|
||||
* to the game tile. E.g. (128,64) not (2,1).
|
||||
*
|
||||
* @return An x position libgdx
|
||||
*/
|
||||
int getYPosition();
|
||||
|
||||
/**
|
||||
* Gets the width of the object
|
||||
* @return A positive integer
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Gets the height of the object
|
||||
* @return A positive integer
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* Gets the number of degrees to rotate the texture counterclockwise when rendering
|
||||
* @return An integer
|
||||
*/
|
||||
int getRotation();
|
||||
|
||||
/**
|
||||
* Whether to flip the texture on the x-axis when rendering
|
||||
* @return True if the texture is to be flipped. False otherwise
|
||||
*/
|
||||
boolean flipX();
|
||||
|
||||
/**
|
||||
* Whether to flip the texture on the y-axis when rendering
|
||||
* @return True if the texture is to be flipped. False otherwise
|
||||
*/
|
||||
boolean flipY();
|
||||
|
||||
}
|
Reference in New Issue
Block a user