Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import com.badlogic.gdx.ApplicationListener;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Input;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.BitmapFont;
- import com.badlogic.gdx.graphics.g2d.Sprite;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- public class AAA_AVOIDOBJECTGAME implements ApplicationListener {
- int SCORE = 0;
- long TIME;
- SpriteBatch batch;
- Sprite Background;
- Sprite GO;
- Sprite MS;
- Sprite TF1;
- Sprite TF2;
- Sprite TF3;
- Sprite TF4;
- Sprite PS;
- Sprite S;
- Sprite OBJ;
- BitmapFont font;
- @Override
- public void create() {
- batch = new SpriteBatch();
- Background = new Sprite(new Texture("ASSETS/TOB.jpg"));
- GO = new Sprite(new Texture("ASSETS/GO.jpg"));
- GO.setPosition(2000,2000);
- font = new BitmapFont();
- MS = new Sprite(new Texture("ASSETS/MS.png"));
- MS.setPosition(50, 50);
- TF1 = new Sprite(new Texture("ASSETS/TF.png"));
- TF1.setPosition(376,900);
- TF2 = new Sprite(new Texture("ASSETS/TF.png"));
- TF2.setPosition(702,900);
- TF3 = new Sprite(new Texture("ASSETS/TF.png"));
- TF3.setPosition(1028,900);
- TF4 = new Sprite(new Texture("ASSETS/TF.png"));
- TF4.setPosition(1354,900);
- PS = new Sprite(new Texture("ASSETS/PS.png"));
- PS.setPosition(1670, 50);
- S = new Sprite(new Texture("ASSETS/SCOREBOARD.png"));
- S.setPosition(50, 900);
- TIME = System.currentTimeMillis();
- OBJ = new Sprite(new Texture("ASSETS/OBJ.png"));
- OBJ.setPosition(50,785);
- }
- @Override
- public void render() {
- Gdx.gl.glClearColor(0,0,0,1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
- MS.translateX(-5);
- }
- if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
- MS.translateX(5);
- }
- if(MS.getX() > 1870 - MS.getWidth()) {
- MS.setX(1870 - MS.getWidth());
- }
- if(MS.getX() < -50 + MS.getWidth()) {
- MS.setX(-50 + MS.getWidth());
- }
- TF1.translateY(-7);
- if(TF1.getY() < -125) {
- TF1.setY(1080);
- }
- TF2.translateY(-5);
- if(TF2.getY() < -125) {
- TF2.setY(1080);
- }
- TF3.translateY(-10);
- if(TF3.getY() < -125) {
- TF3.setY(1080);
- }
- TF4.translateY(-8);
- if(TF4.getY() < -125) {
- TF4.setY(1080);
- }
- if(MS.getBoundingRectangle().overlaps(TF1.getBoundingRectangle())) {
- MS.setPosition(50, 50);
- }
- if(MS.getBoundingRectangle().overlaps(TF2.getBoundingRectangle())) {
- MS.setPosition(50, 50);
- }
- if(MS.getBoundingRectangle().overlaps(TF3.getBoundingRectangle())) {
- MS.setPosition(50, 50);
- }
- if(MS.getBoundingRectangle().overlaps(TF4.getBoundingRectangle())) {
- MS.setPosition(50, 50);
- }
- if(MS.getBoundingRectangle().overlaps(PS.getBoundingRectangle())) {
- MS.setPosition(50, 50);
- SCORE++;
- }
- if(((System.currentTimeMillis() - TIME)/1000)>30){
- MS.setPosition(50, 2000);
- TF1.translateY(7);
- TF1.setY(2000);
- TF2.translateY(5);
- TF2.setY(2000);
- TF3.translateY(10);
- TF3.setY(2000);
- TF4.translateY(8);
- TF4.setY(2000);
- S.setY(2000);
- OBJ.setY(2000);
- PS.setY(2000);
- GO.setPosition(0,0);
- }
- batch.begin();
- Background.draw(batch);
- MS.draw(batch);
- TF1.draw(batch);
- TF2.draw(batch);
- TF3.draw(batch);
- TF4.draw(batch);
- PS.draw(batch);
- S.draw(batch);
- font.draw(batch, " " + (System.currentTimeMillis() - TIME)/1000, 247, 978);
- OBJ.draw(batch);
- GO.draw(batch);
- font.draw(batch, SCORE + " ", 250, 935);
- batch.end();
- }
- @Override
- public void resize(int i, int i1) {
- } @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- @Override
- public void dispose() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement