Countdown now opengl-rendered -> no more bugs

Fixed minor bugs
This commit is contained in:
=
2018-05-07 16:25:27 +02:00
parent 2e24ef619d
commit 0ec17dfe39
22 changed files with 530 additions and 463 deletions

View File

@ -392,7 +392,7 @@
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="true" deadly="false" leftEdge="16.589409" rightEdge="17.557407" height="0.318" y="-1.2799997">
<moveComponent length="3.273" rotation="71.623" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="true" triggerDistance="-0.372"/>
<moveComponent length="3.119" rotation="71.623" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="true" triggerDistance="-0.372"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="true" leftEdge="20.558361" rightEdge="21.06836" height="0.306" y="-0.44700003">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
@ -803,7 +803,7 @@
<tileData x="16.000044" width="38.000088"/>
</ceilingTiles>
<obstacles class="java.util.ArrayList">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="1.7078334" rightEdge="2.0388334" height="0.268" y="-0.46600002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="1.7078335" rightEdge="2.0388334" height="0.268" y="-0.46600002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="2.6304982" rightEdge="3.0894983" height="0.28" y="-0.46000004">
@ -821,7 +821,7 @@
<obstacleData floating="false" moving="false" deadly="false" leftEdge="10.603366" rightEdge="11.103366" height="0.268" y="-0.46600002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="11.996707" rightEdge="12.496707" height="0.5" y="-0.35000002">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="11.996707" rightEdge="12.496707" height="0.5" y="-0.35000002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="12.564209" rightEdge="13.609209" height="0.153" y="-0.2701668">
@ -1081,122 +1081,122 @@
</stars>
<energy x="12.763356" y="0.43999994"/>
</level>
<level packId="2" id="14" goalX="31.86002" startSpeed="0.5" endSpeed="0.5" terrainEdge="-0.6" ceilingEdge="1.0">
<level packId="2" id="14" goalX="32.48672" startSpeed="0.5" endSpeed="0.5" terrainEdge="-0.6" ceilingEdge="1.0">
<terrainTiles class="java.util.ArrayList">
<tileData x="0.4728346" width="6.945669"/>
<tileData x="4.4919186" width="0.2484994"/>
<tileData x="5.8852577" width="1.7361789"/>
<tileData x="7.6318464" width="0.5570016"/>
<tileData x="18.38909" width="3.0254707"/>
<tileData x="26.691662" width="8.093676"/>
<tileData x="0.58950114" width="7.1790023"/>
<tileData x="4.7252517" width="0.24849892"/>
<tileData x="6.315257" width="2.1295123"/>
<tileData x="8.258523" width="0.5570221"/>
<tileData x="19.015753" width="3.0254707"/>
<tileData x="27.318325" width="8.093674"/>
</terrainTiles>
<ceilingTiles class="java.util.ArrayList">
<tileData x="14.43001" width="34.86002"/>
<tileData x="14.7433605" width="35.48672"/>
</ceilingTiles>
<obstacles class="java.util.ArrayList">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="1.5323324" rightEdge="2.1943324" height="0.866" y="-0.16700003">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="1.6256657" rightEdge="2.2876656" height="0.866" y="-0.16700003">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="2.218999" rightEdge="2.880999" height="1.172" y="-0.013999999">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="2.3123322" rightEdge="2.9743323" height="1.172" y="-0.013999999">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="2.909165" rightEdge="3.164165" height="1.057" y="-0.0715">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.0358315" rightEdge="3.2908316" height="1.057" y="-0.0715">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.207998" rightEdge="3.411998" height="0.943" y="-0.12850001">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.3613312" rightEdge="3.5653312" height="0.943" y="-0.12850001">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="true" leftEdge="3.461334" rightEdge="3.665334" height="0.815" y="-0.19250003">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.6546671" rightEdge="3.8586671" height="0.815" y="-0.19250003">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.7146685" rightEdge="3.9186685" height="0.713" y="-0.24350002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="3.9480016" rightEdge="4.1520014" height="0.713" y="-0.24350002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="4.3946686" rightEdge="4.598668" height="0.484" y="-0.35800004">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="4.6280017" rightEdge="4.832001" height="0.484" y="-0.35800004">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="5.0366683" rightEdge="5.316668" height="0.777" y="-0.21150002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="5.2700014" rightEdge="5.550001" height="0.777" y="-0.21150002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="5.4110055" rightEdge="5.589006" height="0.662" y="-0.26900002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="5.791005" rightEdge="5.9690056" height="0.662" y="-0.26900002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="5.6855054" rightEdge="5.9145055" height="0.522" y="-0.33900002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="6.165505" rightEdge="6.394505" height="0.522" y="-0.33900002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="true" leftEdge="5.993676" rightEdge="6.299676" height="0.369" y="-0.41550004">
<obstacleData floating="false" moving="false" deadly="true" leftEdge="6.5736756" rightEdge="6.8796754" height="0.369" y="-0.41550004">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="6.387845" rightEdge="6.7188454" height="0.255" y="-0.47250003">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="7.014511" rightEdge="7.3455114" height="0.255" y="-0.47250003">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="7.3833475" rightEdge="7.8833475" height="0.204" y="-0.49800003">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="8.010023" rightEdge="8.510023" height="0.204" y="-0.49800003">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="6.2150116" rightEdge="7.2850113" height="0.242" y="0.34333315">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="6.795011" rightEdge="7.8650107" height="0.242" y="0.34333315">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="7.9856877" rightEdge="8.647688" height="0.382" y="0.14999996">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="8.612377" rightEdge="9.274378" height="0.382" y="0.14999996">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="8.709686" rightEdge="10.543686" height="0.331" y="0.060000002">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="9.336376" rightEdge="11.170376" height="0.331" y="0.060000002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="12.069031" rightEdge="14.031031" height="0.331" y="0.053333335">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="12.695721" rightEdge="14.657721" height="0.331" y="0.053333335">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="9.580188" rightEdge="10.293187" height="0.446" y="0.8999999">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="10.206878" rightEdge="10.919877" height="0.446" y="0.8999999">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="10.737022" rightEdge="11.883022" height="0.675" y="0.8533331">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="11.363712" rightEdge="12.509712" height="0.675" y="0.8533331">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="10.694859" rightEdge="11.331858" height="0.318" y="-0.5866666">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="11.321548" rightEdge="11.958548" height="0.318" y="-0.5866666">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="11.677198" rightEdge="12.136198" height="0.586" y="-0.5266666">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="12.303888" rightEdge="12.762888" height="0.586" y="-0.5266666">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="14.246534" rightEdge="15.673534" height="0.344" y="-0.14666666">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="14.873224" rightEdge="16.300224" height="0.344" y="-0.14666666">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="12.703201" rightEdge="14.130201" height="0.433" y="0.8866666">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="13.329891" rightEdge="14.756891" height="0.433" y="0.8866666">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="true" leftEdge="14.595043" rightEdge="15.385044" height="0.382" y="0.55333334">
<obstacleData floating="true" moving="false" deadly="true" leftEdge="15.221733" rightEdge="16.011734" height="0.382" y="0.55333334">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="20.580023" rightEdge="21.080023" height="1.569" y="0.18449998">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="21.206686" rightEdge="21.706686" height="1.569" y="0.18449998">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="true" moving="false" deadly="false" leftEdge="19.961805" rightEdge="21.744806" height="0.5" y="-1.16">
<obstacleData floating="true" moving="false" deadly="false" leftEdge="20.588469" rightEdge="22.37147" height="0.5" y="-1.16">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="25.138582" rightEdge="26.234583" height="0.318" y="-0.44100004">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="25.765245" rightEdge="26.861246" height="0.318" y="-0.44100004">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="26.278217" rightEdge="27.348217" height="0.586" y="-0.307">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="26.90488" rightEdge="27.97488" height="0.586" y="-0.307">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="27.380367" rightEdge="28.679367" height="0.713" y="-0.24350002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="28.00703" rightEdge="29.30603" height="0.713" y="-0.24350002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="28.724693" rightEdge="29.361694" height="0.624" y="-0.28800002">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="29.351357" rightEdge="29.988358" height="0.624" y="-0.28800002">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="false" leftEdge="29.413185" rightEdge="29.913185" height="0.535" y="-0.3325">
<obstacleData floating="false" moving="false" deadly="false" leftEdge="30.039848" rightEdge="30.539848" height="0.535" y="-0.3325">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
<obstacleData floating="false" moving="false" deadly="true" leftEdge="29.963339" rightEdge="30.67634" height="0.42" y="-0.39000005">
<obstacleData floating="false" moving="false" deadly="true" leftEdge="30.590002" rightEdge="31.303003" height="0.42" y="-0.39000005">
<moveComponent length="0.0" rotation="0.0" startOffset="0.0" direction="1.0" speed="0.0" hasPlayerXSpeed="false" triggerDistance="0.0"/>
</obstacleData>
</obstacles>
<stars class="java.util.ArrayList">
<positionData x="7.0633464" y="-0.47333318"/>
<positionData x="11.28002" y="0.33333325"/>
<positionData x="27.993254" y="0.7733332"/>
<positionData x="7.6900125" y="-0.47333318"/>
<positionData x="11.90671" y="0.33333325"/>
<positionData x="28.619917" y="0.7733332"/>
</stars>
<energy x="1.3733332" y="-0.45333335"/>
<energy x="1.4666665" y="-0.45333335"/>
</level>
</levels>
</levelPack>

