Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package com.mygdx.game;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.graphics.Color;
  5. import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
  6. import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
  7.  
  8. public class Cube {
  9.     float d;
  10.     float f;
  11.     float widght;
  12.     float height;
  13.     float time_delta;
  14.     float time;
  15.     Color color;
  16.     ShapeRenderer shape;
  17.     boolean moving = true;
  18.     boolean is_destroyed = false;
  19.  
  20.     public void create() {
  21.         shape = new ShapeRenderer();
  22.         d = 50;
  23.         f = 50;
  24.         widght = 50;
  25.         height = 50;
  26.         time = 0;
  27.     }
  28.  
  29.     public void update() {
  30.         time_delta = Gdx.graphics.getDeltaTime();
  31.         time += time_delta;
  32.  
  33.         if (moving == true) {
  34.             d += 2;
  35.         }
  36.         if (time > 2) {
  37.             moving = false;
  38.         }
  39.     }
  40.  
  41.     public void render() {
  42.         update();
  43.         shape.begin(ShapeType.Filled);
  44.         shape.setColor(Color.CHARTREUSE);
  45.         shape.rect(d = 100, f = 10, widght, height);
  46.         shape.rect(d = 200, f = 10, widght, height);
  47.         shape.end();
  48.     }
  49.  
  50.     public void dispose() {
  51.         shape.dispose();
  52.     }
  53.  
  54.     public void setPos(float new_d, float new_f) {
  55.         d = new_d;
  56.         f = new_f;
  57.     }
  58.  
  59.     public void destroy() {
  60.         is_destroyed = true;
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement