From a129e4c2f53dbe2d3b592271f6f7c2ce8938d8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Mon, 22 Jun 2015 23:36:08 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20modification=20de=20gamescreen=20et=20g?= =?UTF-8?q?amerenderer=20lancement=20de=20l'=C3=A9cran=20de=20jeu=20lors?= =?UTF-8?q?=20du=20click=20sur=20un=20niveau=20dans=20l'=C3=A9cran=20des?= =?UTF-8?q?=20mondes=20cr=C3=A9ation=20de=20la=20barre=20d'outil=20du=20ba?= =?UTF-8?q?s=20d=C3=A9but=20cr=C3=A9ation=20de=20la=20barre=20du=20haut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/ButtonLevel.java | 10 +++ core/src/fr/evolving/assets/AssetLoader.java | 13 +-- core/src/fr/evolving/effects/Laser.java | 26 +++--- core/src/fr/evolving/screens/GameScreen.java | 82 +++++++++++++++---- core/src/fr/evolving/screens/LevelScreen.java | 35 ++++++-- .../src/fr/evolving/screens/SplashScreen.java | 2 +- core/src/fr/evolving/worlds/GameRenderer.java | 47 +++-------- core/src/fr/evolving/worlds/GameWorld.java | 15 ++-- .../src/fr/evolving/worlds/LevelRenderer.java | 10 +-- 9 files changed, 145 insertions(+), 95 deletions(-) diff --git a/core/src/fr/evolving/UI/ButtonLevel.java b/core/src/fr/evolving/UI/ButtonLevel.java index fef2fda..ec34b00 100644 --- a/core/src/fr/evolving/UI/ButtonLevel.java +++ b/core/src/fr/evolving/UI/ButtonLevel.java @@ -43,6 +43,16 @@ public class ButtonLevel extends ImageTextButton { return AssetLoader.Levelcolors[level.aWorld]; } + @Override + public void setPosition(float x, float y) { + super.setPosition(x,y); + level.X=x; + level.Y=y; + 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); + this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f); + } + @Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 64b89bb..55fb82c 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -88,17 +88,8 @@ public class AssetLoader { Gdx.app.debug("AssetLoader","Ajout des textures disabled,over et down"); Atlas_level = manager.get("textures/level.pack"); if (manager.isLoaded("textures/level.pack")) { - for(int i=0; i < 5; i++) - addstyle(Atlas_level,"leveler"+String.valueOf(i)); - addstyle(Atlas_level,"arrows"); - addstyle(Atlas_level,"arrows2"); - addstyle(Atlas_level,"exit2"); - addstyle(Atlas_level,"cout"); - addstyle(Atlas_level,"tech"); - addstyle(Atlas_level,"cycle"); - addstyle(Atlas_level,"temp"); - addstyle(Atlas_level,"nrj"); - addstyle(Atlas_level,"rayon"); + for(String toload: new String[]{"leveler0","leveler1","leveler2","leveler3","leveler4","arrows","arrows2","exit2","cout","tech","cycle","temp","nrj","rayon","logo2"}) + addstyle(Atlas_level,toload); } Gdx.app.debug("AssetLoader","Chargement des skins et attente fin chargement"); manager.load("textures/level.json", Skin.class, new SkinLoader.SkinParameter("textures/level.pack")); diff --git a/core/src/fr/evolving/effects/Laser.java b/core/src/fr/evolving/effects/Laser.java index 02535cc..03ae839 100644 --- a/core/src/fr/evolving/effects/Laser.java +++ b/core/src/fr/evolving/effects/Laser.java @@ -30,7 +30,11 @@ public class Laser { overlay=AssetLoader.Skin_level.getAtlas().findRegion("overlay"); } - public void draw(Batch Laser,float x1,float y1,float x2,float y2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + public void draw(Batch Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1+26; + float y1=yy1+20; + float x2=xx2+26; + float y2=yy2+20; Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1)); float length = vectorall.len(); Vector2 vectoradd = vectorall.scl(10/length); @@ -45,11 +49,12 @@ public class Laser { Laser.end(); } - public void drawnotsoold(float x1,float y1,float x2,float y2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { - ShapeRenderer Laser=new ShapeRenderer(); - //Laser.begin(ShapeType.Line); + public void drawnotsoold(ShapeRenderer Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1+58; + float y1=yy1+20; + float x2=xx2+58; + float y2=yy2+20; Laser.begin(ShapeType.Filled); - //Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); if (active) { Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1)); @@ -77,14 +82,15 @@ public class Laser { Laser.rectLine(x1, y1 , x2, y2, 2); } Laser.end(); - Laser.dispose(); Gdx.gl.glDisable(GL20.GL_BLEND); } - public void drawold(float x1,float y1,float x2,float y2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { - ShapeRenderer Laser=new ShapeRenderer(); - //Laser.begin(ShapeType.Line); + public void drawold(ShapeRenderer Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1+20; + float y1=yy1+20; + float x2=xx2+20; + float y2=yy2+20; float adding=0; Laser.begin(ShapeType.Point); Vector2 vec2 = new Vector2(x2, y2).sub(new Vector2(x1, y1)); @@ -110,8 +116,6 @@ public class Laser { } } Laser.end(); - Laser.dispose(); - } } diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 0448150..4a8e9d5 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -1,47 +1,94 @@ package fr.evolving.screens; +import java.util.Timer; +import java.util.TimerTask; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Table; + import fr.evolving.worlds.GameRenderer; import fr.evolving.worlds.GameWorld; +import fr.evolving.worlds.LevelRenderer; +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Level; import fr.evolving.inputs.InputHandler; public class GameScreen implements Screen { - + private Timer ScrollTimer; + private TimerTask ScrollTask; + private Stage stage; + private Table table,table2; private GameWorld world; - private GameRenderer renderer; + private GameRenderer Renderer; private float runTime; - + public Level level; + private ImageButton[] bottom; + private ImageButton[] topleft; + String[] bottom_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"}; + + // This is the constructor, not the class declaration - public GameScreen() { + public GameScreen(Level level) { + Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)"); + stage = new Stage(AssetLoader.viewport); + table = new Table(); + table2 = new Table(); + this.level=level; + world = new GameWorld(level); + Renderer = new GameRenderer(this); + world.setRenderer(Renderer); + Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer."); + ScrollTimer=new Timer(); + ScrollTask = new TimerTask() + { + @Override + public void run() + { + Renderer.evolve(); + } + }; + ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); + Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du bas"); + bottom=new ImageButton[bottom_tocreate.length]; + int i=0; + for (String tocreateitem: bottom_tocreate) + bottom[i++]= new ImageButton(AssetLoader.Skin_level,tocreateitem); + topleft=new ImageButton[topleft_tocreate.length]; + i=0; + for (String tocreateitem: topleft_tocreate) + topleft[i++]= new ImageButton(AssetLoader.Skin_level,tocreateitem); - float screenWidth = Gdx.graphics.getWidth(); - float screenHeight = Gdx.graphics.getHeight(); - float gameWidth = 136; - float gameHeight = screenHeight / (screenWidth / gameWidth); - int midPointY = (int) (gameHeight / 2); - - world = new GameWorld(midPointY); - Gdx.input.setInputProcessor(new InputHandler(screenWidth / gameWidth, screenHeight / gameHeight)); - renderer = new GameRenderer(world, (int) gameHeight, midPointY); - world.setRenderer(renderer); } @Override public void render(float delta) { runTime += delta; world.update(delta); - renderer.render(delta, runTime); + Renderer.render(delta, runTime); + stage.draw(); } @Override public void resize(int width, int height) { + AssetLoader.viewport.update(width,height); } @Override public void show() { - Gdx.app.log("Affichage du GameScreen","ok"); - + Gdx.app.log("*****","Affichage du niveau."); + table.bottom().left().padBottom(10f); + for (int i=0;i0) @@ -131,7 +128,10 @@ public class LevelRenderer { } if (found!=-1) { - Laser.draw(batcher,LevelScreen.buttonLevels[i].level.X+20,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio+20,LevelScreen.buttonLevels[found].level.X+20,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio+20,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor()); + if (!LevelScreen.logosmall.isChecked()) + Laser.draw(batcher,LevelScreen.buttonLevels[i].level.X,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio,LevelScreen.buttonLevels[found].level.X,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor()); + else + Laser.drawnotsoold(shapeRenderer,LevelScreen.buttonLevels[i].level.X,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio,LevelScreen.buttonLevels[found].level.X,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor()); } } }