PathGame.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package pathgame;
  2. import me.hammerle.snuviengine.api.IGame;
  3. import me.hammerle.snuviengine.api.Renderer;
  4. import pathgame.gameplay.Gamestate;
  5. import pathgame.gameplay.Gamestates;
  6. import pathgame.gameplay.Keys;
  7. import pathgame.gameplay.Level;
  8. import pathgame.gameplay.menu.Menu;
  9. import pathgame.rendering.LevelRenderer;
  10. import pathgame.rendering.MenuRenderer;
  11. public class PathGame implements IGame
  12. {
  13. private final Gamestate gamestate = new Gamestate();
  14. private final Level level = new Level();
  15. private final LevelRenderer levelRenderer = new LevelRenderer();
  16. private final Menu menu = new Menu();
  17. private final MenuRenderer menuRenderer = new MenuRenderer();
  18. public PathGame()
  19. {
  20. }
  21. @Override
  22. public void tick()
  23. {
  24. level.tick(gamestate);
  25. levelRenderer.tick(level, gamestate);
  26. menu.tick(gamestate, level);
  27. if(Keys.TEST_KEY.getTime() == 1)
  28. {
  29. //level.nextLevel();
  30. level.getPlayer().win(level.getMap());
  31. }
  32. }
  33. @Override
  34. public void renderTick(Renderer r, float lag)
  35. {
  36. if(gamestate.is(Gamestates.MENU))
  37. {
  38. levelRenderer.renderTick(r, 0.0f, level, gamestate);
  39. menuRenderer.renderTick(r, 0.0f, menu);
  40. }
  41. else
  42. {
  43. levelRenderer.renderTick(r, lag, level, gamestate);
  44. }
  45. }
  46. @Override
  47. public void onStop()
  48. {
  49. }
  50. }