12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package me.hammerle.supersnuvi.entity.components.ai;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.gamelogic.Level;
- import me.hammerle.supersnuvi.tiles.Location;
- import me.hammerle.supersnuvi.tiles.RampTile;
- import me.hammerle.supersnuvi.tiles.Tile;
- import me.hammerle.supersnuvi.util.Face;
- public class StartScreenHeroController extends HumanController
- {
- private boolean shouldJump = false;
-
- public StartScreenHeroController(Entity ent)
- {
- super(ent);
- }
-
- @Override
- public void tick(Level level)
- {
- ent.setMotionX(ent.getMovement().getVelocityX());
-
- if(shouldJump)
- {
- shouldJump = false;
- ent.getMovement().jump();
- }
-
- ox = ent.getFace() == Face.RIGHT ? 0.0f : -0.15625f * Tile.SIZE;
- oy = 0.0f;
- h = 2.0f;
- w = 1.0f;
-
- if(ent.isOnGround())
- {
- if(ent.getMotionX() == 0.0f)
- {
- tx = (idleFrame * 32.0f) / SIZE;
- ty = 128.0f / SIZE;
- nextIdleFrame();
- }
- else
- {
- tx = (96.0f + walkFrame * 32.0f) / SIZE;
- ty = 0.0f;
- nextWalkFrame();
- }
- }
- else
- {
- resetFrames();
- tx = 0.0f;
- ty = 0.0f;
- }
- }
- @Override
- public void onCollideWithTile(Location loc, Face face)
- {
- if(face == Face.RIGHT && !(loc.getTile() instanceof RampTile))
- {
- shouldJump = true;
- }
- }
- }
|