diff --git a/.gitignore b/.gitignore index 852e7eb..5578b4c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,10 @@ *.iws *.iws *.iws +*.iws +*.iws +*.iws +*.iws +*.iws +*.iws *.iws \ No newline at end of file diff --git a/.idea/modules/OVERSTORY.iml b/.idea/modules/OVERSTORY.iml index 4699a32..c546907 100644 --- a/.idea/modules/OVERSTORY.iml +++ b/.idea/modules/OVERSTORY.iml @@ -1,6 +1,8 @@ - + + + diff --git a/.idea/modules/desktop/desktop.iml b/.idea/modules/desktop/desktop.iml index 04ba4b5..f2fe902 100644 --- a/.idea/modules/desktop/desktop.iml +++ b/.idea/modules/desktop/desktop.iml @@ -15,26 +15,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OVERSTORY.iws b/OVERSTORY.iws index 3ddb3b0..f850469 100644 --- a/OVERSTORY.iws +++ b/OVERSTORY.iws @@ -2,16 +2,14 @@ - - - + + - - + @@ -43,24 +41,19 @@ - + - + - - - - - - - - + + + @@ -68,8 +61,8 @@ - - + + @@ -77,11 +70,11 @@ - + - - + + @@ -89,26 +82,24 @@ - - + + - - - - - - - + + + - - + + - - - + + + + + @@ -126,11 +117,11 @@ @@ -155,7 +146,9 @@ + + @@ -288,10 +281,11 @@ - - + + + @@ -576,26 +570,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -608,12 +582,7 @@ - - - - - - + @@ -643,8 +612,6 @@ - - @@ -669,12 +636,7 @@ - - - - - - + @@ -704,8 +666,6 @@ - - @@ -730,12 +690,7 @@ - - - - - - + @@ -765,8 +720,6 @@ - - @@ -791,12 +744,7 @@ - - - - - - + @@ -826,8 +774,6 @@ - - @@ -880,12 +826,7 @@ - - - - - - + @@ -919,12 +860,7 @@ - - - - - - + @@ -1004,70 +940,77 @@ - - + - - + + - + - - - - - - - + + - + - - + + - + - - + + - - - - + - + - - + + - + - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/assets/thor.png b/core/assets/thor.png new file mode 100644 index 0000000..83e4edb Binary files /dev/null and b/core/assets/thor.png differ diff --git a/core/build/classes/main/com/mygdx/overstory/Character.class b/core/build/classes/main/com/mygdx/overstory/Character.class index af043ec..18ab894 100644 Binary files a/core/build/classes/main/com/mygdx/overstory/Character.class and b/core/build/classes/main/com/mygdx/overstory/Character.class differ diff --git a/core/build/classes/main/com/mygdx/overstory/Enemy$1.class b/core/build/classes/main/com/mygdx/overstory/Enemy$1.class deleted file mode 100644 index 7f62e44..0000000 Binary files a/core/build/classes/main/com/mygdx/overstory/Enemy$1.class and /dev/null differ diff --git a/core/build/classes/main/com/mygdx/overstory/Enemy.class b/core/build/classes/main/com/mygdx/overstory/Enemy.class index ea75d26..4c793ea 100644 Binary files a/core/build/classes/main/com/mygdx/overstory/Enemy.class and b/core/build/classes/main/com/mygdx/overstory/Enemy.class differ diff --git a/core/build/classes/main/com/mygdx/overstory/OverstoryMain.class b/core/build/classes/main/com/mygdx/overstory/OverstoryMain.class index 48db14e..0a2039c 100644 Binary files a/core/build/classes/main/com/mygdx/overstory/OverstoryMain.class and b/core/build/classes/main/com/mygdx/overstory/OverstoryMain.class differ diff --git a/core/build/classes/main/com/mygdx/overstory/Player$1.class b/core/build/classes/main/com/mygdx/overstory/Player$1.class index 760a1ff..e64b4db 100644 Binary files a/core/build/classes/main/com/mygdx/overstory/Player$1.class and b/core/build/classes/main/com/mygdx/overstory/Player$1.class differ diff --git a/core/build/classes/main/com/mygdx/overstory/Player.class b/core/build/classes/main/com/mygdx/overstory/Player.class index 5372474..7cf5f1b 100644 Binary files a/core/build/classes/main/com/mygdx/overstory/Player.class and b/core/build/classes/main/com/mygdx/overstory/Player.class differ diff --git a/core/src/com/mygdx/overstory/Character.java b/core/src/com/mygdx/overstory/Character.java index f063e17..2d0f144 100644 --- a/core/src/com/mygdx/overstory/Character.java +++ b/core/src/com/mygdx/overstory/Character.java @@ -20,6 +20,7 @@ public class Character extends MyActor{ float DMG; //Base Attack Damage float DEF; //Base Defence float LCK; //Chance for dodges and critical hits + long time = 0; public Character(Sprite sprite, float health, float x, float y, String Name) { super(sprite); @@ -51,4 +52,10 @@ public void draw(Batch batch, float parentAlpha) { } } + public boolean confineToMap(float x, float y){ + MyActor hitActor = (MyActor) om.getStage().hit(sprite.getX() + sprite.getWidth()/2 + x, sprite.getY() + sprite.getHeight()/2 + y, false); + if(hitActor == null) return false; + return true; + } + } diff --git a/core/src/com/mygdx/overstory/Enemy.java b/core/src/com/mygdx/overstory/Enemy.java index da2d10f..ff9ed9c 100644 --- a/core/src/com/mygdx/overstory/Enemy.java +++ b/core/src/com/mygdx/overstory/Enemy.java @@ -5,26 +5,27 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.ColorAction; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; + /** * Created by chris on 1/17/2017. */ public class Enemy extends Character { float GLD; //Amount of gold enemy drops - public Enemy(final Sprite sprite, float health, float DMG, float x, float y, String Name) { + int enrandmvmt = 0; + float xp = 1f; //Amount of xp enemy drops + + + public Enemy(Sprite sprite, float health, float DMG, float x, float y, String Name) { super(sprite, health, DMG, x , y, Name); //AI movement - addListener(new ClickListener(){ - @Override - public void clicked(InputEvent event, float x, float y) { - removeHealth(om.getPlayer().DMG); - } - }); + } public void isHit(Character character) { @@ -37,5 +38,59 @@ public void removeHealth(float amount) { Gdx.app.log(getName(), String.valueOf(health)); } + @Override + public void draw(Batch batch, float parentAlpha) { + sprite.draw(batch); + if(health <= 0){ + om.getPlayer().xp += this.xp; + Gdx.app.log(om.getPlayer().getName(), String.valueOf(om.getPlayer().xp)); + this.remove(); + sprite.getTexture().dispose(); + } + + if(System.currentTimeMillis() > time) { + enrandmvmt = (int)(Math.random() * 5 + 1); + switch (enrandmvmt){ + case 1: + if(confineToMap(100f,0f)) { + addAction(Actions.moveBy(100f, 0f, .2f)); + time = System.currentTimeMillis() + 300; + } + break; + case 2: + if(confineToMap(-100f,0f)) { + addAction(Actions.moveBy(-100f, 0f, .2f)); + time = System.currentTimeMillis() + 300; + } + break; + case 3: + if(confineToMap(0f,100f)) { + addAction(Actions.moveBy(0f, 100f, .2f)); + time = System.currentTimeMillis() + 300; + } + break; + case 4: + if(confineToMap(0f,-100f)) { + addAction(Actions.moveBy(0f, -100f, .2f)); + time = System.currentTimeMillis() + 300; + } + break; + case 5: + addAction(Actions.moveBy(0f, 0f, .2f)); + time = System.currentTimeMillis() + 300; + break; + } + + } + } + + @Override + public void isHit() { //Currently damages enemy for 50% to 150% of DMG (FEEL FREE TO MODIFY) + removeHealth((float)(int)(om.getPlayer().DMG * (float)(Math.random() * 11 + 5)/10)); + //removeHealth((om.getPlayer().DMG); + } + + + } diff --git a/core/src/com/mygdx/overstory/OverstoryMain.java b/core/src/com/mygdx/overstory/OverstoryMain.java index 26d8c83..745730c 100644 --- a/core/src/com/mygdx/overstory/OverstoryMain.java +++ b/core/src/com/mygdx/overstory/OverstoryMain.java @@ -26,14 +26,14 @@ public Player getPlayer() { public void create () { stage = new Stage(new ScreenViewport()); - map = new MyActor(new Sprite(new Texture("spaceimg.jpg"))); + map = new MyActor(new Sprite(new Texture("floor.jpg"))); map.setName("Map"); map.setTouchable(Touchable.disabled); - player = new Player(new Sprite(new Texture("badlogic.jpg")), 100f, 10f, 0f, 0f, "Player"); + player = new Player(new Sprite(new Texture("thor.png")), 100f, 10f, 0f, 0f, "Player"); player.setTouchable(Touchable.disabled); stage.addActor(map); @@ -64,6 +64,7 @@ public void dispose () { public Stage getStage() { return stage; } + public static MyActor getMap() { return map; } public void spawnEnemy(Texture texture, float health, float DMG, float x, float y, String Name){ stage.addActor(new Enemy(new Sprite(texture), health, DMG, x, y, Name)); diff --git a/core/src/com/mygdx/overstory/Player.java b/core/src/com/mygdx/overstory/Player.java index ca2980b..1c2b9af 100644 --- a/core/src/com/mygdx/overstory/Player.java +++ b/core/src/com/mygdx/overstory/Player.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.actions.Actions; @@ -24,29 +25,43 @@ public Player(Sprite sprite, float health, float DMG, float x, float y, String N @Override public boolean keyDown(InputEvent event, int keycode) { - switch (keycode) { - - //Ill constrain movement later, just setting up classes. - - case Input.Keys.W: - addAction(Actions.moveBy(0f, 100f, 1f)); - break; - - case Input.Keys.S: - addAction(Actions.moveBy(0f, -100f, 1f)); - break; - - case Input.Keys.A: - addAction(Actions.moveBy(-100f, 0f, 1f)); - break; - - case Input.Keys.D: - addAction(Actions.moveBy(100f, 0f, 1f)); - break; + //Ill constrain movement later, just setting up classes. + if(System.currentTimeMillis() > time) { + switch (keycode) { + + case Input.Keys.W: + if (confineToMap(0f, 100f)) { + addAction(Actions.moveBy(0f, 100f, .2f)); + time = System.currentTimeMillis() + 200; + + } + break; + + case Input.Keys.S: + if (confineToMap(0f, -100f)) { + addAction(Actions.moveBy(0f, -100f, .2f)); + time = System.currentTimeMillis() + 200; + } + break; + + case Input.Keys.A: + if (confineToMap(-100f, 0f)) { + addAction(Actions.moveBy(-100f, 0f, .2f)); + time = System.currentTimeMillis() + 200; + } + break; + + case Input.Keys.D: + if (confineToMap(100f, 0f)) { + addAction(Actions.moveBy(100f, 0f, .2f)); + time = System.currentTimeMillis() + 200; + } + break; } - return false; + } + return false; } });