feat: finissions des barres (sauf minimap) affectation du bouton "quitter" & "mondes"

This commit is contained in:
Nicolas Hordé 2015-06-23 23:54:43 +02:00
parent a129e4c2f5
commit 6aeb3560ef
6 changed files with 90 additions and 33 deletions

View File

@ -20,6 +20,8 @@ public class ButtonLevel extends ImageTextButton {
public boolean Activated; public boolean Activated;
TextureRegion Finalled,Locked; TextureRegion Finalled,Locked;
Label Thelabel; Label Thelabel;
float scale;
ImageTextButtonStyle style;
public ButtonLevel(Level level, boolean Activated) { public ButtonLevel(Level level, boolean Activated) {
super(level.Name, AssetLoader.Skin_level, "world"+String.valueOf(level.aWorld)); super(level.Name, AssetLoader.Skin_level, "world"+String.valueOf(level.aWorld));
@ -33,10 +35,26 @@ public class ButtonLevel extends ImageTextButton {
Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked"); Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked");
} }
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f); this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
this.setBounds(level.X, level.Y*AssetLoader.ratio, 111, 125); this.scale=1f;
this.setBounds(level.X, level.Y*AssetLoader.ratio, 111*scale, 125*scale);
Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort"); Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort");
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f); Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f);
Thelabel.setPosition(level.X+54, level.Y*AssetLoader.ratio+20, Align.bottom | Align.center); Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
}
@Override
public void setScale(float scale) {
this.scale=scale;
this.setBounds(level.X, level.Y*AssetLoader.ratio, 111*scale, 125*scale);
Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
Thelabel.setFontScale(scale);
style= this.getStyle();
style.pressedOffsetX=style.pressedOffsetX*scale;
style.pressedOffsetY=style.pressedOffsetY*scale;
style.unpressedOffsetX=style.unpressedOffsetX*scale;
style.unpressedOffsetY=style.unpressedOffsetY*scale;
style.font.setScale(scale);
this.setStyle(this.style);
} }
public Color getLevelcolor() { public Color getLevelcolor() {
@ -49,7 +67,7 @@ public class ButtonLevel extends ImageTextButton {
level.X=x; level.X=x;
level.Y=y; level.Y=y;
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f); Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f);
Thelabel.setPosition(level.X+54, level.Y*AssetLoader.ratio+20, Align.bottom | Align.center); Thelabel.setPosition(level.X+54*scale, level.Y*AssetLoader.ratio+20*scale, Align.bottom | Align.center);
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f); this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
} }
@ -57,10 +75,10 @@ public class ButtonLevel extends ImageTextButton {
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
if (level.Special) { if (level.Special) {
batch.draw(Finalled,level.X,level.Y*AssetLoader.ratio); batch.draw(Finalled,level.X,level.Y*AssetLoader.ratio,Finalled.getRegionWidth()*scale,Finalled.getRegionHeight()*scale);
} }
if (!Activated) { if (!Activated) {
batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y*AssetLoader.ratio+this.getHeight()-Locked.getRegionWidth()); batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y*AssetLoader.ratio+this.getHeight()-Locked.getRegionHeight(),Locked.getRegionWidth()*scale,Locked.getRegionHeight()*scale);
} }
Thelabel.draw(batch, 1f); Thelabel.draw(batch, 1f);
} }

View File

