StartScreenHeroController.java 1.6 KB

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