From 4843f5d1d89f518cc7c78e9a25a567fc0c5ed216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Wed, 8 Jun 2022 20:08:18 +0200 Subject: [PATCH] near to done --- .gitignore | 2 +- resources/Base.png | Bin 0 -> 1048 bytes resources/Character.png | Bin 0 -> 1512 bytes src/Entity/Enemy.java | 8 +- src/Entity/Entity.java | 1 - src/Entity/Player.java | 16 ++-- src/Screen/Hero.java | 189 ---------------------------------------- src/testHER.java | 23 +++-- 8 files changed, 31 insertions(+), 208 deletions(-) create mode 100644 resources/Base.png create mode 100644 resources/Character.png delete mode 100644 src/Screen/Hero.java diff --git a/.gitignore b/.gitignore index ff8e3ce..144401e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,6 @@ build # Ignore bin -app/bin/ +bin/ *.tiled-session resources/map/Maps.tiled-session diff --git a/resources/Base.png b/resources/Base.png new file mode 100644 index 0000000000000000000000000000000000000000..3485b127e652ac1c693ba66b8645816f932512ee GIT binary patch literal 1048 zcmV+z1n2vSP)4*rHj20FL8Y79G`?LAI+YgQuF2I0+nS!%Y10YcKW|{4GO%Y1EOsF4 z_6Cs~(~`FizPz?fXS@1^2XV@)_1xf-4&ROq2Ib>B z%?-jAm-#Wu_d5JwsU@oc)5gb-Xzqy_Nf|S$phVG7(o6PXtks?@sDMRj_VSH1q~($0ZnBIVe3MZif-gX zXlV^5_?m-CY1AXr)-qkrQ3W*6BR@qw)&VLoy{=3b13jXF3XldujcO!uq>I69&|o&) zpmY#4pVPFq|3p_Xe1QS>Zy!(;w(%BG+XNJ z|7aaBI$(6bcnrejfFT+U@1FyVQr>xLz8Wx8Jy*7;6JYRiN_TB>-2+Bo=UM?HEPP3K z4}6OxuhGDiB?Oi@C&1vprq}8Pq;{drc0HP?OF&G+ys`&sf zu)dcGkUZ;2h+|C-fuuAQTZ1HyHMMo5R+bhqnl3Gp^!9w~<-M2pUfv&r(C-iW{XxG! z==TS`{jt^oqXWi20T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g}8?KuOeNdw%2s0IyoNI2_mK$r^< z4?x_W^X|>x<98c?1(sLn5AeEXg97pG1_hXcG~aSQoGsvUgd2FG!+-#Mo}K~DC4<6s z5Ln+}|1SNd|}eK~(lI$|eVNNO*?6 zJ#k;q@0%QiUw~fzq8b#{pm=A4;?u`r`0(^z2F2?XzkV5p&o9w7 zAfB%Vg=t_sZcse$1_dwxrrn?b2FAk%1--LDA^rbj1_j+`P~iT2^$ZBQ$Dml2)#*;T zH}iN0nB40?fDL9->~4`pXVp{8vuaJU|x~E(WLHL`e%4SVmBykLjG3;0L`1sKmkzt z<}e`Od$Q|x3i(pD(Ep2n;Jqf?yKndS1I`_Z5`f#DrrJKB|MfiMI}U`3@Z0|b0Lvx) zqBkhE3pxXb4il8@jgtF7$-uC~vOom0JZNuR4Gerju2D_`ufU)8H+}%sM38xBb(I$Y O0000 frameTime) { - dt -= frameTime; - currentFrame = (currentFrame + 1) % nFrames; - - if(currentFrame == 0){ - move = false; - lastPosition = new Vector2(newPosition); - position = new Vector2(newPosition); - } - } - } - - /** - * @return True if the hero is actually doing a step. - */ - public boolean isMoving(){ - return move; - } - - /** - * @param speed The new speed of the hero. - */ - public void setSpeed(float speed){ - this.speed = speed; - } - - /** - * Do a step on the given direction - * @param direction The direction to go. - */ - public void go(Direction direction){ - move = true; - switch(direction){ - case RIGHT: - newPosition.add(SPRITE_WIDTH, 0); - break; - case LEFT: - newPosition.add(-SPRITE_WIDTH, 0); - break; - case UP: - newPosition.add(0, SPRITE_HEIGHT); - break; - case DOWN: - newPosition.add(0, -SPRITE_HEIGHT); - break; - default: - break; - } - - turn(direction); - } - - /** - * Turn the hero on the given direction without do any step. - * @param direction The direction to turn. - */ - public void turn(Direction direction){ - switch(direction){ - case RIGHT: - textureY = 2; - break; - case LEFT: - textureY = 1; - break; - case UP: - textureY = 3; - break; - case DOWN: - textureY = 0; - break; - default: - break; - } - } - - /** - * Draw the character on the graphic object. - * @param g Graphic object. - */ - public void draw(GdxGraphics g) { - g.draw(ss.sprites[textureY][currentFrame], position.x, position.y); - } -} diff --git a/src/testHER.java b/src/testHER.java index b177a7c..4a74342 100644 --- a/src/testHER.java +++ b/src/testHER.java @@ -1,6 +1,9 @@ +import java.util.Vector; + import com.badlogic.gdx.Input; import Control.Controller; +import Entity.Enemy; import Entity.Entity; import Entity.Player; import Screen.ScreenMap; @@ -13,12 +16,12 @@ public class testHER extends PortableApplication{ private Controller controller; private ScreenMap sm; private Player p1; - private static Entity[] entities; + private static Vector entities = new Vector<>(); + private static Vector players = new Vector<>(); public testHER(){ controller = new Controller(); - p1 = new Player(8, 15); sm = new ScreenMap(); } @@ -32,15 +35,25 @@ public class testHER extends PortableApplication{ public void onInit() { controller.init(); sm.init(); - p1.init(); + p1 = new Player(8, 15); + entities.add((Entity) p1); + entities.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32")); + entities.add(new Enemy("Pignat", 12, 15, "lumberjack_sheet32")); + + for (Entity entity : entities) { + entity.init(); + } } @Override public void onGraphicRender(GdxGraphics g) { g.clear(); p1.manageEntity(sm, controller); - sm.graphicRender(g, p1); // load p1 by Entity[] - p1.graphicRender(g); + sm.graphicRender(g, p1); + + for (Entity entity : entities) { + entity.graphicRender(g); + } } @Override