Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.iMackshun.Games.Pixelformer.Screens;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.InputProcessor;
- import com.badlogic.gdx.Screen;
- import com.badlogic.gdx.Input.Keys;
- import com.badlogic.gdx.graphics.FPSLogger;
- import com.badlogic.gdx.graphics.GL10;
- import com.badlogic.gdx.graphics.g2d.Sprite;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g2d.TextureAtlas;
- import com.badlogic.gdx.graphics.g2d.TextureRegion;
- import com.iMackshun.Games.Pixelformer.PixelFormer;
- import com.iMackshun.Games.Pixelformer.Objects.FallingBackground;
- import com.iMackshun.Games.Pixelformer.Objects.ScrollingBackground;
- import com.iMackshun.Games.Pixelformer.Objects.Reticule;
- public class Menu implements Screen, InputProcessor{
- //Declarations
- PixelFormer game;
- boolean Story, Arcade, Options, Quit, Nothing;
- TextureRegion ScrollTexture, MenuBarTexture, MenuTextTexture, StoryButtonTexture, ArcadeButtonTexture, OptionsButtonTexture, QuitButtonTexture, ReticuleTexture, ChooseModeImageTexture, StoryImageTexture, ArcadeImageTexture, OptionsImageTexture, QuitImageTexture;
- TextureAtlas GUI = new TextureAtlas("packs/PixelFormerGUI.pack");
- Sprite Reticule, ScrollSprite1,ScrollSprite2, MenuBar, MenuText, StoryButton, ArcadeButton, OptionsButton, QuitButton,MenuImage;
- ScrollingBackground Scroll1,Scroll2;
- FallingBackground MenuTextFallbg;
- SpriteBatch batch;
- int centerx = 427;
- int centery = 240;
- private FPSLogger fpsLogger;
- int ReticuleX,ReticuleY;
- //Constructor
- public Menu(PixelFormer game){
- this.game = game;
- }
- @Override
- public void render(float delta) {
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
- fpsLogger.log();
- ReticuleX = centerx - 16;
- ReticuleY = centery - 16;
- CheckMenuImage();
- checkreticule();
- Scroll1.update();
- Scroll2.update();
- MenuTextFallbg.update();
- ScrollSprite1.setPosition(Scroll1.getBgX(), Scroll1.getBgY());
- ScrollSprite2.setPosition(Scroll2.getBgX(), Scroll2.getBgY());
- MenuText.setPosition(MenuTextFallbg.getBgX(), MenuTextFallbg.getBgY());
- StoryButton.setPosition(470, 315);
- ArcadeButton.setPosition(470, 240);
- OptionsButton.setPosition(470, 164);
- QuitButton.setPosition(470, 94);
- MenuImage.setPosition(22, 101);
- Reticule.setPosition(ReticuleX, ReticuleY);
- batch.begin();
- ScrollSprite1.draw(batch);
- ScrollSprite2.draw(batch);
- MenuBar.draw(batch);
- MenuText.draw(batch);
- StoryButton.draw(batch);
- ArcadeButton.draw(batch);
- OptionsButton.draw(batch);
- QuitButton.draw(batch);
- MenuImage.draw(batch);
- Reticule.draw(batch);
- batch.end();
- }
- private void CheckMenuImage() {
- if(Story){
- MenuImage.setRegion(StoryImageTexture);
- }
- if(Arcade){
- MenuImage.setRegion(ArcadeImageTexture);
- }
- if(Options){
- MenuImage.setRegion(OptionsImageTexture);
- }
- if(Quit){
- MenuImage.setRegion(QuitImageTexture);
- }
- if(Nothing){
- MenuImage.setRegion(ChooseModeImageTexture);
- }
- if(!Story && !Arcade && !Options && !Quit){
- MenuImage.setRegion(ChooseModeImageTexture);
- }
- }
- private void checkreticule() {
- if(centerx >= 470 && centerx < 834){
- if (centery <= 370 && centery >= 320){
- Gdx.app.log(PixelFormer.LOG, "StoryMode Detected");
- Story = true;
- }else{
- Story = false;
- }
- if (centery <= 300 && centery >= 242){
- Gdx.app.log(PixelFormer.LOG, "ArcadeMode Detected");
- Arcade = true;
- }else{
- Arcade = false;
- }
- if (centery <= 220 && centery >= 170){
- Gdx.app.log(PixelFormer.LOG, "OptionsMode Detected");
- Options = true;
- }else{
- Options = false;
- }
- if (centery <= 150 && centery >= 92){
- Gdx.app.log(PixelFormer.LOG, "Quit Detected");
- Quit = true;
- }else{
- Quit = false;
- }
- if(centerx <= 470){
- Nothing = true;
- Story = false;
- Arcade = false;
- Options = false;
- Quit = false;
- }
- }
- }
- @Override
- public void resize(int width, int height) {
- Gdx.app.log(PixelFormer.LOG, "Menu. Awesome!!!!!");
- Gdx.input.setInputProcessor(this);
- }
- @Override
- public void show() {
- Scroll1 = new ScrollingBackground(0, 0, 854, 480, 0, -5, "Down");
- Scroll2 = new ScrollingBackground(0, 480, 854, 480, 0, -5, "Down");
- MenuTextFallbg = new FallingBackground(0, 100, 0, 4, 0, 0);
- ScrollTexture = new TextureRegion(GUI.findRegion("TitleScroll"));
- MenuBarTexture = new TextureRegion(GUI.findRegion("MenuBar"));
- MenuTextTexture = new TextureRegion(GUI.findRegion("MenuText"));
- StoryButtonTexture = new TextureRegion(GUI.findRegion("StoryButton"));
- ArcadeButtonTexture = new TextureRegion(GUI.findRegion("ArcadeButton"));
- OptionsButtonTexture = new TextureRegion(GUI.findRegion("OptionsButton"));
- QuitButtonTexture = new TextureRegion(GUI.findRegion("QuitButton"));
- ReticuleTexture = new TextureRegion(GUI.findRegion("Reticule"));
- ChooseModeImageTexture = new TextureRegion(GUI.findRegion("MenuImageChoose"));
- StoryImageTexture = new TextureRegion(GUI.findRegion("MenuImageStory"));
- ArcadeImageTexture = new TextureRegion(GUI.findRegion("MenuImageArcade"));
- OptionsImageTexture = new TextureRegion(GUI.findRegion("MenuImageOptions"));
- QuitImageTexture = new TextureRegion(GUI.findRegion("MenuImageQuit"));
- ScrollSprite1 = new Sprite(ScrollTexture);
- ScrollSprite2 = new Sprite(ScrollTexture);
- Reticule = new Sprite(ReticuleTexture);
- MenuBar = new Sprite(MenuBarTexture);
- MenuText = new Sprite(MenuTextTexture);
- StoryButton = new Sprite(StoryButtonTexture);
- ArcadeButton = new Sprite(ArcadeButtonTexture);
- OptionsButton = new Sprite(OptionsButtonTexture);
- QuitButton = new Sprite(QuitButtonTexture);
- MenuImage = new Sprite(ChooseModeImageTexture);
- fpsLogger = new FPSLogger();
- batch = new SpriteBatch();
- }
- @Override
- public void hide() {
- // TODO Auto-generated method stub
- }
- @Override
- public void pause() {
- // TODO Auto-generated method stub
- }
- @Override
- public void resume() {
- // TODO Auto-generated method stub
- }
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
- }
- @Override
- public boolean keyDown(int keycode) {
- if(keycode == Keys.DPAD_UP){
- centery += 10;
- }
- if(keycode == Keys.DPAD_DOWN){
- centery -= 10;
- }
- if(keycode == Keys.DPAD_LEFT){
- centerx -= 10;
- }
- if(keycode == Keys.DPAD_RIGHT){
- centerx += 10;
- }
- if(keycode == Keys.DPAD_CENTER && Story){
- game.setScreen(new World1Story(game));
- }
- return false;
- }
- @Override
- public boolean keyUp(int keycode) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean keyTyped(char character) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean touchDown(int screenX, int screenY, int pointer, int button) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean touchUp(int screenX, int screenY, int pointer, int button) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean touchDragged(int screenX, int screenY, int pointer) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean mouseMoved(int screenX, int screenY) {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- public boolean scrolled(int amount) {
- // TODO Auto-generated method stub
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment