Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. package is.ru.tgra;
  2.  
  3. import java.awt.geom.Point2D;
  4. import java.nio.FloatBuffer;
  5. import java.util.Vector;
  6.  
  7. import com.badlogic.gdx.ApplicationListener;
  8. import com.badlogic.gdx.Gdx;
  9. import com.badlogic.gdx.graphics.GL11;
  10. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  11. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  12. import com.badlogic.gdx.Input;
  13. import com.badlogic.gdx.utils.BufferUtils;
  14. import java.nio.FloatBuffer;
  15. import java.util.ArrayList;
  16. import java.util.Random;
  17. import java.util.Vector;
  18. import java.math.*;
  19.  
  20. public class Skil1 implements ApplicationListener {
  21.     //Board:
  22.     ObjectReference boxxy; //IS BOXXY YOU SEEEEE!
  23.     float boxxy_x = 320;
  24.     float boxxy_y = 30;
  25.     float boxxy_height = 30;
  26.     float boxxy_length = 200;
  27.    
  28.     //Bricks:
  29.     ObjectReference brick; //IS BRICKS YOU SEEEE!
  30.     float brick_x = 40;
  31.     float brick_y = 450;
  32.     float brick_length = 50;
  33.     float brick_height = 30;
  34.     ArrayList<float[]> brickLocation = new ArrayList<float[]>();
  35.    
  36.     int delayCounter = 0;
  37.     int bounceCounter = 0;
  38.    
  39.     //Ball:
  40.     ObjectReference ball;
  41.     float ball_radius = 10;
  42.     float ball_x = 320;
  43.     float ball_y = 100;
  44.     float ball_speed = 250;
  45.     boolean ball_up = false;
  46.     boolean ball_right =true;
  47.        
  48.     //World:
  49.     float world_left;
  50.     float world_right;
  51.     float world_bottom;
  52.     float world_top;
  53.    
  54.     //Collision variables
  55.     double  NW_corner = 0;
  56.     double  NE_corner = 0;
  57.     double  SW_corner = 0;
  58.     double SE_corner = 0;
  59.     boolean noDelay = true;
  60.     boolean canBounce = true;
  61.    
  62.     //is the game running?
  63.     boolean running = false;
  64.     boolean gameOver = false;
  65.     //Colours
  66.     float[] brickColours = new float[3];
  67.     float[] ballColours = new float[3];
  68.     private Random random = new Random();
  69.    
  70.     //lives
  71.     int lives = 4;
  72.    
  73.     //text
  74.     private SpriteBatch spriteBatch;
  75.     private BitmapFont font;
  76.    
  77.     //buffer
  78.     FloatBuffer vertexBuffer;
  79.     public Skil1() {
  80.         // TODO Auto-generated constructor stub
  81.     }
  82.  
  83.     @Override
  84.     public void create() {
  85.         spriteBatch = new SpriteBatch();
  86.         font = new BitmapFont();
  87.        
  88.         Gdx.gl11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
  89.         Gdx.graphics.getDeltaTime();
  90.        
  91.         Vector<Point2D> vertexList = new Vector<Point2D>();
  92.         boxxy = createBox(boxxy_length, 20, vertexList);
  93.         brick = createBox(50,30,vertexList);
  94.         ball = createCircle(ball_radius, 39, vertexList);
  95.         int floatBufferSize = vertexList.size() * 2;
  96.         vertexBuffer = BufferUtils.newFloatBuffer(floatBufferSize);
  97.         float[] array = new float[floatBufferSize];
  98.         for(int i = 0; i < vertexList.size(); i++)
  99.         {
  100.             array[i*2] = vertexList.get(i).x;
  101.             array[i*2+1] = vertexList.get(i).y;
  102.         }
  103.         vertexBuffer.put(array);
  104.         vertexBuffer.rewind();
  105.         Gdx.gl11.glVertexPointer(2, GL11.GL_FLOAT, 0, vertexBuffer);
  106.         brickLocations();
  107.         for (int i = 0; i < 3; i++)
  108.         {
  109.             brickColours[i] = 1.0f;
  110.             ballColours[i] = 1.0f;
  111.         }
  112.        
  113.        
  114.        
  115.        
  116.        
  117.     }
  118.  
  119.     @Override
  120.     public void dispose() {
  121.         // TODO Auto-generated method stub
  122.        
  123.     }
  124.  
  125.     @Override
  126.     public void pause() {
  127.         // TODO Auto-generated method stub
  128.        
  129.     }
  130.  
  131.     @Override
  132.     public void render() {
  133.         display();
  134.         update();
  135.        
  136.     }
  137.    
  138.     private void ballTravel()
  139.     {
  140.         if (!gameOver)
  141.         {
  142.             float deltaTime = Gdx.graphics.getDeltaTime();
  143.             if(ball_right == true){
  144.                 ball_x += ball_speed*deltaTime;
  145.                 if(ball_x > Gdx.graphics.getWidth()-ball_radius)
  146.                     ball_right = false;
  147.             }
  148.             if(ball_right ==false){
  149.                 ball_x -= ball_speed*deltaTime;
  150.                 if(ball_x < ball_radius)
  151.                     ball_right = true;
  152.             }
  153.             if(ball_up == true){
  154.                 ball_y += ball_speed*deltaTime;
  155.                 if(ball_y > Gdx.graphics.getHeight()-ball_radius)
  156.                     ball_up = false;
  157.             }
  158.             if(ball_up == false){
  159.                 ball_y -= ball_speed*deltaTime;
  160.                 if(ball_y < ball_radius && lives == 1)
  161.                 {
  162.                     gameOver = true;
  163.                     running = false;
  164.                     System.out.println("Game Over");   
  165.                    
  166.                 }
  167.                 else if(ball_y < ball_radius)
  168.                 {
  169.                     lives -= 1;
  170.                     restartGame();
  171.                 }                      
  172.             }
  173.             ball_speed += 0.05;
  174.         }
  175.     }
  176.    
  177.     private void restartGame()
  178.     {
  179.        
  180.         boxxy_x = 320;
  181.         boxxy_y = 30;
  182.        
  183.         //Bricks:
  184.         brick_x = 40;
  185.         brick_y = 450;
  186.        
  187.         //Ball:
  188.         ball_x = 320;
  189.         ball_y = 100;
  190.         ball_speed = 250;
  191.         ball_up = false;
  192.         ball_right =true;
  193.        
  194.         running = false;
  195.        
  196.     }
  197.    
  198.     private void startOver()
  199.     {
  200.         boxxy_x = 320;
  201.         boxxy_y = 30;
  202.        
  203.         //Bricks:
  204.         brick_x = 40;
  205.         brick_y = 450;
  206.        
  207.         //Ball:
  208.         ball_x = 320;
  209.         ball_y = 100;
  210.         ball_speed = 250;
  211.         ball_up = false;
  212.         ball_right =true;
  213.         lives = 4;
  214.        
  215.         running = false;
  216.         gameOver = false;
  217.         brickLocation.clear();
  218.        
  219.         brickLocations();
  220.     }
  221.    
  222.     private void ballCollision()
  223.     {
  224.         //The delay checker. We want to have a slight delay between bouncing off bricks, we can't bump off bricks unless noDelay == true
  225.         if (!noDelay)
  226.         {
  227.             delayCounter++;
  228.             if (delayCounter == 2)
  229.             {
  230.                 delayCounter = 0;
  231.                 noDelay = true;
  232.             }
  233.         }
  234.         //The delay checker for the board. We need a slight delay after the ball hits the board since otherwise the ball freaks out
  235.         //after hitting a corner of the board if we're moving the board towards the ball
  236.         if (!canBounce)
  237.         {
  238.             bounceCounter++;
  239.             if (bounceCounter == 50)
  240.             {
  241.                 bounceCounter = 0;
  242.                 canBounce = true;
  243.             }
  244.         }
  245.        
  246.         //Board collision
  247.         //The formula for calculating whether or not we've hit one of the upper corners of the board
  248.         NW_corner = Math.sqrt(
  249.                 ((ball_x - (boxxy_x - boxxy_length/2)) * (ball_x - (boxxy_x - boxxy_length/2)))
  250.                 + ((ball_y - (boxxy_y + boxxy_height/2)) * (ball_y - (boxxy_y + boxxy_height/2)))
  251.                 );
  252.         NE_corner = Math.sqrt(
  253.                 ((ball_x - (boxxy_x + boxxy_length/2)) * (ball_x - (boxxy_x + boxxy_length/2)))
  254.         + ((ball_y - (boxxy_y + boxxy_height/2)) * (ball_y - (boxxy_y + boxxy_height/2)))
  255.         );
  256.        
  257.         if ((NW_corner <= ball_radius/2
  258.             || NE_corner <= ball_radius/2)
  259.             && canBounce)
  260.             {
  261.                     //If we hit a corner of the board
  262.                     ball_right = !ball_right;
  263.                     ball_up = !ball_up;
  264.                     canBounce = false;
  265.             }
  266.         else if (ball_x + ball_radius >= boxxy_x - boxxy_length/2 && ball_x + ball_radius < boxxy_x + boxxy_length/2)
  267.         {
  268.             if (ball_x < boxxy_x - boxxy_length/2 && ball_x > boxxy_x + boxxy_length/2)
  269.             {
  270.                  if (((ball_y + ball_radius <= boxxy_y + boxxy_height/2 && ball_y + ball_radius >= boxxy_y - boxxy_height/2)
  271.                  || (ball_y - ball_radius >= boxxy_y - boxxy_height/2 && ball_y - ball_radius <= boxxy_y + boxxy_height/2))
  272.                  && canBounce)
  273.                 {
  274.                     //Ball has hit the left side of the board
  275.                     ball_right = !ball_right;
  276.                     canBounce = false;
  277.                 }
  278.             }
  279.             else if (ball_y - ball_radius <= boxxy_y + boxxy_height/2 && ball_y - ball_radius >= boxxy_y- boxxy_height/2 && canBounce)
  280.             {
  281.                 //Bottom of ball has hit the top side of the board, coming from the left
  282.                 ball_up = !ball_up;
  283.                 canBounce = false;
  284.             }
  285.         }
  286.         else if (ball_x - ball_radius > boxxy_x - boxxy_length/2 && ball_x - ball_radius <= boxxy_x + boxxy_length/2)
  287.         {
  288.             if (ball_x < boxxy_x - boxxy_length/2 && ball_x > boxxy_x + boxxy_length/2)
  289.             {
  290.                 if (((ball_y + ball_radius <= boxxy_y + boxxy_height/2 && ball_y + ball_radius >= boxxy_y - boxxy_height/2)
  291.                  || (ball_y - ball_radius >= boxxy_y - boxxy_height/2 && ball_y - ball_radius <= boxxy_y + boxxy_height/2))
  292.                  && canBounce )
  293.                 {
  294.                     //Ball has hit the right side of the board
  295.                     ball_right = !ball_right;
  296.                     canBounce = false;
  297.                 }
  298.             }
  299.             else if (ball_y - ball_radius <= boxxy_y + boxxy_height/2 && ball_y - ball_radius >= boxxy_y - boxxy_height/2 && canBounce)
  300.             {
  301.                 //Bottom of ball has hit the top side of the board, coming from the right
  302.                 ball_up = !ball_up;
  303.                 canBounce = false;
  304.             }
  305.         }
  306.  
  307.         //Brick collision
  308.         for(float[] locations : brickLocation){ //For all bricks
  309.             if(locations[2] ==1) //That have not been destroyed yet
  310.             {   //Same formula as above, calculate all corners of the brick in question
  311.                 NW_corner = Math.sqrt((ball_x - (locations[0] - brick_length/2)) * (ball_x - (locations[0] - brick_length/2))
  312.                                 + (ball_y - (locations[1] + brick_height/2)) * (ball_y - (locations[1] + brick_height/2)));
  313.                 NE_corner = Math.sqrt((ball_x - (locations[0] + brick_length/2)) * (ball_x - (locations[0] + brick_length/2))
  314.                         + (ball_y - (locations[1] + brick_height/2)) * (ball_y - (locations[1] + brick_height/2)));
  315.                 SW_corner = Math.sqrt((ball_x - (locations[0] - brick_length/2)) * (ball_x - (locations[0] - brick_length/2))
  316.                         + (ball_y - (locations[1] - brick_height/2)) * (ball_y - (locations[1] - brick_height/2)));
  317.                 SE_corner = Math.sqrt((ball_x - (locations[0] + brick_length/2)) * (ball_x - (locations[0] + brick_length/2))
  318.                         + (ball_y - (locations[1] - brick_height/2)) * ((ball_y - locations[1] - brick_height/2)));
  319.                
  320.                 if ((NW_corner <= ball_radius/2
  321.                 || NE_corner <= ball_radius/2
  322.                 || SW_corner <= ball_radius/2
  323.                 || SE_corner <= ball_radius/2)
  324.                 && noDelay )
  325.                 {
  326.                     if(locations[3] > 1)
  327.                         locations[3] -= 1;
  328.                     else
  329.                         locations[2] = 0;
  330.                     //If we hit a corner
  331.                     ball_right = !ball_right;
  332.                     ball_up = !ball_up;
  333.                     ball_speed += 1;
  334.                     noDelay = false;
  335.                     changeColour();
  336.                 }//If right side of ball is within the brick's x-coordinates
  337.                 else if (ball_x + ball_radius >= locations[0] - brick_length/2 && ball_x + ball_radius < locations[0] + brick_length/2)
  338.                 {   //If the center of the ball is not within the brick
  339.                     if (ball_x < locations[0] - brick_length/2 || ball_x > locations[0] + brick_length/2)
  340.                     {    //If either the top or the bot of the ball is within the y-cords of the brick
  341.                          if ((ball_y + ball_radius <= locations[1] + brick_height/2 && ball_y + ball_radius >= locations[1] - brick_height/2)
  342.                          || (ball_y - ball_radius >= locations[1] - brick_height/2 && ball_y - ball_radius <= locations[1] + brick_height/2)
  343.                          && noDelay)
  344.                         {
  345.                             //Ball has hit the left side of the box
  346.                             ball_right = !ball_right;
  347.                             if(locations[3] > 1)
  348.                                 locations[3] -= 1;
  349.                             else
  350.                                 locations[2] = 0;
  351.                             ball_speed += 1;
  352.                             noDelay = false;
  353.                             changeColour();
  354.                         }
  355.                     } //If the bottom of the ball is within the brick
  356.                     else if (ball_y - ball_radius <= locations[1] + brick_height/2 && ball_y - ball_radius >= locations[1] - brick_height/2 && noDelay)
  357.                     {
  358.                         //Bottom of ball has hit the top side of the box
  359.                         ball_up = !ball_up;
  360.                         if(locations[3] > 1)
  361.                             locations[3] -= 1;
  362.                         else
  363.                             locations[2] = 0;
  364.                         ball_speed += 1;
  365.                         noDelay = false;
  366.                         changeColour();
  367.                     } //If the top of the ball is within the brick
  368.                     else if (ball_y + ball_radius >= locations[1] - brick_height/2 && ball_y + ball_radius <= locations[1] + brick_height/2 && noDelay)
  369.                     {
  370.                         //Top of ball has hit the bottom of the box
  371.                         ball_up = !ball_up;
  372.                         if(locations[3] > 1)
  373.                             locations[3] -= 1;
  374.                         else
  375.                             locations[2] = 0;
  376.                         ball_speed += 1;
  377.                         noDelay = false;
  378.                         changeColour();
  379.                     }
  380.                 } //If the left side of the ball is within the brick's x-coordinates
  381.                 else if (ball_x - ball_radius > locations[0] - brick_length/2 && ball_x - ball_radius <= locations[0] + brick_length/2)
  382.                 {   //If the center of the ball is not within the brick
  383.                     if (ball_x < locations[0] - brick_length/2 || ball_x > locations[0] + brick_length/2)
  384.                     {   //If either the top or the bot of the ball is within the y-cords of the brick
  385.                         if ((ball_y + ball_radius <= locations[1] + brick_height/2 && ball_y + ball_radius >= locations[1] - brick_height/2)
  386.                          || (ball_y - ball_radius >= locations[1] - brick_height/2 && ball_y - ball_radius <= locations[1] + brick_height/2) && noDelay)
  387.                         {
  388.                             //Ball has hit the right side of the box
  389.                             ball_right = !ball_right;
  390.                             if(locations[3] > 1)
  391.                                 locations[3] -= 1;
  392.                             else
  393.                                 locations[2] = 0;
  394.                             ball_speed += 1;
  395.                             noDelay = false;
  396.                             changeColour();
  397.                         }
  398.                     } //If the bottom of the ball is within the brick
  399.                     else if (ball_y - ball_radius <= locations[1] + brick_height/2 && ball_y - ball_radius >= locations[1] - brick_height/2 && noDelay)
  400.                     {
  401.                         //Bottom of ball has hit the top side of the box
  402.                         ball_up = !ball_up;
  403.                         if(locations[3] > 1)
  404.                             locations[3] -= 1;
  405.                         else
  406.                             locations[2] = 0;
  407.                         ball_speed += 1;
  408.                         noDelay = false;
  409.                         changeColour();
  410.                     }  //If the top of the ball is within the brick
  411.                     else if (ball_y + ball_radius >= locations[1] - brick_height/2 && ball_y + ball_radius <= locations[1] + brick_height/2 && noDelay)
  412.                     {
  413.                         //Top of ball has hit the bottom of the box
  414.                         ball_up = !ball_up;
  415.                         if(locations[3] > 1)
  416.                             locations[3] -= 1;
  417.                         else
  418.                             locations[2] = 0;
  419.                         ball_speed += 1;
  420.                         noDelay = false;
  421.                         changeColour();
  422.  
  423.                     }
  424.                 }
  425.  
  426.             }
  427.             isTheGameOver();
  428.         }
  429.        
  430.     }
  431.     private void isTheGameOver()
  432.     {
  433.         gameOver = true;
  434.         for(float[] locations : brickLocation)
  435.         {
  436.             if(lives == 1)
  437.             {
  438.                 break;
  439.             }
  440.             if (locations[2] != 0)
  441.             {
  442.                 gameOver = false;
  443.                 break;
  444.             }
  445.         }
  446.        
  447.     }
  448.     private void update(){
  449.         if(running)
  450.             ballTravel();
  451.         if(Gdx.input.isKeyPressed(Input.Keys.SPACE)){
  452.             running = true;
  453.         }
  454.         if(gameOver == true){
  455.             if(Gdx.input.isKeyPressed(Input.Keys.ENTER)){
  456.                 startOver();
  457.             }
  458.         }
  459.         ballCollision();
  460.         if(Gdx.input.isKeyPressed(Input.Keys.LEFT)){
  461.             if(boxxy_x > boxxy_length/2)
  462.                 boxxy_x = boxxy_x -5;
  463.         }
  464.        
  465.         if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)){
  466.             if(boxxy_x < Gdx.graphics.getWidth()-boxxy_length/2)
  467.                 boxxy_x = boxxy_x +5;
  468.         }
  469.        
  470.         world_left = 0;
  471.         world_right = Gdx.graphics.getWidth();
  472.         world_bottom = 0;
  473.         world_top = Gdx.graphics.getHeight();
  474.     }
  475.    
  476.     private void drawObject(ObjectReference or)
  477.     {
  478.         Gdx.gl11.glDrawArrays(or.openGLPrimitiveType, or.firstIndex, or.vertexCount);
  479.     }
  480.    
  481.     private ObjectReference createCircle(float radius, int slices, Vector<Point2D> vertexList) {
  482.         ObjectReference or = new ObjectReference(vertexList.size(), slices, GL11.GL_TRIANGLE_FAN);
  483.  
  484.         for(float f = 0; f < 2*Math.PI; f += (float)2*Math.PI / (float)slices) {
  485.             vertexList.add(new Point2D((float)Math.cos(f) * radius, (float)Math.sin(f) * radius));
  486.         }
  487.        
  488.         return or;
  489.     }
  490.        
  491.     private void display(){
  492.         Gdx.gl11.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 
  493.         Gdx.gl11.glClear(GL11.GL_COLOR_BUFFER_BIT);
  494.         Gdx.gl11.glMatrixMode(GL11.GL_MODELVIEW);      
  495.         Gdx.gl11.glLoadIdentity();
  496.         Gdx.glu.gluOrtho2D(Gdx.gl10, world_left, world_right, world_bottom, world_top);
  497.         if(!gameOver)
  498.         {
  499.             int currentlives = lives -1;
  500.             spriteBatch.begin();
  501.             font.setColor(1, 1, 1, 1f);
  502.             font.draw(spriteBatch, String.format("Lives: " + currentlives), 10, 20);
  503.             spriteBatch.end();     
  504.         }
  505.         else
  506.         {
  507.             spriteBatch.begin();
  508.             font.setColor(1, 1, 1, 1f);
  509.             font.draw(spriteBatch, String.format("GAME OVER "), 260, 200);
  510.             font.draw(spriteBatch, String.format("To start a new game press Enter "), 210, 185);
  511.             spriteBatch.end();     
  512.         }
  513.        
  514.         Gdx.gl11.glMatrixMode(GL11.GL_MODELVIEW);
  515.         Gdx.gl11.glLoadIdentity();
  516.         Gdx.gl11.glVertexPointer(2, GL11.GL_FLOAT, 0, vertexBuffer);  
  517.        
  518.         Gdx.gl11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  519.        
  520.         Gdx.gl11.glPushMatrix();
  521.         Gdx.gl11.glTranslatef(boxxy_x, boxxy_y, 0);
  522.         drawObject(boxxy);
  523.         Gdx.gl11.glPopMatrix();
  524.        
  525.         Gdx.gl11.glPushMatrix();
  526.         Gdx.gl11.glColor4f(ballColours[0], ballColours[1], ballColours[2], 1f);
  527.         Gdx.gl11.glTranslatef(ball_x, ball_y, 0);
  528.         drawObject(ball);
  529.         Gdx.gl11.glPopMatrix();
  530.        
  531.         for(float[] locations : brickLocation){
  532.             if(locations[2] == 1)
  533.             {
  534.                 if(locations[3] == 2) //Is it a hardbrick
  535.                 {
  536.                     Gdx.gl11.glPushMatrix();
  537.                     Gdx.gl11.glColor4f(0.0f, 0.0f, 0.93f, 1);
  538.                     Gdx.gl11.glTranslatef(locations[0],locations[1], 0);
  539.                     drawObject(brick);
  540.                     Gdx.gl11.glPopMatrix();
  541.                 }
  542.                 else
  543.                 {
  544.                     Gdx.gl11.glPushMatrix();
  545.                     Gdx.gl11.glColor4f(brickColours[0], brickColours[1], brickColours[2], 1f);
  546.                     Gdx.gl11.glTranslatef(locations[0],locations[1], 0);
  547.                     drawObject(brick);
  548.                     Gdx.gl11.glPopMatrix();
  549.                 }
  550.             }
  551.         }  
  552.        
  553.     }
  554.     private void changeColour()
  555.     {
  556.         float sumBricks = 0;
  557.         float sumBall = 0;
  558.         for (int i = 0; i < 3; i++)
  559.             {
  560.                 brickColours[i] = this.random.nextFloat();
  561.                 ballColours[i] = this.random.nextFloat();
  562.                 sumBricks += brickColours[i];
  563.                 sumBall += ballColours[i];
  564.             }
  565.         sumBricks = sumBricks/3;
  566.         sumBall = sumBall/3;
  567.         if (sumBricks < 0.5 || sumBall < 0.5) //Check whether either of the colours is too dark against the black background
  568.         {
  569.             changeColour(); //If so, we change the colours again
  570.         }
  571.  
  572.     }
  573.  
  574.     private void brickLocations()
  575.     {
  576.         boolean makeHardBricks = true;
  577.         for(float x = brick_x; x <= 590; x+=55)
  578.         {
  579.             for(float y= brick_y; y >= 300; y-=35)
  580.             {  
  581.                 if(makeHardBricks)
  582.                 {
  583.                     //The array contains 3 elements, x, y and destroyed boolean variable.
  584.                     float[] pos = {x, y, 1, 2};
  585.                     brickLocation.add(pos);
  586.                 }
  587.                 else
  588.                 {
  589.                     float[] pos = {x, y, 1, -1};
  590.                     brickLocation.add(pos);
  591.                 }
  592.                 makeHardBricks = !makeHardBricks;
  593.                
  594.             }
  595.             makeHardBricks = !makeHardBricks;
  596.            
  597.         }
  598.     }
  599.  
  600.     @Override
  601.     public void resize(int arg0, int arg1) {
  602.         // TODO Auto-generated method stub
  603.        
  604.     }
  605.  
  606.     @Override
  607.     public void resume() {
  608.         // TODO Auto-generated method stub
  609.        
  610.     }
  611.    
  612.     private ObjectReference createBox(float width, float height,Vector<Point2D> vertexList)
  613.     {
  614.         ObjectReference or = new ObjectReference(vertexList.size(), 4,
  615.         GL11.GL_TRIANGLE_STRIP);
  616.         vertexList.add(new Point2D(-width/2.0f, -height/2.0f));
  617.         vertexList.add(new Point2D(-width/2.0f, height/2.0f));
  618.         vertexList.add(new Point2D(width/2.0f, -height/2.0f));
  619.         vertexList.add(new Point2D(width/2.0f, height/2.0f));
  620.         return or;
  621.     }
  622.    
  623.     public class Point2D
  624.     {
  625.         public float x;
  626.         public float y;
  627.         public Point2D(float xx, float yy)
  628.         {
  629.             x = xx;
  630.             y = yy;
  631.         }
  632.     }
  633.    
  634.     public class ObjectReference
  635.     {
  636.         public int firstIndex;
  637.         public int vertexCount;
  638.         public int openGLPrimitiveType;
  639.         public ObjectReference(int fi, int vc, int pt)
  640.         {
  641.             firstIndex = fi;
  642.             vertexCount = vc;
  643.             openGLPrimitiveType = pt;
  644.         }
  645.     }
  646.  
  647. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top