@ -534,7 +534,7 @@ public class SaveObject {
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.", "Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
"Ne", "Ne",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1}, new int[]{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
1000f, 1000f,
750f, 750f,
6, 6,

View File

@ -3,15 +3,21 @@ package fr.evolving.screens;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import fr.evolving.worlds.GameRenderer; import fr.evolving.worlds.GameRenderer;
import fr.evolving.worlds.GameWorld; import fr.evolving.worlds.GameWorld;
import fr.evolving.worlds.LevelRenderer; import fr.evolving.worlds.LevelRenderer;
import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.inputs.InputHandler; import fr.evolving.inputs.InputHandler;
@ -20,24 +26,24 @@ public class GameScreen implements Screen {
private Timer ScrollTimer; private Timer ScrollTimer;
private TimerTask ScrollTask; private TimerTask ScrollTask;
private Stage stage; private Stage stage;
private Table table,table2; private Table table;
private GameWorld world; private GameWorld world;
private GameRenderer Renderer; private GameRenderer Renderer;
private float runTime; private float runTime;
public Level level; public Level level;
private ImageButton[] bottom; private ImageButton[] Barre;
private ImageButton[] topleft; private ImageTextButton cycle,temp,nrj,rayon,cout,tech;
String[] bottom_tocreate={"run","stop","speed","separator","move","zoomp","zoomm","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"}; String[] tocreate={"run","stop","speed","separator","move","zoomp","zoomm","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"};
String[] topleft_tocreate={"cycle","temp","nrj","rayon"}; private ButtonLevel buttonlevel;
private Objectives objectives;
// This is the constructor, not the class declaration // This is the constructor, not the class declaration
public GameScreen(Level level) { public GameScreen(Level alevel) {
Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)"); Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)");
stage = new Stage(AssetLoader.viewport); stage = new Stage(AssetLoader.viewport);
table = new Table(); table = new Table();
table2 = new Table(); this.level=alevel;
this.level=level;
world = new GameWorld(level); world = new GameWorld(level);
Renderer = new GameRenderer(this); Renderer = new GameRenderer(this);
world.setRenderer(Renderer); world.setRenderer(Renderer);
@ -53,15 +59,41 @@ public class GameScreen implements Screen {
}; };
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du bas"); Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du bas");
bottom=new ImageButton[bottom_tocreate.length]; Barre=new ImageButton[tocreate.length];
int i=0; int i=0;
for (String tocreateitem: bottom_tocreate) for (String tocreateitem: tocreate)
bottom[i++]= new ImageButton(AssetLoader.Skin_level,tocreateitem); Barre[i++]= new ImageButton(AssetLoader.Skin_level,tocreateitem);
topleft=new ImageButton[topleft_tocreate.length]; Barre[10].addListener(new ClickListener(){
i=0; @Override
for (String tocreateitem: topleft_tocreate) public void clicked(InputEvent event, float x, float y) {
topleft[i++]= new ImageButton(AssetLoader.Skin_level,tocreateitem); ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(level.aWorld));
}
});
Barre[12].addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut");
cycle=new ImageTextButton(String.valueOf(level.Cycle),AssetLoader.Skin_level,"cycle2");
cycle.setPosition(10,AssetLoader.height-74);
temp=new ImageTextButton(String.valueOf(level.Temp),AssetLoader.Skin_level,"temp2");
temp.setPosition(210,AssetLoader.height-74);
nrj=new ImageTextButton(String.valueOf(level.Nrj),AssetLoader.Skin_level,"nrj2");
nrj.setPosition(410,AssetLoader.height-74);
rayon=new ImageTextButton(String.valueOf(level.Rayon),AssetLoader.Skin_level,"rayon2");
rayon.setPosition(610,AssetLoader.height-74);
tech=new ImageTextButton(String.valueOf(level.Tech),AssetLoader.Skin_level,"tech2");
tech.setPosition(1345,AssetLoader.height-74);
cout=new ImageTextButton(String.valueOf(level.Cout),AssetLoader.Skin_level,"cout2");
cout.setPosition(1445,AssetLoader.height-74);
objectives=new Objectives();
objectives.setVictory(level.Victory);
objectives.setPosition(960,AssetLoader.height-85);
buttonlevel=new ButtonLevel(level,true);
buttonlevel.setScale(0.6f);
buttonlevel.setPosition(860,AssetLoader.height-88);
} }
@Override @Override
@ -81,13 +113,17 @@ public class GameScreen implements Screen {
public void show() { public void show() {
Gdx.app.log("*****","Affichage du niveau."); Gdx.app.log("*****","Affichage du niveau.");
table.bottom().left().padBottom(10f); table.bottom().left().padBottom(10f);
for (int i=0;i<bottom_tocreate.length;i++) for (int i=0;i<tocreate.length;i++)
table.add(bottom[i]).padLeft(10f); table.add(Barre[i]).padLeft(10f);
stage.addActor(objectives);
stage.addActor(buttonlevel);
stage.addActor(rayon);
stage.addActor(nrj);
stage.addActor(temp);
stage.addActor(cycle);
stage.addActor(table); stage.addActor(table);
table2.top().left().padTop(10f); stage.addActor(tech);
for (int i=0;i<topleft_tocreate.length;i++) stage.addActor(cout);
table2.add(topleft[i]).padLeft(10f);
stage.addActor(table2);
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
} }

View File

@ -117,8 +117,8 @@ public class LevelScreen implements Screen {
showlevel(buttonLevels[0]); showlevel(buttonLevels[0]);
} }
public LevelScreen() { public LevelScreen(int aworld) {
this.world=0; this.world=aworld;
Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table)"); Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table)");
stage = new Stage(AssetLoader.viewport); stage = new Stage(AssetLoader.viewport);
table = new Table(); table = new Table();
@ -193,7 +193,7 @@ public class LevelScreen implements Screen {
Victory.setPosition(1216, 185); Victory.setPosition(1216, 185);
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons de niveau."); Gdx.app.debug(getClass().getSimpleName(),"Création des boutons de niveau.");
thelevels= SaveObject.initObject(); thelevels= SaveObject.initObject();
loadWorld(0); loadWorld(world);
} }
@Override @Override

View File

@ -46,7 +46,7 @@ public class SplashScreen implements Screen {
}),Actions.run(new Runnable() { }),Actions.run(new Runnable() {
@Override @Override
public void run() { public void run() {
((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen()); ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(0));
} }
}))); })));
} }

View File

@ -40,7 +40,10 @@ public class GameRenderer {
shapeRenderer.begin(ShapeType.Filled); shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(0.2f, 0.2f, 0.2f, 0.5f); shapeRenderer.setColor(0.2f, 0.2f, 0.2f, 0.5f);
shapeRenderer.rect(5, 5, AssetLoader.width-10, 74); shapeRenderer.rect(5, 5, AssetLoader.width-10, 74);
shapeRenderer.rect(5, AssetLoader.height-81, 550, 74); shapeRenderer.rect(5, AssetLoader.height-81, 810, 74);
shapeRenderer.rect(825, AssetLoader.height-107, 500, 100);
shapeRenderer.rect(1335, AssetLoader.height-107, 200, 100);
shapeRenderer.circle(1850, AssetLoader.height, 300, 60);
shapeRenderer.end(); shapeRenderer.end();
batcher.begin(); batcher.begin();
batcher.disableBlending(); batcher.disableBlending();