X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameInput.java;h=015d81a1ad6b2ff4abcea74462113214747d95f3;hb=5646018e364d9a708e985f04ab510bf88692082b;hp=291311a68077622850ed90b533622ccf30ab6557;hpb=46c9d587bf0b5ef342e2073b69b40cb5438109d9;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java index 291311a..015d81a 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameInput.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameInput.java @@ -3,6 +3,7 @@ package ru.deadsoftware.cavedroid.game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Intersector; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.TimeUtils; import com.google.common.collect.Range; @@ -215,6 +216,16 @@ public class GameInput { } } + private void hitMobs() { + final Player player = mMobsController.getPlayer(); + mMobsController.getMobs().forEach((mob) -> { + if (Intersector.overlaps(mob, player)) { + mob.damage(5); + mob.jump(); + } + }); + } + private void pressLMB() { if (mMainConfig.checkGameUiWindow(GameUiWindow.NONE)) { mPlayer.startHitting(); @@ -244,6 +255,7 @@ public class GameInput { mTouchedDown = false; } } else { + hitMobs(); mTouchedDown = false; } } @@ -303,7 +315,7 @@ public class GameInput { break; case Input.Keys.G: - mMobsController.addMob(Pig.class, mCurX * 16, mCurY * 16); + mMobsController.addMob(new Pig(mCurX * 16, mCurY * 16)); break; case Input.Keys.Q: