Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public void create() {
  2. // Game Initialization
  3. v = new Vector2(Gdx.graphics.getWidth() - 0, Gdx.graphics.getHeight() - 0);
  4. v.nor();
  5. v.scl(100);
  6.  
  7. spriteBatch = new SpriteBatch();
  8. bug = new Sprite(new Texture("EnemyBug.png"));
  9. bug.setSize(50, 85);
  10. bug.setOrigin(0,0);//Gdx.graphics.getHeight() / 5, Gdx.graphics.getHeight() / 5);
  11. bug.setPosition(1,1);//Gdx.graphics.getWidth() - 50, Gdx.graphics.getHeight() - 50);
  12. bug.rotate(v.angle());
  13.  
  14. rotDeg = 5;
  15. }
  16.  
  17. @Override
  18. public void render() {
  19. // Game Loop
  20.  
  21. Gdx.gl.glClearColor(0.7f, 0.7f, 0.2f, 1);
  22. Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  23. spriteBatch.begin();
  24.  
  25. if(bug.getX() >= (int)(Gdx.graphics.getWidth() - 100) && bug.getY() >= (int)(Gdx.graphics.getHeight() - 100)){
  26. turn = !turn;
  27. }
  28. else if(bug.getX() <= 50 && bug.getY() <= 50){
  29. turn = !turn;
  30. }
  31.  
  32.  
  33. if(!turn){
  34. bug.translate(v.x * Gdx.graphics.getDeltaTime(), v.y * Gdx.graphics.getDeltaTime());
  35. }
  36. else{
  37. bug.translate(-(v.x * Gdx.graphics.getDeltaTime()), -(v.y * Gdx.graphics.getDeltaTime()));
  38. }
  39.  
  40. bug.translate(v.x * Gdx.graphics.getDeltaTime(), v.y * Gdx.graphics.getDeltaTime());
  41. bug.draw(spriteBatch);
  42. spriteBatch.end();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement