StartScreenHeroController.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package me.hammerle.supersnuvi.entity.components.ai;
  2. import me.hammerle.supersnuvi.entity.Entity;
  3. import me.hammerle.supersnuvi.tiles.Location;
  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. public StartScreenHeroController(Entity ent)
  11. {
  12. super(ent);
  13. }
  14. @Override
  15. public void tick()
  16. {
  17. ent.setMotionX(ent.getMovement().getVelocityX());
  18. if(shouldJump)
  19. {
  20. shouldJump = false;
  21. ent.getMovement().jump();
  22. }
  23. ox = ent.getFace() == Face.RIGHT ? 0.0f : -0.15625f * Tile.SIZE;
  24. oy = 0.0f;
  25. h = 2.0f;
  26. w = 1.0f;
  27. if(ent.isOnGround())
  28. {
  29. if(ent.getMotionX() == 0.0f)
  30. {
  31. tx = (idleFrame * 32.0f) / SIZE;
  32. ty = 128.0f / SIZE;
  33. nextIdleFrame();
  34. }
  35. else
  36. {
  37. tx = (96.0f + walkFrame * 32.0f) / SIZE;
  38. ty = 0.0f;
  39. nextWalkFrame();
  40. }
  41. }
  42. else
  43. {
  44. resetFrames();
  45. tx = 0.0f;
  46. ty = 0.0f;
  47. }
  48. }
  49. @Override
  50. public void onCollideWithTile(Location loc, Face face)
  51. {
  52. if(face == Face.RIGHT && !(loc.getTile() instanceof RampTile))
  53. {
  54. shouldJump = true;
  55. }
  56. }
  57. }