View File

@ -0,0 +1,15 @@
uniform mat4 mvpMatrix;
uniform mat4 transformationMatrix;
attribute vec4 position;
attribute vec2 texCoords;
varying vec2 pass_TexCoords;
void main() {
vec4 transformatedPosition = transformationMatrix * position;
gl_Position = mvpMatrix * transformatedPosition;
pass_TexCoords = texCoords;
}

View File

@ -0,0 +1,95 @@
package de.frajul.endlessroll.entities;
import java.util.concurrent.atomic.AtomicBoolean;
import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.Entity;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.sounds.SoundManager;
import de.frajul.endlessroll.sounds.SoundStream;
/**
* Created by Julian on 31.07.2016.
*/
public class Countdown extends Entity {
private Game game;
private SoundManager soundManager;
private SoundStream soundStream;
private Texture texture3;
private Texture texture2;
private Texture texture1;
private AtomicBoolean running;
private int currentSeconds = 0;
private float time = 0;
public Countdown(Game game, SoundManager soundManager, TexturePack texturePack) {
super(texturePack.countdown3, new Vector(), 0.8f, 0.8f);
this.game = game;
this.soundManager = soundManager;
this.texture3 = texturePack.countdown1;
this.texture2 = texturePack.countdown2;
this.texture1 = texturePack.countdown3;
running = new AtomicBoolean(false);
}
public void update(float delta) {
if (running.get()) {
time += delta;
if (time >= 1000 && currentSeconds == 0) {
currentSeconds = 1;
onNextSecondThread(currentSeconds, true);
}
if (time >= 2000 && currentSeconds == 1) {
currentSeconds = 2;
onNextSecondThread(currentSeconds, true);
}
if (time >= 3000 && currentSeconds == 2) {
currentSeconds = 3;
running.set(false);
game.countdownFinished();
}
}
}
public void start() {
reset();
running.set(true);
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
}
public void stop() {
running.set(false);
if (soundStream != null)
soundManager.stopSound(soundStream);
}
private void reset() {
time = 0;
currentSeconds = 0;
onNextSecondThread(0, false);
}
private void onNextSecondThread(final int second, final boolean playSound) {
if (playSound) {
if (second == 2)
soundStream = soundManager.playSound(soundManager.countdownSoundLast);
else
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
}
super.setTexture(texture1);
if (second == 1)
super.setTexture(texture2);
else if (second == 2)
super.setTexture(texture3);
}
@Override
public boolean isVisible() {
return running.get();
}
}

