StartScreenHeroController.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package me.hammerle.supersnuvi.entity.components.ai;
  2. import me.hammerle.supersnuvi.entity.Entity;
  3. import me.hammerle.supersnuvi.gamelogic.Level;
  4. import me.hammerle.supersnuvi.tiles.RampTile;
  5. import me.hammerle.supersnuvi.tiles.Tile;
  6. import me.hammerle.supersnuvi.util.Face;
  7. public class StartScreenHeroController extends HumanController
  8. {
  9. private boolean shouldJump = false;
  10. @Override
  11. public void tick(Entity ent, Level level)
  12. {
  13. ent.applyOwnForce(ent.getMovement().getVelocityX(), 0.0f);
  14. if(shouldJump)
  15. {
  16. shouldJump = false;
  17. ent.jump();
  18. }
  19. ox = 0.0f;
  20. oy = 0.0f;
  21. h = 2.0f;
  22. w = 1.0f;
  23. if(ent.isOnGround())
  24. {
  25. if(ent.getOwnForceX() == 0.0f)
  26. {
  27. tx = (idleFrame * 32.0f) / SIZE;
  28. ty = 128.0f / SIZE;
  29. nextIdleFrame();
  30. }
  31. else
  32. {
  33. tx = (96.0f + walkFrame * 32.0f) / SIZE;
  34. ty = 0.0f;
  35. nextWalkFrame();
  36. }
  37. }
  38. else
  39. {
  40. resetFrames();
  41. tx = 0.0f;
  42. ty = 0.0f;
  43. }
  44. }
  45. @Override
  46. public void onCollideWithTile(Entity ent, int x, int y, Level l, Tile t, Face face)
  47. {
  48. if(face == Face.RIGHT && !(t instanceof RampTile))
  49. {
  50. shouldJump = true;
  51. }
  52. }
  53. }