From 42f5238c3341437e9d55f14715033b03aad60fc8 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Mon, 29 Aug 2022 00:40:49 +0600 Subject: важное переименовывание папок MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/ilotterytea/maxoning/MaxonGame.java | 4 +- .../ilotterytea/maxoning/anim/AnimatedImage.java | 38 --- .../maxoning/screen/AssetLoadingScreen.java | 107 --------- .../ilotterytea/maxoning/screen/MenuScreen.java | 260 --------------------- .../ilotterytea/maxoning/screen/SplashScreen.java | 159 ------------- .../maxoning/screens/AssetLoadingScreen.java | 107 +++++++++ .../ilotterytea/maxoning/screens/MenuScreen.java | 260 +++++++++++++++++++++ .../ilotterytea/maxoning/screens/SplashScreen.java | 158 +++++++++++++ .../com/ilotterytea/maxoning/ui/AnimatedImage.java | 38 +++ 9 files changed, 564 insertions(+), 567 deletions(-) delete mode 100644 core/src/com/ilotterytea/maxoning/anim/AnimatedImage.java delete mode 100644 core/src/com/ilotterytea/maxoning/screen/AssetLoadingScreen.java delete mode 100644 core/src/com/ilotterytea/maxoning/screen/MenuScreen.java delete mode 100644 core/src/com/ilotterytea/maxoning/screen/SplashScreen.java create mode 100644 core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java create mode 100644 core/src/com/ilotterytea/maxoning/screens/MenuScreen.java create mode 100644 core/src/com/ilotterytea/maxoning/screens/SplashScreen.java create mode 100644 core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java (limited to 'core/src') diff --git a/core/src/com/ilotterytea/maxoning/MaxonGame.java b/core/src/com/ilotterytea/maxoning/MaxonGame.java index 9a24256..84bc6e6 100644 --- a/core/src/com/ilotterytea/maxoning/MaxonGame.java +++ b/core/src/com/ilotterytea/maxoning/MaxonGame.java @@ -1,11 +1,9 @@ package com.ilotterytea.maxoning; import com.badlogic.gdx.Game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.ilotterytea.maxoning.screen.AssetLoadingScreen; -import com.ilotterytea.maxoning.screen.SplashScreen; +import com.ilotterytea.maxoning.screens.AssetLoadingScreen; public class MaxonGame extends Game { public SpriteBatch batch; diff --git a/core/src/com/ilotterytea/maxoning/anim/AnimatedImage.java b/core/src/com/ilotterytea/maxoning/anim/AnimatedImage.java deleted file mode 100644 index 8da1c19..0000000 --- a/core/src/com/ilotterytea/maxoning/anim/AnimatedImage.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ilotterytea.maxoning.anim; - -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; - -public class AnimatedImage extends Image { - private float stateTime = 0; - private final TextureRegion[] regions; - private int index = 0; - - public AnimatedImage(TextureRegion[] regions) { - super(regions[0]); - this.regions = regions; - } - - @Override public void act(float delta) { - if (index > regions.length - 1) { - index = 0; - } - if (regions[index + 1] == null) { - index = 0; - } - super.setDrawable(new TextureRegionDrawable(regions[index])); - index++; - super.act(delta); - - } - - public void dispose() { - for (TextureRegion reg : regions) { - if (reg != null) { - reg.getTexture().dispose(); - } - } - } -} diff --git a/core/src/com/ilotterytea/maxoning/screen/AssetLoadingScreen.java b/core/src/com/ilotterytea/maxoning/screen/AssetLoadingScreen.java deleted file mode 100644 index 0db18e6..0000000 --- a/core/src/com/ilotterytea/maxoning/screen/AssetLoadingScreen.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.ilotterytea.maxoning.screen; - -import com.badlogic.gdx.*; -import com.badlogic.gdx.audio.Music; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.MathUtils; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.viewport.FillViewport; -import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.anim.AnimatedImage; -import com.ilotterytea.maxoning.anim.SpriteUtils; - -import java.util.Arrays; - -public class AssetLoadingScreen implements Screen { - final MaxonGame game; - - final Stage stage; - final Skin skin; - final AnimatedImage animatedMaxon; - final Label loadingLabel; - - final Texture M4x0nnes; - - public AssetLoadingScreen(MaxonGame game) { - this.game = game; - - this.M4x0nnes = new Texture("sprites/sheet/loadingCircle.png"); - - this.skin = new Skin(Gdx.files.internal("main.skin")); - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); - - this.loadingLabel = new Label("Loading...", skin); - - TextureRegion[] txrr = SpriteUtils.splitToTextureRegions(M4x0nnes, 112, 112, 10, 5); - this.animatedMaxon = new AnimatedImage(txrr); - - animatedMaxon.setPosition(8, 8); - animatedMaxon.setScale(0.25f); - - loadingLabel.setPosition(animatedMaxon.getWidth() * 0.25f + loadingLabel.getX() + 16, 8); - - stage.addActor(animatedMaxon); - stage.addActor(loadingLabel); - - queueAssets(); - } - - @Override public void show() { render(Gdx.graphics.getDeltaTime()); } - - private void update(float delta) { - if (game.assetManager.update()) { - Timer.schedule(new Timer.Task() { - @Override - public void run() { - game.setScreen(new SplashScreen(game)); - dispose(); - } - }, 1f); - } - } - - @Override - public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - loadingLabel.setText(String.format("%s%% (Loaded %s assets)", MathUtils.floor(game.assetManager.getProgress() * 100), game.assetManager.getLoadedAssets())); - - stage.draw(); - stage.act(delta); - - update(delta); - } - - @Override - public void resize(int width, int height) { - stage.getViewport().update(width, height, true); - } - @Override public void pause() {} - @Override public void resume() {} - @Override public void hide() { dispose(); } - @Override public void dispose() {} - private void queueAssets() { - // Textures: - game.assetManager.load("icon.png", Texture.class); - game.assetManager.load("dev.png", Texture.class); - game.assetManager.load("sprites/sheet/loadingCircle.png", Texture.class); - game.assetManager.load("sprites/black.png", Texture.class); - game.assetManager.load("sprites/white.png", Texture.class); - game.assetManager.load("sprites/brand.png", Texture.class); - game.assetManager.load("sprites/ilotterytea.png", Texture.class); - game.assetManager.load("sprites/SplashWall.png", Texture.class); - - // Music: - game.assetManager.load("mus/menu/mus_menu_intro.ogg", Music.class); - game.assetManager.load("mus/menu/mus_menu_loop.ogg", Music.class); - // Sounds: - } -} diff --git a/core/src/com/ilotterytea/maxoning/screen/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screen/MenuScreen.java deleted file mode 100644 index be8e1f4..0000000 --- a/core/src/com/ilotterytea/maxoning/screen/MenuScreen.java +++ /dev/null @@ -1,260 +0,0 @@ -package com.ilotterytea.maxoning.screen; - -import com.badlogic.gdx.*; -import com.badlogic.gdx.audio.Music; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.Sprite; -import com.badlogic.gdx.math.Interpolation; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.actions.Actions; -import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.utils.viewport.FillViewport; -import com.ilotterytea.maxoning.MaxonConstants; -import com.ilotterytea.maxoning.MaxonGame; - -import java.util.ArrayList; - -public class MenuScreen implements Screen, InputProcessor { - - final MaxonGame game; - - final Stage stage; - final Skin skin; - - final Image brandLogo, maxonLogo; - final Label startLabel, infoLabel; - - final Texture wall, brandTxr, maxonTxr; - - final Music menuMusic; - - private ArrayList> wallTiles = new ArrayList<>(); - - private boolean anyKeyPressed = false, brandActionsSet = false; - - public MenuScreen(MaxonGame game) { - this.game = game; - - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); - this.skin = new Skin(Gdx.files.internal("main.skin")); - - this.brandTxr = new Texture(Gdx.files.internal("sprites/brand.png")); - this.maxonTxr = new Texture(Gdx.files.internal("icon.png")); - this.wall = new Texture(Gdx.files.internal("sprites/SplashWall.png")); - - this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); - - for (int i = 0; i < (Gdx.graphics.getHeight() / wall.getHeight()) + 1; i++) { - wallTiles.add(new ArrayList()); - for (int j = 0; j < (Gdx.graphics.getWidth() / wall.getWidth()); j++) { - Sprite spr = new Sprite(wall); - spr.setPosition(wall.getWidth() * j, wall.getHeight() * i); - - wallTiles.get(i).add(spr); - } - } - - this.maxonLogo = new Image(maxonTxr); - this.brandLogo = new Image(brandTxr); - - this.startLabel = new Label("PRESS START", skin, "press"); - this.infoLabel = new Label(String.format("%s %s", MaxonConstants.GAME_NAME, MaxonConstants.GAME_VERSION), skin, "credits"); - - brandLogo.setScale(100f); - - brandLogo.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (brandLogo.getWidth() / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (brandLogo.getHeight() / 2.0f) - ); - - brandLogo.setOrigin( - brandLogo.getWidth() / 2.0f, - brandLogo.getHeight() / 2.0f - ); - - brandLogo.addAction( - Actions.sequence( - Actions.alpha(0), - Actions.parallel( - Actions.fadeIn(1f), - Actions.scaleTo(1f, 1f, 1f, Interpolation.pow2InInverse) - ), - Actions.repeat( - RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-10, 10f, Interpolation.sine), - Actions.scaleTo(0.85f, 0.85f, 10f, Interpolation.sine) - ), - Actions.parallel( - Actions.rotateTo(10, 10f, Interpolation.sine), - Actions.scaleTo(1.25f, 1.25f, 10f, Interpolation.sine) - ) - ) - )) - ); - - startLabel.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (startLabel.getWidth() / 2.0f), - 32 - ); - - startLabel.addAction( - Actions.repeat( - RepeatAction.FOREVER, - Actions.sequence( - Actions.alpha(0f), - Actions.fadeIn(1f), - Actions.delay(5f), - Actions.fadeOut(1f) - ) - ) - ); - - stage.addActor(infoLabel); - stage.addActor(brandLogo); - stage.addActor(startLabel); - - Gdx.input.setInputProcessor(new InputMultiplexer(this, stage)); - } - - @Override public void show() { - render(Gdx.graphics.getDeltaTime()); - menuMusic.setLooping(true); - menuMusic.play(); - } - - private final float wallVelocity = 1f; - - @Override - public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - // Draw the sprites: - /*for (ArrayList sprArray : wallTiles) { - for (Sprite tile : sprArray) { - tile.setPosition(tile.getX() + wallVelocity, tile.getY()); - tile.draw(game.batch); - } - }*/ - - /* - for (ArrayList sprArray : wallTiles) { - for (int i = 0; i < sprArray.size(); i++) { - Sprite spr = sprArray.get(i); - - if (spr.getX() + spr.getWidth() > Gdx.graphics.getWidth()) { - spr.setPosition(sprArray.get(0).getX() - spr.getWidth(), spr.getY()); - sprArray.remove(i); - sprArray.add(0, spr); - } - } - }*/ - - if (anyKeyPressed && !brandActionsSet) { - startLabel.clearActions(); - startLabel.addAction(Actions.fadeOut(0.5f)); - - brandLogo.clearActions(); - brandLogo.addAction( - Actions.sequence( - Actions.parallel( - Actions.rotateTo(0f, 2f), - Actions.scaleTo(1f, 1f, 2f), - Actions.moveTo( - (Gdx.graphics.getWidth() / 2f) - (brandTxr.getWidth() / 2f), - (Gdx.graphics.getHeight() - brandTxr.getHeight()) - 81, - 2f, - Interpolation.sine - ) - ), - Actions.repeat(RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-5f, 5f, Interpolation.smoother), - Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) - ), - Actions.parallel( - Actions.rotateTo(5f, 5f, Interpolation.smoother), - Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) - ) - ))) - ); - - brandActionsSet = true; - } - - stage.draw(); - stage.act(delta); - } - - @Override - public void resize(int width, int height) { - stage.getViewport().update(width, height, true); - } - - @Override public void pause() {} - @Override public void resume() {} - @Override public void hide() { dispose(); } - @Override - public void dispose() { - stage.dispose(); - skin.dispose(); - } - - @Override - public boolean keyDown(int keycode) { - if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - Gdx.app.exit(); - } - - if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { - anyKeyPressed = true; - } - - return false; - } - - @Override - public boolean keyUp(int keycode) { - return false; - } - - @Override - public boolean keyTyped(char character) { - return false; - } - - @Override - public boolean touchDown(int screenX, int screenY, int pointer, int button) { - if (Gdx.input.isTouched()) { - anyKeyPressed = true; - } - return false; - } - - @Override - public boolean touchUp(int screenX, int screenY, int pointer, int button) { - return false; - } - - @Override - public boolean touchDragged(int screenX, int screenY, int pointer) { - return false; - } - - @Override - public boolean mouseMoved(int screenX, int screenY) { - return false; - } - - @Override - public boolean scrolled(float amountX, float amountY) { - return false; - } -} diff --git a/core/src/com/ilotterytea/maxoning/screen/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screen/SplashScreen.java deleted file mode 100644 index ff3b1a3..0000000 --- a/core/src/com/ilotterytea/maxoning/screen/SplashScreen.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.ilotterytea.maxoning.screen; - -import com.badlogic.gdx.*; -import com.badlogic.gdx.audio.Music; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.actions.Actions; -import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.viewport.FillViewport; -import com.ilotterytea.maxoning.MaxonConstants; -import com.ilotterytea.maxoning.MaxonGame; - -public class SplashScreen implements InputProcessor, Screen { - - final MaxonGame game; - - final Stage stage; - final Skin skin; - - final Image whiteSquare, dev; - final Label infoLabel; - - final Music introMusic; - - public SplashScreen(MaxonGame game) { - this.game = game; - - this.introMusic = game.assetManager.get("mus/menu/mus_menu_intro.ogg", Music.class); - - - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); - this.skin = new Skin(Gdx.files.internal("main.skin")); - - this.infoLabel = new Label( - String.format("%s %s", MaxonConstants.GAME_NAME, MaxonConstants.GAME_VERSION), - skin, "credits" - ); - - this.dev = new Image(game.assetManager.get("sprites/ilotterytea.png", Texture.class)); - this.whiteSquare = new Image(game.assetManager.get("sprites/white.png", Texture.class)); - - infoLabel.setPosition( - 8, - (Gdx.graphics.getHeight() - infoLabel.getHeight()) - 8 - ); - - dev.setScale(5f); - - dev.setPosition( - (Gdx.graphics.getWidth() / 2.0f) - (dev.getWidth() * 5f / 2.0f), - (Gdx.graphics.getHeight() / 2.0f) - (dev.getHeight() * 5f / 2.0f) - ); - - whiteSquare.setPosition(0, 0); - whiteSquare.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - - dev.addAction(Actions.sequence( - Actions.alpha(0), - Actions.fadeIn(1f), - Actions.delay(5f), - Actions.fadeOut(0.25f) - )); - - whiteSquare.addAction(Actions.sequence( - Actions.alpha(0), - Actions.fadeIn(0.5f), - Actions.delay(25f), - Actions.fadeOut(0.5f) - )); - - stage.addActor(whiteSquare); - stage.addActor(infoLabel); - stage.addActor(dev); - - Gdx.input.setInputProcessor(new InputMultiplexer(this, stage)); - } - - @Override public void show() { - introMusic.play(); - render(Gdx.graphics.getDeltaTime()); - } - - private final float wallVelocity = 1f; - - @Override - public void render(float delta) { - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - stage.draw(); - stage.act(delta); - - if (!introMusic.isPlaying()) { - game.setScreen(new MenuScreen(game)); - } - } - - @Override - public void resize(int width, int height) { - stage.getViewport().update(width, height, true); - } - - @Override public void pause() {} - @Override public void resume() {} - @Override public void hide() { dispose(); } - @Override public void dispose() {} - - @Override - public boolean keyDown(int keycode) { - if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { - Gdx.app.exit(); - } - if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { - introMusic.stop(); - game.setScreen(new MenuScreen(game)); - dispose(); - } - return false; - } - - @Override - public boolean keyUp(int keycode) { - return false; - } - - @Override - public boolean keyTyped(char character) { - return false; - } - - @Override - public boolean touchDown(int screenX, int screenY, int pointer, int button) { - return false; - } - - @Override - public boolean touchUp(int screenX, int screenY, int pointer, int button) { - return false; - } - - @Override - public boolean touchDragged(int screenX, int screenY, int pointer) { - return false; - } - - @Override - public boolean mouseMoved(int screenX, int screenY) { - return false; - } - - @Override - public boolean scrolled(float amountX, float amountY) { - return false; - } -} diff --git a/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java b/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java new file mode 100644 index 0000000..e3d4c29 --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/screens/AssetLoadingScreen.java @@ -0,0 +1,107 @@ +package com.ilotterytea.maxoning.screens; + +import com.badlogic.gdx.*; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.utils.Timer; +import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonGame; +import com.ilotterytea.maxoning.ui.AnimatedImage; +import com.ilotterytea.maxoning.anim.SpriteUtils; + +import java.util.Arrays; + +public class AssetLoadingScreen implements Screen { + final MaxonGame game; + + final Stage stage; + final Skin skin; + final AnimatedImage animatedMaxon; + final Label loadingLabel; + + final Texture M4x0nnes; + + public AssetLoadingScreen(MaxonGame game) { + this.game = game; + + this.M4x0nnes = new Texture("sprites/sheet/loadingCircle.png"); + + this.skin = new Skin(Gdx.files.internal("main.skin")); + this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + + this.loadingLabel = new Label("Loading...", skin); + + TextureRegion[] txrr = SpriteUtils.splitToTextureRegions(M4x0nnes, 112, 112, 10, 5); + this.animatedMaxon = new AnimatedImage(txrr); + + animatedMaxon.setPosition(8, 8); + animatedMaxon.setScale(0.25f); + + loadingLabel.setPosition(animatedMaxon.getWidth() * 0.25f + loadingLabel.getX() + 16, 8); + + stage.addActor(animatedMaxon); + stage.addActor(loadingLabel); + + queueAssets(); + } + + @Override public void show() { render(Gdx.graphics.getDeltaTime()); } + + private void update(float delta) { + if (game.assetManager.update()) { + Timer.schedule(new Timer.Task() { + @Override + public void run() { + game.setScreen(new SplashScreen(game)); + dispose(); + } + }, 1f); + } + } + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + loadingLabel.setText(String.format("%s%% (Loaded %s assets)", MathUtils.floor(game.assetManager.getProgress() * 100), game.assetManager.getLoadedAssets())); + + stage.draw(); + stage.act(delta); + + update(delta); + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + @Override public void pause() {} + @Override public void resume() {} + @Override public void hide() { dispose(); } + @Override public void dispose() {} + private void queueAssets() { + // Textures: + game.assetManager.load("icon.png", Texture.class); + game.assetManager.load("dev.png", Texture.class); + game.assetManager.load("sprites/sheet/loadingCircle.png", Texture.class); + game.assetManager.load("sprites/black.png", Texture.class); + game.assetManager.load("sprites/white.png", Texture.class); + game.assetManager.load("sprites/brand.png", Texture.class); + game.assetManager.load("sprites/ilotterytea.png", Texture.class); + game.assetManager.load("sprites/SplashWall.png", Texture.class); + + // Music: + game.assetManager.load("mus/menu/mus_menu_intro.ogg", Music.class); + game.assetManager.load("mus/menu/mus_menu_loop.ogg", Music.class); + // Sounds: + } +} diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java new file mode 100644 index 0000000..88c8d5a --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -0,0 +1,260 @@ +package com.ilotterytea.maxoning.screens; + +import com.badlogic.gdx.*; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonConstants; +import com.ilotterytea.maxoning.MaxonGame; + +import java.util.ArrayList; + +public class MenuScreen implements Screen, InputProcessor { + + final MaxonGame game; + + final Stage stage; + final Skin skin; + + final Image brandLogo, maxonLogo; + final Label startLabel, infoLabel; + + final Texture wall, brandTxr, maxonTxr; + + final Music menuMusic; + + private ArrayList> wallTiles = new ArrayList<>(); + + private boolean anyKeyPressed = false, brandActionsSet = false; + + public MenuScreen(MaxonGame game) { + this.game = game; + + this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + this.skin = new Skin(Gdx.files.internal("main.skin")); + + this.brandTxr = new Texture(Gdx.files.internal("sprites/brand.png")); + this.maxonTxr = new Texture(Gdx.files.internal("icon.png")); + this.wall = new Texture(Gdx.files.internal("sprites/SplashWall.png")); + + this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); + + for (int i = 0; i < (Gdx.graphics.getHeight() / wall.getHeight()) + 1; i++) { + wallTiles.add(new ArrayList()); + for (int j = 0; j < (Gdx.graphics.getWidth() / wall.getWidth()); j++) { + Sprite spr = new Sprite(wall); + spr.setPosition(wall.getWidth() * j, wall.getHeight() * i); + + wallTiles.get(i).add(spr); + } + } + + this.maxonLogo = new Image(maxonTxr); + this.brandLogo = new Image(brandTxr); + + this.startLabel = new Label("PRESS START", skin, "press"); + this.infoLabel = new Label(String.format("%s %s", MaxonConstants.GAME_NAME, MaxonConstants.GAME_VERSION), skin, "credits"); + + brandLogo.setScale(100f); + + brandLogo.setPosition( + (Gdx.graphics.getWidth() / 2.0f) - (brandLogo.getWidth() / 2.0f), + (Gdx.graphics.getHeight() / 2.0f) - (brandLogo.getHeight() / 2.0f) + ); + + brandLogo.setOrigin( + brandLogo.getWidth() / 2.0f, + brandLogo.getHeight() / 2.0f + ); + + brandLogo.addAction( + Actions.sequence( + Actions.alpha(0), + Actions.parallel( + Actions.fadeIn(1f), + Actions.scaleTo(1f, 1f, 1f, Interpolation.pow2InInverse) + ), + Actions.repeat( + RepeatAction.FOREVER, + Actions.sequence( + Actions.parallel( + Actions.rotateTo(-10, 10f, Interpolation.sine), + Actions.scaleTo(0.85f, 0.85f, 10f, Interpolation.sine) + ), + Actions.parallel( + Actions.rotateTo(10, 10f, Interpolation.sine), + Actions.scaleTo(1.25f, 1.25f, 10f, Interpolation.sine) + ) + ) + )) + ); + + startLabel.setPosition( + (Gdx.graphics.getWidth() / 2.0f) - (startLabel.getWidth() / 2.0f), + 32 + ); + + startLabel.addAction( + Actions.repeat( + RepeatAction.FOREVER, + Actions.sequence( + Actions.alpha(0f), + Actions.fadeIn(1f), + Actions.delay(5f), + Actions.fadeOut(1f) + ) + ) + ); + + stage.addActor(infoLabel); + stage.addActor(brandLogo); + stage.addActor(startLabel); + + Gdx.input.setInputProcessor(new InputMultiplexer(this, stage)); + } + + @Override public void show() { + render(Gdx.graphics.getDeltaTime()); + menuMusic.setLooping(true); + menuMusic.play(); + } + + private final float wallVelocity = 1f; + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + // Draw the sprites: + /*for (ArrayList sprArray : wallTiles) { + for (Sprite tile : sprArray) { + tile.setPosition(tile.getX() + wallVelocity, tile.getY()); + tile.draw(game.batch); + } + }*/ + + /* + for (ArrayList sprArray : wallTiles) { + for (int i = 0; i < sprArray.size(); i++) { + Sprite spr = sprArray.get(i); + + if (spr.getX() + spr.getWidth() > Gdx.graphics.getWidth()) { + spr.setPosition(sprArray.get(0).getX() - spr.getWidth(), spr.getY()); + sprArray.remove(i); + sprArray.add(0, spr); + } + } + }*/ + + if (anyKeyPressed && !brandActionsSet) { + startLabel.clearActions(); + startLabel.addAction(Actions.fadeOut(0.5f)); + + brandLogo.clearActions(); + brandLogo.addAction( + Actions.sequence( + Actions.parallel( + Actions.rotateTo(0f, 2f), + Actions.scaleTo(1f, 1f, 2f), + Actions.moveTo( + (Gdx.graphics.getWidth() / 2f) - (brandTxr.getWidth() / 2f), + (Gdx.graphics.getHeight() - brandTxr.getHeight()) - 81, + 2f, + Interpolation.sine + ) + ), + Actions.repeat(RepeatAction.FOREVER, + Actions.sequence( + Actions.parallel( + Actions.rotateTo(-5f, 5f, Interpolation.smoother), + Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) + ), + Actions.parallel( + Actions.rotateTo(5f, 5f, Interpolation.smoother), + Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) + ) + ))) + ); + + brandActionsSet = true; + } + + stage.draw(); + stage.act(delta); + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + @Override public void pause() {} + @Override public void resume() {} + @Override public void hide() { dispose(); } + @Override + public void dispose() { + stage.dispose(); + skin.dispose(); + } + + @Override + public boolean keyDown(int keycode) { + if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { + Gdx.app.exit(); + } + + if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { + anyKeyPressed = true; + } + + return false; + } + + @Override + public boolean keyUp(int keycode) { + return false; + } + + @Override + public boolean keyTyped(char character) { + return false; + } + + @Override + public boolean touchDown(int screenX, int screenY, int pointer, int button) { + if (Gdx.input.isTouched()) { + anyKeyPressed = true; + } + return false; + } + + @Override + public boolean touchUp(int screenX, int screenY, int pointer, int button) { + return false; + } + + @Override + public boolean touchDragged(int screenX, int screenY, int pointer) { + return false; + } + + @Override + public boolean mouseMoved(int screenX, int screenY) { + return false; + } + + @Override + public boolean scrolled(float amountX, float amountY) { + return false; + } +} diff --git a/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java new file mode 100644 index 0000000..27951fb --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/screens/SplashScreen.java @@ -0,0 +1,158 @@ +package com.ilotterytea.maxoning.screens; + +import com.badlogic.gdx.*; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.utils.viewport.FillViewport; +import com.ilotterytea.maxoning.MaxonConstants; +import com.ilotterytea.maxoning.MaxonGame; + +public class SplashScreen implements InputProcessor, Screen { + + final MaxonGame game; + + final Stage stage; + final Skin skin; + + final Image whiteSquare, dev; + final Label infoLabel; + + final Music introMusic; + + public SplashScreen(MaxonGame game) { + this.game = game; + + this.introMusic = game.assetManager.get("mus/menu/mus_menu_intro.ogg", Music.class); + + + this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + this.skin = new Skin(Gdx.files.internal("main.skin")); + + this.infoLabel = new Label( + String.format("%s %s", MaxonConstants.GAME_NAME, MaxonConstants.GAME_VERSION), + skin, "credits" + ); + + this.dev = new Image(game.assetManager.get("sprites/ilotterytea.png", Texture.class)); + this.whiteSquare = new Image(game.assetManager.get("sprites/white.png", Texture.class)); + + infoLabel.setPosition( + 8, + (Gdx.graphics.getHeight() - infoLabel.getHeight()) - 8 + ); + + dev.setScale(5f); + + dev.setPosition( + (Gdx.graphics.getWidth() / 2.0f) - (dev.getWidth() * 5f / 2.0f), + (Gdx.graphics.getHeight() / 2.0f) - (dev.getHeight() * 5f / 2.0f) + ); + + whiteSquare.setPosition(0, 0); + whiteSquare.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + + dev.addAction(Actions.sequence( + Actions.alpha(0), + Actions.fadeIn(1f), + Actions.delay(5f), + Actions.fadeOut(0.25f) + )); + + whiteSquare.addAction(Actions.sequence( + Actions.alpha(0), + Actions.fadeIn(0.5f), + Actions.delay(25f), + Actions.fadeOut(0.5f) + )); + + stage.addActor(whiteSquare); + stage.addActor(infoLabel); + stage.addActor(dev); + + Gdx.input.setInputProcessor(new InputMultiplexer(this, stage)); + } + + @Override public void show() { + introMusic.play(); + render(Gdx.graphics.getDeltaTime()); + } + + private final float wallVelocity = 1f; + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + stage.draw(); + stage.act(delta); + + if (!introMusic.isPlaying()) { + game.setScreen(new MenuScreen(game)); + } + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + @Override public void pause() {} + @Override public void resume() {} + @Override public void hide() { dispose(); } + @Override public void dispose() {} + + @Override + public boolean keyDown(int keycode) { + if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) { + Gdx.app.exit(); + } + if (Gdx.input.isKeyPressed(Input.Keys.ANY_KEY)) { + introMusic.stop(); + game.setScreen(new MenuScreen(game)); + dispose(); + } + return false; + } + + @Override + public boolean keyUp(int keycode) { + return false; + } + + @Override + public boolean keyTyped(char character) { + return false; + } + + @Override + public boolean touchDown(int screenX, int screenY, int pointer, int button) { + return false; + } + + @Override + public boolean touchUp(int screenX, int screenY, int pointer, int button) { + return false; + } + + @Override + public boolean touchDragged(int screenX, int screenY, int pointer) { + return false; + } + + @Override + public boolean mouseMoved(int screenX, int screenY) { + return false; + } + + @Override + public boolean scrolled(float amountX, float amountY) { + return false; + } +} diff --git a/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java b/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java new file mode 100644 index 0000000..521059e --- /dev/null +++ b/core/src/com/ilotterytea/maxoning/ui/AnimatedImage.java @@ -0,0 +1,38 @@ +package com.ilotterytea.maxoning.ui; + +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; + +public class AnimatedImage extends Image { + private float stateTime = 0; + private final TextureRegion[] regions; + private int index = 0; + + public AnimatedImage(TextureRegion[] regions) { + super(regions[0]); + this.regions = regions; + } + + @Override public void act(float delta) { + if (index > regions.length - 1) { + index = 0; + } + if (regions[index + 1] == null) { + index = 0; + } + super.setDrawable(new TextureRegionDrawable(regions[index])); + index++; + super.act(delta); + + } + + public void dispose() { + for (TextureRegion reg : regions) { + if (reg != null) { + reg.getTexture().dispose(); + } + } + } +} -- cgit v1.2.3