Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mygdx.game;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- public class MyGdxGame extends ApplicationAdapter {
- SpriteBatch batch;
- Texture bottomLeft;
- Texture bottomRight;
- Texture topLeft;
- Texture topRight;
- Texture handle;
- Texture rightPadding, leftPadding, topPadding, bottomPadding;
- Texture centerPadding;
- @Override
- public void create () {
- batch = new SpriteBatch();
- bottomLeft = new Texture("bottomleft.png");
- bottomRight = new Texture("bottomright.png");
- topLeft = new Texture("topleft.png");
- topRight = new Texture("topright.png");
- handle = new Texture("handle.png");
- rightPadding = new Texture("rightpadding.png");
- leftPadding = new Texture("leftpadding.png");
- topPadding = new Texture("toppadding.png");
- bottomPadding = new Texture("bottompadding.png");
- centerPadding = new Texture("center.png");
- }
- public void drawCabinet(SpriteBatch batch, int width, int height) {
- int vertDistance = height - topRight.getHeight() - bottomRight.getHeight();
- int horizDistance = width - topRight.getWidth() - topLeft.getWidth();
- batch.draw(bottomLeft, 0, 0);
- batch.draw(topLeft,0,bottomLeft.getHeight() + vertDistance);
- batch.draw(bottomRight, bottomLeft.getWidth() + horizDistance, 0);
- batch.draw(topRight, bottomLeft.getWidth() + horizDistance, bottomRight.getHeight() + vertDistance);
- for (int spaces = vertDistance; spaces > 0; spaces--) {
- batch.draw(rightPadding, bottomLeft.getWidth() + horizDistance, bottomRight.getHeight() + spaces - 1);
- }
- for (int spaces = vertDistance; spaces > 0; spaces--) {
- batch.draw(leftPadding, 0, bottomLeft.getHeight() + spaces - 1);
- }
- for (int spaces = horizDistance; spaces > 0; spaces--) {
- batch.draw(bottomPadding, bottomLeft.getWidth() + spaces - 1, 0);
- }
- for (int spaces = horizDistance; spaces > 0; spaces--) {
- batch.draw(topPadding, topLeft.getWidth() + spaces - 1, bottomLeft.getHeight() + vertDistance + topLeft.getHeight() - topPadding.getHeight());
- }
- batch.draw(centerPadding, bottomLeft.getWidth(), bottomPadding.getHeight(), horizDistance, height - topPadding.getHeight() - bottomPadding.getHeight());
- batch.draw(handle, bottomLeft.getWidth() + horizDistance + bottomRight.getWidth() - handle.getWidth(), (bottomRight.getHeight() + vertDistance + topRight.getHeight()) / 2 - handle.getHeight() / 2);
- }
- @Override
- public void render () {
- Gdx.gl.glClearColor(1, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- batch.begin();
- drawCabinet(batch, 80, 100);
- batch.end();
- }
- @Override
- public void dispose () {
- batch.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement