mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-01-31 05:02:45 +00:00
Merge pull request #4 from Klagarge/TileScreen-and-BattleScreen
add BattleScreen and MapScreen
This commit is contained in:
commit
7c108fbff0
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -3,5 +3,6 @@
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
],
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
}
|
||||
|
BIN
resources/font/OptimusPrinceps.ttf
Normal file
BIN
resources/font/OptimusPrinceps.ttf
Normal file
Binary file not shown.
BIN
resources/font/RobotoSlab-Regular.ttf
Normal file
BIN
resources/font/RobotoSlab-Regular.ttf
Normal file
Binary file not shown.
BIN
resources/font/Starjedi.ttf
Normal file
BIN
resources/font/Starjedi.ttf
Normal file
Binary file not shown.
BIN
resources/font/Timeless.ttf
Normal file
BIN
resources/font/Timeless.ttf
Normal file
Binary file not shown.
BIN
resources/font/ice_pixel-7.ttf
Normal file
BIN
resources/font/ice_pixel-7.ttf
Normal file
Binary file not shown.
@ -1,26 +1,44 @@
|
||||
import Screen.ScreenPlayer;
|
||||
import ch.hevs.gdx2d.desktop.PortableApplication;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
|
||||
public class PokeMudry extends PortableApplication{
|
||||
public class PokeMudry extends PortableApplication {
|
||||
public final boolean ANDROID = false;
|
||||
public final int PLAYERS = 1;
|
||||
public static final int TIME = 10; // number of minutes for kill all enemy
|
||||
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
private ScreenPlayer screenPlayer = new ScreenPlayer();
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new PokeMudry();
|
||||
}
|
||||
*/
|
||||
|
||||
PokeMudry(){
|
||||
super(1000, 800);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
screenPlayer.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
// TODO Auto-generated method stub
|
||||
screenPlayer.render(g);
|
||||
}
|
||||
|
||||
|
||||
//key gestion
|
||||
@Override
|
||||
public void onKeyDown(int keycode) {
|
||||
screenPlayer.screenManager.getActiveScreen().onKeyDown(keycode);
|
||||
super.onKeyDown(keycode);
|
||||
}
|
||||
@Override
|
||||
public void onKeyUp(int keycode) {
|
||||
screenPlayer.screenManager.getActiveScreen().onKeyUp(keycode);
|
||||
super.onKeyUp(keycode);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,51 @@
|
||||
package Screen;
|
||||
|
||||
public class ScreenBattle {
|
||||
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||
|
||||
public class ScreenBattle extends RenderingScreen{
|
||||
|
||||
private BitmapFont optimus40;
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
|
||||
//display the question
|
||||
generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 100, Color.WHITE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
g.clear(Color.GREEN);
|
||||
g.drawStringCentered(g.getScreenHeight()/2, "question", optimus40);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
optimus40.dispose();
|
||||
|
||||
}
|
||||
|
||||
public void generateFont(String file, BitmapFont bitmapFont, int height, Color c ){
|
||||
FileHandle fileHandle = Gdx.files.internal(file);
|
||||
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
|
||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle);
|
||||
parameter.size = generator.scaleForPixelHeight(height);
|
||||
parameter.color = c;
|
||||
optimus40 = generator.generateFont(parameter);
|
||||
generator.dispose();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,9 +17,10 @@ import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import Entity.Player;
|
||||
import ch.hevs.gdx2d.components.screen_management.RenderingScreen;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
|
||||
public class ScreenMap {
|
||||
public class ScreenMap extends RenderingScreen{
|
||||
|
||||
// tiles management
|
||||
private Vector<TiledMapTileLayer> tiledLayer = new Vector<>();
|
||||
@ -40,7 +41,8 @@ public class ScreenMap {
|
||||
tMapRenderer.put(name,new OrthogonalTiledMapRenderer(tm));
|
||||
}
|
||||
|
||||
public void init() {
|
||||
@Override
|
||||
public void onInit() {
|
||||
// Set initial zoom
|
||||
zoom = 1;
|
||||
|
||||
@ -50,7 +52,8 @@ public class ScreenMap {
|
||||
createMap("desert");
|
||||
}
|
||||
|
||||
public void graphicRender(GdxGraphics g, Player p) {
|
||||
@Override
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
|
||||
tiledLayer.clear();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
@ -68,7 +71,7 @@ public class ScreenMap {
|
||||
|
||||
// Camera follows the hero
|
||||
g.zoom(zoom);
|
||||
g.moveCamera(p.getPosition().x, p.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
//g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
|
||||
// Render the tileMap
|
||||
tMapRenderer.get(map).setView(g.getCamera());
|
||||
@ -77,6 +80,7 @@ public class ScreenMap {
|
||||
g.drawFPS();
|
||||
}
|
||||
|
||||
|
||||
public Vector<TiledMapTile> getTile(Vector2 position, int offsetX, int offsetY) {
|
||||
Vector<TiledMapTile> tiles = new Vector<>();
|
||||
for (TiledMapTileLayer tl : tiledLayer) {
|
||||
|
@ -1,17 +1,26 @@
|
||||
package Screen;
|
||||
|
||||
import Entity.Player;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
import ch.hevs.gdx2d.lib.ScreenManager;
|
||||
|
||||
public class ScreenPlayer {
|
||||
private ScreenManager screenManager;
|
||||
private ScreenMap screenMap;
|
||||
private ScreenBattle screenBattle;
|
||||
public ScreenManager screenManager = new ScreenManager();
|
||||
|
||||
private Player player;
|
||||
|
||||
public void init(){
|
||||
|
||||
player = new Player(8, 15);
|
||||
|
||||
|
||||
screenManager.registerScreen(ScreenMap.class);
|
||||
screenManager.registerScreen(ScreenBattle.class);
|
||||
|
||||
}
|
||||
|
||||
public void render(){
|
||||
public void render(GdxGraphics g){
|
||||
screenManager.render(g);
|
||||
|
||||
}
|
||||
}
|
||||
|
47
src/testYann.java
Normal file
47
src/testYann.java
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
import Screen.ScreenBattle;
|
||||
import ch.hevs.gdx2d.desktop.PortableApplication;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
import ch.hevs.gdx2d.lib.ScreenManager;
|
||||
|
||||
public class testYann extends PortableApplication{
|
||||
|
||||
private ScreenManager s = new ScreenManager();
|
||||
|
||||
ScreenBattle b;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new testYann();
|
||||
|
||||
}
|
||||
|
||||
testYann(){
|
||||
super(1000, 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit() {
|
||||
b = new ScreenBattle();
|
||||
s.registerScreen(b.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGraphicRender(GdxGraphics g) {
|
||||
s.render(g);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onKeyDown(int keycode) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onKeyDown(keycode);
|
||||
}
|
||||
@Override
|
||||
public void onKeyUp(int keycode) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onKeyUp(keycode);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user