Monster and Walls are being drawn

master
GammelJAN 5 years ago
parent 41da1e8641
commit 5593c667bd

@ -10,8 +10,10 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Timer;
import com.trs.game.model.Model;
import com.trs.game.model.Wall;
import com.trs.game.view.View;
import com.trs.game.view.Button;
import com.trs.game.view.Screen;
@ -70,6 +72,16 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
screen.render(batch,renderer,font);
// MODEL DRAWING
if(screen.getId() == 1){
renderer.begin(ShapeRenderer.ShapeType.Filled);
for(Wall wall : model.getWalls()){
renderer.rect(wall.getRect().getX(), wall.getRect().getY(),0,0, wall.getRect().getWidth(), wall.getRect().getHeight(),1,1, (float)wall.getRotation());
}
renderer.end();
model.getMonster().drawMonster(renderer);
}
}
@Override

@ -1,6 +1,8 @@
package com.trs.game.model;
import com.badlogic.gdx.math.Rectangle;
import java.util.ArrayList;
public class Model {
@ -8,11 +10,20 @@ public class Model {
private ArrayList<Wall> walls;
public Model(){
monster = new Monster();
monster = new Monster(250,150);
walls = new ArrayList<>();
walls.add(new PermWall(20,new Rectangle(250,250,50,25)));
}
public void timerStep(){
}
public ArrayList<Wall> getWalls(){
return walls;
}
public Monster getMonster(){
return monster;
}
}

@ -1,5 +1,7 @@
package com.trs.game.model;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.trs.game.StaticMath;
public class Monster {
@ -16,6 +18,19 @@ public class Monster {
public Monster(int xPos, int yPos){
this.xPos = xPos;
this.yPos = yPos;
}
public void drawMonster(ShapeRenderer renderer){
if(renderer.isDrawing()) renderer.end();
renderer.begin(ShapeRenderer.ShapeType.Filled);
renderer.setColor(Color.BLACK);
renderer.rect(xPos, yPos, 50,50);
renderer.setColor(Color.RED);
renderer.rect(xPos + 10, yPos + 30, 5, 10);
renderer.rect(xPos + 35, yPos + 30, 5, 10);
renderer.setColor(Color.WHITE);
renderer.rect(xPos + 10, yPos + 10, 30, 10);
}
public void move(){

@ -32,4 +32,5 @@ public class PermWall implements Wall {
public void setRect(Rectangle rect) {
this.rect = rect;
}
}

@ -1,5 +1,9 @@
package com.trs.game.model;
import com.badlogic.gdx.math.Rectangle;
public interface Wall {
public Wall timerStep();
public Rectangle getRect();
public double getRotation();
}

Loading…
Cancel
Save