HORSE GAME

pull/1/head
hYdos 2020-02-23 19:43:10 +10:00
parent 4026e407c6
commit 2803856e95
6 changed files with 47 additions and 60 deletions

View File

@ -29,79 +29,43 @@ public class Example extends Game{
Constants.gravity = -0.000000000005f;
Constants.jumpPower = 0.000005f;
Window.create(1200, 800, "Simple Ginger Example", 60);
Window.create(1200, 800, "Horse Game 1.0.0", 60);
GingerMain.init();
Window.setBackgroundColour(0.2f, 0.2f, 0.8f);
TexturedModel tModel = ModelLoader.loadModel("stall.obj", "stallTexture.png");
TexturedModel tModel = ModelLoader.loadModel("Zebra.obj", "stallTexture.png");
tModel.getTexture().setReflectivity(1f);
tModel.getTexture().setShineDamper(7f);
Player player = new Player(tModel, new Vector3f(0,0,-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
Camera camera = new Camera(new Vector3f(0,0.1f,0), player);
ginger3D = new Ginger();
data = new GameData(player, camera);
data.handleGuis = false;
ginger3D.setup(new MasterRenderer(data.camera), data);
FontType font = new FontType(Loader.loadFontAtlas("candara.png"), "candara.fnt");
GUIText text = new GUIText("german", 3, font, new Vector2f(0,0), 1f, true);
text.setColour(0, 1, 0);
ParticleMaster.init(ginger3D.masterRenderer.getProjectionMatrix());
GUIText text = new GUIText("Horse Game", 3, font, new Vector2f(0,0), 1f, true);
text.setColour(0, 1, 0);
TexturedModel dragonMdl = ModelLoader.loadModel("Zebra.obj", "stallTexture.png");
dragonMdl.getTexture().setReflectivity(4f);
dragonMdl.getTexture().setShineDamper(2f);
Terrain terrain = handleFlatTerrain();
Light sun = new Light(new Vector3f(100,105,-100), new Vector3f(1.3f, 1.3f, 1.3f), new Vector3f(0.0001f, 0.0001f, 0.0001f));
data.lights.add(sun);
TexturedModel tgrass = ModelLoader.loadModel("grass.obj", "grass.png");
tgrass.getTexture().setTransparency(true);
tgrass.getTexture().useFakeLighting(true);
TerrainTexture backgroundTexture = Loader.loadTerrainTexture("grass.png");
TerrainTexture rTexture = Loader.loadTerrainTexture("mud.png");
TerrainTexture gTexture = Loader.loadTerrainTexture("grassFlowers.png");
TerrainTexture bTexture = Loader.loadTerrainTexture("path.png");
TerrainTexturePack texturePack = new TerrainTexturePack(backgroundTexture, rTexture, gTexture, bTexture);
TerrainTexture blendMap = Loader.loadTerrainTexture("blendMap.png");
Terrain terrain = new Terrain(-0.5f, -0.5f, texturePack, blendMap, "heightmap.png");
Entity dragon = new Entity(dragonMdl, new Vector3f(3,terrain.getHeightOfTerrain(3, -3),-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
Entity grassEntity = new Entity(tgrass, new Vector3f(-3,terrain.getHeightOfTerrain(-3, -3),-3),0,180f,0, new Vector3f(0.2f, 0.2f, 0.2f));
data.entities.add(grassEntity);
TexturedModel barrelModel = new TexturedModel(NormalMappedObjLoader.loadOBJ("barrel.obj"), new ModelTexture("barrel.png"));
barrelModel.getTexture().setNormalMap(new ModelTexture("modelNormals/barrelNormal.png").getTextureID());
barrelModel.getTexture().setShineDamper(10f);
barrelModel.getTexture().setReflectivity(0.5f);
Entity barrel = new Entity(barrelModel, new Vector3f(1,terrain.getHeightOfTerrain(1, 1),1), 0, 0, 0, new Vector3f(0.25f,0.25f,0.25f));
data.normalMapEntities.add(barrel);
data.entities.add(player);
data.entities.add(dragon);
data.flatTerrains.add(terrain);
data.entities.add(player);
ParticleSystem system = setupParticles();
TextureButton button = new TextureButton("/textures/guis/ginger.png", new Vector2f(0.8f, 0), new Vector2f(0.1f, 0.1f));
button.show(data.guis);
boolean isInWorld = false;
TextureButton playButton = new TextureButton("/textures/guis/purpur.png", new Vector2f(0, 0), new Vector2f(0.25f, 0.1f));
playButton.show(data.guis);
Window.lockMouse();
while(!Window.closed()) {
@ -115,15 +79,16 @@ public class Example extends Game{
system.generateParticles(new Vector3f(0,-2,0));
ginger3D.render(data, this);
if(isInWorld) {
ginger3D.render(this);
}
ginger3D.renderOverlays(this);
dragon.increaseRotation(0,1,0);
barrel.increaseRotation(0, 1, 0);
button.update();
if(button.isClicked()) {
System.out.println("click");
button.hide(data.guis);
playButton.update();
if(playButton.isClicked()) {
Window.lockMouse();
playButton.hide(data.guis);
isInWorld = true;
}
ginger3D.postRender();
@ -148,4 +113,18 @@ public class Example extends Game{
}
private Terrain handleFlatTerrain() {
TerrainTexture backgroundTexture = Loader.loadTerrainTexture("grass.png");
TerrainTexture rTexture = Loader.loadTerrainTexture("mud.png");
TerrainTexture gTexture = Loader.loadTerrainTexture("grassFlowers.png");
TerrainTexture bTexture = Loader.loadTerrainTexture("path.png");
TerrainTexturePack texturePack = new TerrainTexturePack(backgroundTexture, rTexture, gTexture, bTexture);
TerrainTexture blendMap = Loader.loadTerrainTexture("blendMap.png");
Terrain terrain = new Terrain(-0.5f, -0.5f, texturePack, blendMap, "heightmap.png");
data.flatTerrains.add(terrain);
return terrain;
}
}

View File

@ -23,6 +23,7 @@ public class GameData {
public Player player;
public Camera camera;
public Vector4f clippingPlane;
public boolean handleGuis = true;
public GameData(Player player, Camera camera) {
clippingPlane = new Vector4f(0, -1, 0, 100000);

View File

@ -22,6 +22,7 @@ public class Ginger {
this.masterRenderer = masterRenderer;
picker = new MousePicker(data.camera, masterRenderer.getProjectionMatrix(), null);
PostProcessing.init();
ParticleMaster.init(masterRenderer.getProjectionMatrix());
}
public void update(GameData data) {
@ -33,14 +34,20 @@ public class Ginger {
ParticleMaster.update(data.camera);
}
public void render(GameData data, Game game) {
public void render(Game game) {
GingerMain.preRenderScene(masterRenderer);
ParticleMaster.renderParticles(data.camera);
ParticleMaster.renderParticles(game.data.camera);
contrastFbo.bindFBO();
masterRenderer.renderScene(data.entities, data.normalMapEntities, data.flatTerrains, data.lights, data.camera, data.clippingPlane);
masterRenderer.renderScene(game.data.entities, game.data.normalMapEntities, game.data.flatTerrains, game.data.lights, game.data.camera, game.data.clippingPlane);
contrastFbo.unbindFBO();
PostProcessing.doPostProcessing(contrastFbo.colorTexture);
masterRenderer.renderGuis(data.guis);
if(game.data.handleGuis) {
renderOverlays(game);
}
}
public void renderOverlays(Game game) {
masterRenderer.renderGuis(game.data.guis);
TextMaster.render();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB