diff options
| author | ilotterytea <iltsu@alright.party> | 2024-10-28 01:30:57 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-10-29 02:04:34 +0500 |
| commit | 232e6485cfe200c62fe1266adf9e7fb886d2d8f2 (patch) | |
| tree | ad0fd2de0dbc3a9f258d751c34f9e20f6241b64e /core | |
| parent | 096f52f6b5b86ef433339e56abcecb925096195e (diff) | |
feat: pet maxon through the space key
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/kz/ilotterytea/maxon/player/DecalPlayer.java | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/core/src/kz/ilotterytea/maxon/player/DecalPlayer.java b/core/src/kz/ilotterytea/maxon/player/DecalPlayer.java index 2fa97c8..e7871e5 100644 --- a/core/src/kz/ilotterytea/maxon/player/DecalPlayer.java +++ b/core/src/kz/ilotterytea/maxon/player/DecalPlayer.java @@ -1,6 +1,7 @@ package kz.ilotterytea.maxon.player; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.g2d.TextureRegion; @@ -63,10 +64,10 @@ public class DecalPlayer implements Disposable { } public void render(Camera camera) { - checkCollisions(camera); + if (checkCollisions(camera) || Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) pet(); } - private void checkCollisions(Camera camera) { + private boolean checkCollisions(Camera camera) { Ray ray = null; if (Gdx.input.justTouched()) { @@ -74,20 +75,22 @@ public class DecalPlayer implements Disposable { } if (ray == null) { - return; + return false; } Vector3 intersection = new Vector3(); - if (Intersector.intersectRayBounds(ray, box, intersection)) { - updateTextureRegion(); - savegame.increaseMoney(1); + return Intersector.intersectRayBounds(ray, box, intersection); + } - Sound sound = MaxonGame.getInstance().assetManager.get("sfx/player/purr.ogg", Sound.class); - sound.play(); + private void pet() { + updateTextureRegion(); + savegame.increaseMoney(1); - clickStreak++; - } + Sound sound = MaxonGame.getInstance().assetManager.get("sfx/player/purr.ogg", Sound.class); + sound.play(); + + clickStreak++; } private void updateTextureRegion() { |
