From 5d0d638275be65123192dfb032d56dc134035ab6 Mon Sep 17 00:00:00 2001 From: Fastium Date: Wed, 15 Jun 2022 22:54:18 +0200 Subject: [PATCH] finish format text --- src/Screen/ScreenMap.java | 3 +- src/testYann.java | 98 ++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 44 deletions(-) diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index 625b6c2..06c5e7e 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -16,6 +16,7 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; +import Entity.Character.Direction; import Entity.Player; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; @@ -160,7 +161,7 @@ public class ScreenMap extends RenderingScreen{ try { Door.nextMap = mapProperties.get("nextMap").toString(); } catch (Exception e) { } try { Door.nextX = Integer.parseInt(mapProperties.get("nextX").toString()); } catch (Exception e) { } try { Door.nextY = Integer.parseInt(mapProperties.get("nextY").toString()); } catch (Exception e) { } - try { Door.nextDirection = Door.nextDirection.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { } + try { Door.nextDirection = Direction.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { } } } diff --git a/src/testYann.java b/src/testYann.java index 70cf8a4..c267fa5 100644 --- a/src/testYann.java +++ b/src/testYann.java @@ -14,63 +14,75 @@ import java.util.RandomAccess; class testYann{ public static void main(String[] args) { - System.out.println(111); + - String line = " Je vais te manger tout cru asdnkajsdh asl "; + String text = "aaaaaa aaaaaa\naaaaaa aaaaaa"; + String newText =""; String cutLine = ""; String newLine = ""; - int cut = 12; + int cut = 6; int startC = 0; int stoppC = cut; - if(cut>line.length()-1){ - newLine =line; - } - else{ - - char[] c = new char[line.length()]; + String[] s = text.split("\n"); - for(int i=0; iline.length()-1){ + newLine =line; } - - - - while(true){ - for(int i =stoppC; i>=startC; i--){ - if(c[i] == ' '){ - stoppC = i; - break; - } - else if(stoppC == c.length-1){ - break; - } - } - - //découper le mot - for(int i=startC;i<=stoppC;i++){ - cutLine += c[i]; - } - - newLine += cutLine+"\n"; - cutLine = ""; - - startC = stoppC + 1; - + else{ - if(c.length-1-stoppC <=0){ - break; + char[] c = new char[line.length()]; + + for(int i=0; i=startC; i--){ + if(c[i] == ' '){ + stoppC = i; + break; + } + else if(stoppC == c.length-1){ + break; + } + } + + //découper le mot + for(int i=startC;i<=stoppC;i++){ + cutLine += c[i]; + } + + newLine += cutLine+"\n"; + cutLine = ""; + + startC = stoppC + 1; + + + if(c.length-1-stoppC <=0){ + break; + } + else if(c.length-1-stoppC <= cut){ + stoppC = c.length-1; + } + else{ + stoppC += cut; + } } } + + newText += newLine + "\n"; + } + + @@ -78,7 +90,7 @@ class testYann{ - System.out.println(newLine); + System.out.println(newText);