View File

@ -19,6 +19,7 @@ public class TexturePack {
public final Texture playerArrow;
public final Texture star;
public final Texture energy;
public final Texture countdown3, countdown2, countdown1;
public TexturePack(Context context) {
loader = new TextureLoader(context);
@ -28,6 +29,10 @@ public class TexturePack {
star = loadTexture(R.drawable.currency_star);
energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2);
countdown3 = loadTexture(R.drawable.countdown_3);
countdown2 = loadTexture(R.drawable.countdown_2);
countdown1 = loadTexture(R.drawable.countdown_1);
PlayerShape.loadAllTextures(this);
ToolType.loadAllToolTextures(this);
World.loadAllSpecificTextures(this);

View File

@ -29,6 +29,7 @@ import de.frajul.endlessroll.main.screens.GameScreen;
import de.frajul.endlessroll.main.screens.Screen;
import de.frajul.endlessroll.rendering.Rendering;
import de.frajul.endlessroll.sqlDatabase.MyDatabase;
import de.frajul.endlessroll.entities.Countdown;
import de.frajul.endlessroll.views.ToolButton;
import de.frajul.endlessroll.views.ToolButtonBar;
import de.frajul.endlessroll.views.ViewManager;
@ -44,6 +45,7 @@ public class Game extends Rendering<GameScene> {
private LevelPack levelPack;
private ParticleSystem particleSystem;
private Firework firework;
private Countdown countdown;
private ToolType currentTool;
private Player player;
@ -74,6 +76,8 @@ public class Game extends Rendering<GameScene> {
if (isFirstTime) {
scene = new GameScene(gameActivity, texturePack, particleSystem);
firework = new Firework(particleSystem.firework, scene.getCamera());
countdown = new Countdown(this, gameActivity.getSoundManager(), texturePack);
scene.getGuis().add(countdown);
if (level != null)
startGame(levelPack, level);
} else {
@ -108,7 +112,7 @@ public class Game extends Rendering<GameScene> {
viewManager.setShowFps(gameActivity.getDataStorageHandler().readIsShowFps());
viewManager
.setBoostPerformance(gameActivity.getDataStorageHandler().readIsPerformanceBoost());
viewManager.startCountdown();
countdown.start();
}
} catch (Exception e) {
onException(e);
@ -155,7 +159,7 @@ public class Game extends Rendering<GameScene> {
collisionManager.update(physics, scene, timer);
break;
case COUNTDOWN:
viewManager.updateCountdown(timer.getFrameTimeSeconds());
countdown.update(timer.getFrameTimeSeconds());
break;
}
} catch (Exception e) {
@ -210,7 +214,7 @@ public class Game extends Rendering<GameScene> {
viewManager.setShowFps(gameActivity.getDataStorageHandler().readIsShowFps());
viewManager
.setBoostPerformance(gameActivity.getDataStorageHandler().readIsPerformanceBoost());
viewManager.startCountdown();
countdown.start();
}
public void startNextLevel() {
@ -251,7 +255,7 @@ public class Game extends Rendering<GameScene> {
gameActivity.getSoundManager().getCurrentGameMusic().pause();
viewManager.showShortMenu();
if (gameState == GameState.COUNTDOWN)
viewManager.stopCountdown();
countdown.stop();
gameState = GameState.PAUSED;
}

View File

@ -51,6 +51,7 @@ public abstract class Scene {
protected final List<Obstacle> obstacles = Collections.synchronizedList(new ArrayList<Obstacle>());
protected final List<Tool> tools = Collections.synchronizedList(new ArrayList<Tool>());
protected Collectables collectables = new Collectables();
protected final List<Entity> guis = Collections.synchronizedList(new ArrayList<Entity>());
public Scene(GameActivity gameActivity, TexturePack texturePack, ParticleSystem particleSystem) {
this.gameActivity = gameActivity;
@ -192,6 +193,10 @@ public abstract class Scene {
return collectables;
}
public synchronized List<Entity> getGuis() {
return guis;
}
public Player getPlayer() {
return player;
}

View File

@ -1,6 +1,7 @@
package de.frajul.endlessroll.main.screens;
import android.widget.RelativeLayout;
import android.widget.TextView;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;
@ -13,6 +14,8 @@ public class PreStartScreen extends Screen<RelativeLayout> {
public PreStartScreen(GameActivity gameActivity) {
super(ScreenType.PRE_START, gameActivity, R.layout.pre_start_screen);
TextView textView = (TextView) layout.findViewById(R.id.pre_start_screen_text);
textView.setTypeface(gameActivity.getTypeface());
}
@Override

View File

@ -18,6 +18,18 @@ public class MatrixCreator {
this.height = height;
}
public float[] createGuiModelViewProjectionMatrix() {
float[] mvpMatrix = new float[16];
float[] projectionMatrix = new float[16];
float[] viewMatrix = new float[16];
float ratio = width / height;
Matrix.frustumM(projectionMatrix, 0, -ratio, ratio, -1, 1, 1, 2);
Matrix.setLookAtM(viewMatrix, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0);
Matrix.multiplyMM(mvpMatrix, 0, projectionMatrix, 0, viewMatrix, 0);
return mvpMatrix;
}
public float[] createModelViewProjectionMatrix(Camera camera) {
float[] mvpMatrix = new float[16];
float[] projectionMatrix = new float[16];

View File

@ -24,6 +24,7 @@ import de.frajul.endlessroll.rendering.MatrixCreator;
import de.frajul.endlessroll.rendering.Quad;
import de.frajul.endlessroll.rendering.Rendering;
import de.frajul.endlessroll.rendering.shader.EntityShader;
import de.frajul.endlessroll.rendering.shader.GuiShader;
import de.frajul.endlessroll.rendering.shader.ObstacleShader;
import de.frajul.endlessroll.rendering.shader.SimpleShader;
import de.frajul.endlessroll.rendering.shader.TerrainShader;
@ -46,6 +47,7 @@ public class GameRenderer implements GLSurfaceView.Renderer {
private ObstacleShader obstacleShader;
private TerrainShader terrainShader;
private SimpleShader simpleShader;
private GuiShader guiShader;
private TexturePack texturePack;
private Timer timer;
@ -78,6 +80,7 @@ public class GameRenderer implements GLSurfaceView.Renderer {
obstacleShader = new ObstacleShader(activity);
terrainShader = new TerrainShader(activity);
simpleShader = new SimpleShader(activity);
guiShader = new GuiShader(activity);
texturePack = new TexturePack(activity);
timer = new Timer();
} catch (Exception e) {
@ -122,17 +125,39 @@ public class GameRenderer implements GLSurfaceView.Renderer {
renderEntityList(gl, scene.getUncategorizedEntities(), scene.getCamera());
renderFbo(gl);
renderGuis(gl, scene.getGuis());
}
}
private void renderGuis(GL10 gl, List<Entity> guis) {
guiShader.start();
guiShader.loadMVPMatrix(matrixCreator);
synchronized (guis) {
for (Entity gui : guis)
renderGui(gl, gui);
}
guiShader.stop();
}
private void renderGui(GL10 gl, Entity gui) {
if (!gui.isVisible())
return;
gl.glActiveTexture(GL10.GL_TEXTURE0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, gui.getTexture().getId());
guiShader.loadTransformationMatrix(matrixCreator, gui);
quad.draw();
}
private void renderBackground(GL10 gl, Scene scene) {
entityShader.start();
entityShader.loadMVPMatrix(matrixCreator, scene.getCamera());
List<BackgroundLayer> layers = scene.getBackground().getLayers();
synchronized (layers) {
for(BackgroundLayer layer : layers){
synchronized (layer){
for(Entity backgroundPart : layer)
for (BackgroundLayer layer : layers) {
synchronized (layer) {
for (Entity backgroundPart : layer)
renderEntity(gl, backgroundPart);
}
}

View File

@ -0,0 +1,39 @@
package de.frajul.endlessroll.rendering.shader;
import android.content.Context;
import android.opengl.GLES20;
import de.frajul.endlessroll.entities.Entity;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.main.game.Camera;
import de.frajul.endlessroll.rendering.MatrixCreator;
/**
* Created by Julian on 10.08.2016.
*/
public class GuiShader extends ShaderProgram {
private int location_mvpMatrix;
private int location_transformationMatrix;
public GuiShader(Context context) throws Exception {
super(context, "shader/guiVertexShader.glsl", "shader/simpleFragmentShader.glsl");
}
@Override
protected void loadUniformLocations() {
location_mvpMatrix = super.getUniformLocation("mvpMatrix");
location_transformationMatrix = super.getUniformLocation("transformationMatrix");
}
public void loadMVPMatrix(MatrixCreator matrixCreator) {
float[] mvpMatrix = matrixCreator.createGuiModelViewProjectionMatrix();
GLES20.glUniformMatrix4fv(location_mvpMatrix, 1, false, mvpMatrix, 0);
}
public void loadTransformationMatrix(MatrixCreator matrixCreator, Entity entity) {
float[] transformationMatrix = matrixCreator.createTransformationMatrix(entity);
GLES20.glUniformMatrix4fv(location_transformationMatrix, 1, false, transformationMatrix, 0);
}
}

View File

@ -1,106 +0,0 @@
package de.frajul.endlessroll.views;
import android.view.View;
import android.widget.TextView;
import java.util.concurrent.atomic.AtomicBoolean;
import de.frajul.endlessroll.R;
import de.frajul.endlessroll.main.GameActivity;
import de.frajul.endlessroll.main.GameLog;
import de.frajul.endlessroll.main.game.Game;
import de.frajul.endlessroll.sounds.SoundStream;
/**
* Created by Julian on 31.07.2016.
*/
public class Countdown {
private Game game;
private GameActivity gameActivity;
private TextView textView;
private SoundStream soundStream;
private AtomicBoolean running;
private int currentSeconds = 0;
private float time = 0;
public Countdown(Game game, GameActivity gameActivity, TextView textView) {
this.game = game;
this.gameActivity = gameActivity;
this.textView = textView;
this.textView.setTypeface(gameActivity.getTypeface());
running = new AtomicBoolean(false);
}
public void update(float delta) {
if (running.get()) {
time += delta;
if (time >= 1000 && currentSeconds == 0) {
currentSeconds = 1;
onNextSecondInUiThread(currentSeconds, true);
}
if (time >= 2000 && currentSeconds == 1) {
currentSeconds = 2;
onNextSecondInUiThread(currentSeconds, true);
}
if (time >= 3000 && currentSeconds == 2) {
currentSeconds = 3;
gameActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
textView.setVisibility(View.GONE);
}
});
running.set(false);
game.countdownFinished();
}
}
}
public void start() {
reset();
running.set(true);
textView.setVisibility(View.VISIBLE);
soundStream = gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().countdownSoundSingle);
}
public void stop() {
textView.setVisibility(View.GONE);
running.set(false);
if (soundStream != null)
gameActivity.getSoundManager().stopSound(soundStream);
}
private void reset() {
time = 0;
currentSeconds = 0;
onNextSecondInUiThread(0, false);
}
private void onNextSecondInUiThread(final int second, final boolean playSound) {
gameActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(playSound){
if(second == 2)
soundStream = gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().countdownSoundLast);
else
soundStream = gameActivity.getSoundManager()
.playSound(gameActivity.getSoundManager().countdownSoundSingle);
}
textView.setText((3 - second) + "");
int color = R.color.countdown1;
if (second == 1)
color = R.color.countdown2;
else if (second == 2)
color = R.color.countdown3;
textView.setTextColor(game.getContext().getResources().getColor(color));
}
});
}
}

View File

@ -35,7 +35,6 @@ public class ViewManager implements View.OnClickListener {
private GoalMessage goalMessage;
public ToolButtonBar toolButtonBar;
public ShortMenu shortMenu;
private Countdown countdown;
private boolean showFps = false;
private boolean boostPerformance = false;
@ -62,8 +61,6 @@ public class ViewManager implements View.OnClickListener {
layout.findViewById(R.id.game_game_over_message));
goalMessage = new GoalMessage(game, gameScreen, gameActivity,
layout.findViewById(R.id.game_goal_message));
countdown = new Countdown(game, gameActivity,
(TextView) layout.findViewById(R.id.game_countdown));
}
});
pauseButton = (ImageView) layout.findViewById(R.id.game_pausebutton);
@ -86,10 +83,6 @@ public class ViewManager implements View.OnClickListener {
goalMessage.prepareToBeShown();
}
public void updateCountdown(float delta) {
countdown.update(delta);
}
public void showBombErrorMessage(float xPos, float yPos) {
for (BombErrorMessage bombErrorMessage : bombErrorMessages) {
if (!bombErrorMessage.isAnimationRunning()) {
@ -150,14 +143,6 @@ public class ViewManager implements View.OnClickListener {
shortMenu.setVisible(false);
}
public void startCountdown() {
countdown.start();
}
public void stopCountdown() {
countdown.stop();
}
public void update(final boolean gameRunning, final Timer timer, final float playerX) {
gameViewHandler.startInUiThread(new Runnable() {
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -71,15 +71,4 @@
android:layout_centerVertical="true"
android:visibility="invisible"/>
<TextView
android:id="@+id/game_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/game_countdown_placeholder"
android:textColor="@color/countdown3"
android:textSize="150sp"
android:visibility="gone"/>
</RelativeLayout>

View File

@ -5,10 +5,10 @@
android:background="@color/primary">
<TextView
android:id="@+id/pre_start_screen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/pre_start_screen_loading"
android:textSize="30sp"
android:textStyle="bold"/>
android:textSize="30sp"/>
</RelativeLayout>

View File

@ -26,10 +26,6 @@
<color name="toolslotEnabled">#db41e42b</color>
<color name="toolslotEnabledSelected">#b3d700</color>
<color name="countdown3">#f41602</color>
<color name="countdown2">#f47b02</color>
<color name="countdown1">#f4d802</color>
<color name="background_message">#9d000000</color>
<color name="background_short_menu">#5b000000</color>
<color name="background_tutorial">#3d000000</color>