SetNewText dans Text.java
This commit is contained in:
parent
516f18c99c
commit
a2fb0a4719
@ -286,12 +286,13 @@ public class Engine {
|
|||||||
if (System.currentTimeMillis() - timer > 1000) {
|
if (System.currentTimeMillis() - timer > 1000) {
|
||||||
timer += 1000;
|
timer += 1000;
|
||||||
System.out.println("FPS: " + frame);
|
System.out.println("FPS: " + frame);
|
||||||
|
texTest.setNewText("FPS " + frame);
|
||||||
frame = 0;
|
frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!nextFrame) {
|
// while (!nextFrame) {
|
||||||
nextFrame = System.currentTimeMillis() - lastFrame >= 16.66f;
|
// nextFrame = System.currentTimeMillis() - lastFrame >= 16.66f;
|
||||||
}
|
// }
|
||||||
|
|
||||||
nextFrame = false;
|
nextFrame = false;
|
||||||
if (engine.shouldClose()) engine.setRunning(false);
|
if (engine.shouldClose()) engine.setRunning(false);
|
||||||
|
@ -8,10 +8,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Text {
|
public class Text {
|
||||||
|
|
||||||
private final List<ObjectGl> charList;
|
private List<ObjectGl> charList;
|
||||||
private float size;
|
private final float size;
|
||||||
private Engine engine;
|
private final Engine engine;
|
||||||
private float zPos;
|
private final float zPos;
|
||||||
|
|
||||||
public Text(String text, float z, float size, Engine engine){
|
public Text(String text, float z, float size, Engine engine){
|
||||||
this.charList = new ArrayList<>();
|
this.charList = new ArrayList<>();
|
||||||
@ -19,12 +19,16 @@ public class Text {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.textToArrayObjectGl(text);
|
this.textToArrayObjectGl(text);
|
||||||
|
this.addCharListInEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void textToArrayObjectGl(String s){
|
private void textToArrayObjectGl(String s){
|
||||||
for (int i = 0; i < s.length(); i++){
|
for (int i = 0; i < s.length(); i++){
|
||||||
this.charList.add(this.charToObjectGl(s.charAt(i)));
|
this.charList.add(this.charToObjectGl(s.charAt(i)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCharListInEngine(){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ObjectGl c : this.charList){
|
for (ObjectGl c : this.charList){
|
||||||
c.translate(new Vector3f(i * 10.0f * this.size, 0.0f, 0.0f));
|
c.translate(new Vector3f(i * 10.0f * this.size, 0.0f, 0.0f));
|
||||||
@ -33,6 +37,14 @@ public class Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNewText(String text){
|
||||||
|
// TODO NE PAS REGENERER L'OBJECTGL DE ZERO A CHAQUE FOIS
|
||||||
|
this.remove();
|
||||||
|
this.charList = new ArrayList<>();
|
||||||
|
textToArrayObjectGl(text);
|
||||||
|
this.addCharListInEngine();
|
||||||
|
}
|
||||||
|
|
||||||
public void remove(){
|
public void remove(){
|
||||||
for (ObjectGl obj : this.charList){
|
for (ObjectGl obj : this.charList){
|
||||||
this.engine.remove_objectGl(obj);
|
this.engine.remove_objectGl(obj);
|
||||||
@ -48,6 +60,9 @@ public class Text {
|
|||||||
else if (a < 91 && a > 64){
|
else if (a < 91 && a > 64){
|
||||||
objectGl.setTextureWrap(0.0f + (a - 65) * 10.0f,30.0f,10.0f,10.0f, ObjectGl.DEFAULT);
|
objectGl.setTextureWrap(0.0f + (a - 65) * 10.0f,30.0f,10.0f,10.0f, ObjectGl.DEFAULT);
|
||||||
}
|
}
|
||||||
|
else if (a < 64 && a > 31){
|
||||||
|
objectGl.setTextureWrap(0.0f + (a - 32) * 10.0f,0.0f,10.0f,10.0f, ObjectGl.DEFAULT);
|
||||||
|
}
|
||||||
return objectGl;
|
return objectGl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user