From ee647652d2920b5aaf4ed9c1867a58f170de3bde Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Wed, 27 Jul 2016 00:20:36 +0900 Subject: [PATCH] fixed a bug where colourmap won't interpolate properly. BUG: fadeout/fadein is somewhat glitched, UIQuickBar does not fade-in/out instead it just (dis)appears with no effect Former-commit-id: 029f504b7e2e4d85676ec8b36b27dcbed5e5db47 Former-commit-id: 0b56ca1e8976bfc5e7ea8d665e6ed6496a52de85 --- .idea/codeStyleSettings.xml | 4 +- res/graphics/fonts/numeric_small.png | Bin 932 -> 932 bytes res/graphics/gui/quickbar/item_slot.bmp | Bin 4152 -> 0 bytes res/graphics/gui/quickbar/item_slot.png | Bin 16264 -> 906 bytes res/graphics/gui/quickbar/item_slot_large.png | Bin 0 -> 904 bytes .../weathers/generic_light 복사본.png | Bin 0 -> 16031 bytes res/graphics/weathers/generic_light.png | Bin 16031 -> 20338 bytes res/graphics/weathers/generic_skybox.png | Bin 16356 -> 19426 bytes src/net/torvald/colourutil/ColourTemp.kt | 18 ++++ src/net/torvald/colourutil/ColourUtil.kt | 10 +++ src/net/torvald/serialise/WriteGameMapData.kt | 12 +-- src/net/torvald/serialise/WriteMeta.kt | 6 +- src/net/torvald/terrarum/COPYING.md | 6 +- src/net/torvald/terrarum/DefaultConfig.kt | 2 +- src/net/torvald/terrarum/StateInGame.kt | 37 ++++---- src/net/torvald/terrarum/StateMonitorCheck.kt | 4 +- .../terrarum/gameactors/ActorWithBody.kt | 78 ++++++++--------- .../torvald/terrarum/gameactors/PBSigrid.kt | 2 +- src/net/torvald/terrarum/gameactors/Player.kt | 40 +++++---- .../torvald/terrarum/gamecontroller/KeyMap.kt | 13 +-- src/net/torvald/terrarum/gamemap/GameWorld.kt | 2 +- src/net/torvald/terrarum/gamemap/MapLayer.kt | 1 + .../terrarum/gamemap/PairedMapLayer.kt | 2 +- .../torvald/terrarum/mapdrawer/MapDrawer.kt | 22 +---- .../terrarum/ui/BasicDebugInfoWindow.kt | 16 ++-- src/net/torvald/terrarum/ui/ConsoleWindow.kt | 2 +- .../torvald/terrarum/ui/GamepadControlled.kt | 12 +++ .../terrarum/ui/ItemSlotImageBuilder.kt | 38 ++++++++- .../{UITypable.kt => KeyboardControlled.kt} | 2 +- .../ui/{UIClickable.kt => MouseControlled.kt} | 7 +- src/net/torvald/terrarum/ui/UICanvas.kt | 8 +- src/net/torvald/terrarum/ui/UIHandler.kt | 62 ++++++++------ src/net/torvald/terrarum/ui/UIPieMenu.kt | 59 ++++++------- src/net/torvald/terrarum/ui/UIQuickBar.kt | 79 ++++++++++++------ .../torvald/terrarum/weather/WeatherMixer.kt | 46 +++++++--- work_files/graphics/weathers/.gitattributes | 1 + 36 files changed, 368 insertions(+), 223 deletions(-) delete mode 100644 res/graphics/gui/quickbar/item_slot.bmp create mode 100644 res/graphics/gui/quickbar/item_slot_large.png create mode 100644 res/graphics/weathers/generic_light 복사본.png create mode 100644 src/net/torvald/colourutil/ColourTemp.kt create mode 100644 src/net/torvald/colourutil/ColourUtil.kt create mode 100644 src/net/torvald/terrarum/ui/GamepadControlled.kt rename src/net/torvald/terrarum/ui/{UITypable.kt => KeyboardControlled.kt} (83%) rename src/net/torvald/terrarum/ui/{UIClickable.kt => MouseControlled.kt} (69%) create mode 100644 work_files/graphics/weathers/.gitattributes diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index ae39d99ac..c4d5773f1 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -7,9 +7,9 @@ - + + diff --git a/res/graphics/fonts/numeric_small.png b/res/graphics/fonts/numeric_small.png index bb5d30de1a9b15d8660a9928948b614cc9716205..52b9272ac614ce5ca8b477a0150603d2798cffbe 100644 GIT binary patch delta 101 zcmZ3&zJz^)J9DfjAA0~xJb@jBQ_(X~tdw45JWIq4Q5X#8S zd2>%xpSR0Z?gVf3pciYaw(;kS{YzZw%`<16LrCjqbGGx!j3PTfq<>-n0#8>zmvv4F FO#nz3C5`|9 delta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j5CDWP3S4|XKr3(oAbe5a;`0GofeQfPivky)56}u+00>_c zxcGd4R^S3a_@cnY=L56?7XZQ+1ui}xpcS|P5WXmI@%aF)zy*NtMS+XY2WSN@0E90J zTzo!2D{uiId{N-y^8s3c3jpDZ0vDeT&B zE7i00&W&Hbee^yg-9K~v<{yXeUYEW>w~Gg<%u literal 0 HcmV?d00001 diff --git a/res/graphics/weathers/generic_light 복사본.png b/res/graphics/weathers/generic_light 복사본.png new file mode 100644 index 0000000000000000000000000000000000000000..da689f9188c927af6882c647080cdbf84c428362 GIT binary patch literal 16031 zcmeI3e{9_38ONQnO(XnN+pPp`#k-c#LVf;m=ex7#T$@bHO-9n9u0H$q#p|7Y zJv+_a4Rws7L6}BMt3frDLN%r#3Z+_CRwxzQSm}N+6|x^l6-_rJDh+L8Q;{~d(d@PF z*L#;s-)bODlU^&iJbC?np67i(&+F&xKRmf+;Fc@euWhF&>Wcop#2`gox*ytYAD;(5 zhgbf+7yh|4*Ei}=)MX32-!|&od#<4U z;L<6OHm%OUJ4as((5BuQxLr(g$y_fOGy6(;u(mWXq?I;lk{;-aw<`r12FLI`&y3F(pK8oJlc16mA57>(z7Iw}QuF%}ZU6|}(dBFjlE z&oLY?^PDVjbma)d+o7f8bweIZ++0Zq|LY8lxo%Eo*@=mX;6x~B=hG}NNfOHmtROH@ z!8k?BRSS&eEGY-6#z_E2%bPjZv@P0;tETL6w=)p%64j2%y0W=iBFm|;gB00 z5HHG{B!~H%;3vl+LCVUe7)iMMb=6goC{czNhJ=tT^0F94qcmunND{o`J;_F&;?v*hKjDqhMmu< zZrseOX~5>Jw8GX0>xsO=CzEo&<+v(bYJb9?xd~^Uk^~?MQHe1$Ltw(;sK`hmF~p?8 zd`QssaM;iy{%&Y=pB1_~PZ+w~BXwJY;p>%%X&}r&MobJ^49~-qDi;$NO*djdl_IfJ zO0OnDg3U^FTi%2%T+JYwY87G{AL3Oh#E3B!Rv{AQnUn^rpy`spX~2LJNL5p`2s0~H zpXu$1V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?d00001 diff --git a/res/graphics/weathers/generic_light.png b/res/graphics/weathers/generic_light.png index da689f9188c927af6882c647080cdbf84c428362..4cc174700795b0e7e73c087acedff07dbe3f23ab 100644 GIT binary patch delta 4053 zcmb_fX*iUB+rG!vAWOCh$==2=GiHXFkR=&KWLHVETE|R`HH^}tWNR$Rl2B4Zlp=py zB4mpqTiHoyEFsxmJ^$XG|M4F0ho0kjzWk2gb>G)@p2vCp&g;W5;>k`$}C6uScGYvOBHwRlYy>S!gh4W@h!nYWYOk#9C`mn@IQ$u|4tQ%q$N8 zV|`f{+bth!iK}g_2!=#cbD>`@#esn8ro@)yV;x!&rHOB40_JB2hZTow zyo!wQko}?*{!yj0vjN;S!sW{p>rs1VtjOHoJpDR;(V*i+VGsEDd{WD z4Q!O(;Nk&9kGFApUBWL5;;hxjpLtT?ZSYD|kj|RH?u@%u z4Z3o>1Ox?VR0(%0U?Wlbn_5G(!KkpMt-l+6!Lz`*+XgB5)!7m2=kVVC1=cYWO*}?$ z@8t>Qjrz+>=6cNj_F-hvX?4l#bB@Z{!)TnEu8jJuDlw;g=g{|HrTFGtt)E8HyXZ6;O@>OLuuP; zY&XxdLT;JN9k+)>i(kTZgeC^XPG6X!L-@|_%&6H}eubaMumLQNSHwo{AjEVlwSplj zF+56m9P(y(j>2T5#0jOk2A>?RJR^^IXPojp)JFmnecIqhTwj9%;`-Y4a#MK1g(oMt z-*Ykj3|>5tm%08r)3=?06mbqu%JOWNDc-FY{yZzU{n%$e1`v8Zh8W%s7pC0k!Jocy z)#U6oN0~kKQp7Pwlzl9UDCel{FDYA{f#-l#xT3Uz0{-5JUP3+^3VmX)&WfGSgW=ZF4>hX>lc3zg`Qlwd?fP)7tQR+2cK) za2C^(cC=NoRjBnmlpA^oTGZu{PstC<*X|AOt?VVt_{>PnO!ad7=;;RO>gkJEDwetI z$6tmnJ5hGItk19Qi~c*}RL~^<;+sX`$&c-(i_~w~i;ypzE>63=HVg?y$4Ps^b%?Xg zam3G_x7w{*|ft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G zo-Z@*r7zukA!QGeH&%s>6JzOuVwyZvN^ zd49+KvF<&yc*~z940Q!@ag`=Eg=O<@r5Y>l?w{0bBd)5Z&l9bixLRmlmXmpx^-+~G zL6s->JiHSr)LFdOo3C=7?~Li&HW$C2^DKQ`M8dDll3oUvG{ib`)2q59_g?g|VP0rn zB`ohLWjCojGAicT+7us~vqQc)$Rl4N(N6?KbLh*2~7YV%vxUn diff --git a/res/graphics/weathers/generic_skybox.png b/res/graphics/weathers/generic_skybox.png index 15762dab423fedee9b31f6dd3456ee837d224602..84a2ace640557011cc0af21b3353b2b2b694dad4 100644 GIT binary patch delta 4030 zcmeHKXE5AhxBpv&)uXKv(WS8LE*7gqjU|iKTSQnT$|Cw|D?~{|%PLVLNJO%PL_$Q1 z9yKIHjZOqvC2T}{-MMq`-1ozsc|X0M-e;aU=Q(qJXMShSoDaWekvN}CBYF>Otk23M zzytsQs{vZq3;<{tPv0O$+EYtve=VFY3L!EXdFbe1vA28!eFJX!`iU6m=!p3F`?`5} zy8=MyM1gsT4T;LDF++7_x6&Tltj_kn1Bi)}8M`@bi#Z+wPIoytH9O)GnXI^Z&gP>n z+hazU&;^O}MHlPbweBa{C0Slq{v|wB_BJw%vaxaS?Vw>Lf8}t1FvuQ#mQyNynON)z zsF=m6p~i$$P0;P18lyox=vg`uj^*A~clr(h*rX+dMg>+~Iiz{z3xEK>5m^b&uDO%g zdaRT+Ad(KuigB(m)1;XJ-Le+l+(0)UP-Xtcg$c+20B=Hswixh&6Rqkv1i8fF23{1)&(0I)La)$b23P<!}e zAL@$uaaSCXc$9K!XkMZEx(v_#Et`9FSTUn6!h5rHUC~dO^PHC4JG(dlL=>h;W{NTI( zJOhI1JY789qC1zXv=~@Ea+6!w@;?eSv_L>k#51~@ED|kh9NK3Vqt7ut;mgwEw`f6) z(Y>vr6(~BJJI7J;5w6U-GRt}W&YBYbE_m@*Zi9{*)4*&e|Wz^AD(gNwJGga z5HU#e{c~Y~`<+DrLxBqH4$)b~UPA&k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&i^d8@ijD`-+1WRi4BRHTdG^%-I1Mn z^g`NBpF82#?k2pO7ytR__mu6=UJ6{>vvcQ9hwRNc*=O&befaF%hiCgP{%P7a`%F$& z+hon{M|IV6FBxU0y*+Kj+kP~E_y1?XW}C0w3M;<1sJhsE$6=oOcOSxv;@(Mq-m78! zX7;RWads1|KrVrRisbpl^(%h7)i7F@ZzU(Q=l_=Lt_D|cGb~#g`AgT7@z$5!2HhSL zd{|OcCMaIrvt_AsgTtfi{u3`&yQI5(>8LRHQDJkWgJV+9i@zUV2<{a(KP4i#_q$xr z3&A&g*;hxr7fk7|pTTrep}8xe|HVOt<(u3maE1Ap&Jfr9+Hoa7NmOa&1CC>_l+@GP zLL=4ItoYPnq%Yab>-lwBF`I|G$2TGAs~y|(7GBMin9nt>OEf=LZp+@qD@!M-NZ))L tn{GSbac_Z6DJZEn+y`dS|Nog8YQB6n)eSUQ1LQJzy85}Sb7D$p0sw>>v}FJQ diff --git a/src/net/torvald/colourutil/ColourTemp.kt b/src/net/torvald/colourutil/ColourTemp.kt new file mode 100644 index 000000000..d6e6998ac --- /dev/null +++ b/src/net/torvald/colourutil/ColourTemp.kt @@ -0,0 +1,18 @@ +package net.torvald.colourutil + +import org.newdawn.slick.Color +import org.newdawn.slick.Image + +/** + * Created by minjaesong on 16-07-26. + */ +object ColourTemp { + private var envOverlayColourmap = Image("./res/graphics/colourmap/black_body_col_1000_40000_K.png") + + private fun colTempToImagePos(K: Int): Int { + if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)") + return (K - 1000) / 10 + } + + operator fun invoke(temp: Int): Color = envOverlayColourmap.getColor(colTempToImagePos(temp), 0) +} \ No newline at end of file diff --git a/src/net/torvald/colourutil/ColourUtil.kt b/src/net/torvald/colourutil/ColourUtil.kt new file mode 100644 index 000000000..798fb8d93 --- /dev/null +++ b/src/net/torvald/colourutil/ColourUtil.kt @@ -0,0 +1,10 @@ +package net.torvald.colourutil + +import org.newdawn.slick.Color + +/** + * Created by minjaesong on 16-07-26. + */ +object ColourUtil { + fun toSlickColor(r: Int, g: Int, b: Int) = Color(r.shl(16) or g.shl(8) or b) +} \ No newline at end of file diff --git a/src/net/torvald/serialise/WriteGameMapData.kt b/src/net/torvald/serialise/WriteGameMapData.kt index b8fa0fcee..053f00a42 100644 --- a/src/net/torvald/serialise/WriteGameMapData.kt +++ b/src/net/torvald/serialise/WriteGameMapData.kt @@ -35,7 +35,7 @@ object WriteGameMapData { // write binary Files.write(tempPath, MAGIC) - Files.write(tempPath, byteArrayOf(GameWorld.BITS)) + Files.write(tempPath, byteArrayOf(GameWorld.SIZEOF)) Files.write(tempPath, byteArrayOf(GameWorld.LAYERS)) Files.write(tempPath, byteArrayOf(BYTE_NULL)) Files.write(tempPath, byteArrayOf(BYTE_NULL)) @@ -44,15 +44,15 @@ object WriteGameMapData { Files.write(tempPath, toByteArray(map.spawnX)) Files.write(tempPath, toByteArray(map.spawnY)) map.layerTerrain.forEach( - {b -> Files.write(tempPath, byteArrayOf(b))}) + { b -> Files.write(tempPath, byteArrayOf(b)) }) map.layerWall.forEach( - {b -> Files.write(tempPath, byteArrayOf(b))}) + { b -> Files.write(tempPath, byteArrayOf(b)) }) map.terrainDamage.forEach( - {b -> Files.write(tempPath, byteArrayOf(b))}) + { b -> Files.write(tempPath, byteArrayOf(b)) }) map.wallDamage.forEach( - {b -> Files.write(tempPath, byteArrayOf(b))}) + { b -> Files.write(tempPath, byteArrayOf(b)) }) map.layerWire.forEach( - {b -> Files.write(tempPath, byteArrayOf(b))}) + { b -> Files.write(tempPath, byteArrayOf(b)) }) // replace savemeta with tempfile try { diff --git a/src/net/torvald/serialise/WriteMeta.kt b/src/net/torvald/serialise/WriteMeta.kt index 3b9f642ab..686587af5 100644 --- a/src/net/torvald/serialise/WriteMeta.kt +++ b/src/net/torvald/serialise/WriteMeta.kt @@ -3,6 +3,8 @@ package net.torvald.serialise import net.torvald.terrarum.mapgenerator.MapGenerator import net.torvald.terrarum.mapgenerator.RoguelikeRandomiser import net.torvald.terrarum.Terrarum +import net.torvald.terrarum.itemproperties.ItemPropCodex +import net.torvald.terrarum.itemproperties.MaterialPropCodex import net.torvald.terrarum.tileproperties.TilePropCodex import org.apache.commons.codec.digest.DigestUtils import java.io.FileInputStream @@ -43,8 +45,8 @@ object WriteMeta { // define files to get hash val fileArray: Array = arrayOf( File(TilePropCodex.CSV_PATH) - //, File(ItemPropCodex.CSV_PATH) - //, File(MaterialPropCodex.CSV_PATH) + , File(ItemPropCodex.CSV_PATH) + , File(MaterialPropCodex.CSV_PATH) //, ) diff --git a/src/net/torvald/terrarum/COPYING.md b/src/net/torvald/terrarum/COPYING.md index f5bcebe7b..9ae6a91bb 100644 --- a/src/net/torvald/terrarum/COPYING.md +++ b/src/net/torvald/terrarum/COPYING.md @@ -1,7 +1,9 @@ *Terrarum* by Torvald -Copyright (C) 2015-2016 Torvald. All rights reserved. -mailto: skyhi14 *64* __115875741922660__ *46* __6516589__ +Copyright (C) 2013-2016 Torvald. All rights reserved. +mailto: alswo9628 *at* __gmail__ *dot* __com__ + +You can use any assets (sprites, fonts and tiles) for your own goods (e.g. texture pack for Minecraft), provided that you gave necessary credit to this game and me. ---- diff --git a/src/net/torvald/terrarum/DefaultConfig.kt b/src/net/torvald/terrarum/DefaultConfig.kt index d8acdf035..4c5b2fdd9 100644 --- a/src/net/torvald/terrarum/DefaultConfig.kt +++ b/src/net/torvald/terrarum/DefaultConfig.kt @@ -34,7 +34,7 @@ object DefaultConfig { jsonObject.addProperty("joypadrstickx", 2) jsonObject.addProperty("joypadrsticky", 3) // logitech indices - // control-keyboard (Java key index. This is what Minecraft also uses) + // control-keyboard (Java key codes. This is what Minecraft also uses) jsonObject.addProperty("keyup", Key.E) jsonObject.addProperty("keyleft", Key.S) jsonObject.addProperty("keydown", Key.D) diff --git a/src/net/torvald/terrarum/StateInGame.kt b/src/net/torvald/terrarum/StateInGame.kt index 3c0a9f904..eb5bb8ce8 100644 --- a/src/net/torvald/terrarum/StateInGame.kt +++ b/src/net/torvald/terrarum/StateInGame.kt @@ -137,6 +137,13 @@ constructor() : BasicGameState() { // queue up game UIs // lesser UIs + // quick bar + uiAliases[UI_QUICK_BAR] = UIHandler(UIQuickBar()) + uiAliases[UI_QUICK_BAR]!!.isVisible = true + uiAliases[UI_QUICK_BAR]!!.setPosition(0, 0) + uiAliases[UI_QUICK_BAR]!!.UI.handler = uiAliases[UI_QUICK_BAR] + uiContainer.add(uiAliases[UI_QUICK_BAR]!!) + // pie menu uiAliases[UI_PIE_MENU] = UIHandler(UIPieMenu()) uiAliases[UI_PIE_MENU]!!.setPosition( (Terrarum.WIDTH - uiAliases[UI_PIE_MENU]!!.UI.width) / 2, @@ -284,65 +291,65 @@ constructor() : BasicGameState() { if (Terrarum.getConfigIntArray("keyquickselalt").contains(key) || key == Terrarum.getConfigInt("keyquicksel")) { - uiAliases[UI_PIE_MENU]!!.setAsOpening() - // TODO hide quick bar + uiAliases[UI_PIE_MENU]!!.setAsOpen() + uiAliases[UI_QUICK_BAR]!!.setAsClose() } - uiContainer.forEach { it.keyPressed(key, c) } + uiContainer.forEach { it.keyPressed(key, c) } // for KeyboardControlled UIcanvases } override fun keyReleased(key: Int, c: Char) { GameController.keyReleased(key, c) if (Terrarum.getConfigIntArray("keyquickselalt").contains(key) - || key == Terrarum.getConfigInt("keyquicksel")) { - uiAliases[UI_PIE_MENU]!!.setAsClosing() - // TODO show quick bar + || key == Terrarum.getConfigInt("keyquicksel")) { + uiAliases[UI_PIE_MENU]!!.setAsClose() + uiAliases[UI_QUICK_BAR]!!.setAsOpen() } - uiContainer.forEach { it.keyReleased(key, c) } + uiContainer.forEach { it.keyReleased(key, c) } // for KeyboardControlled UIcanvases } override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { GameController.mouseMoved(oldx, oldy, newx, newy) - uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } + uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases } override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { GameController.mouseDragged(oldx, oldy, newx, newy) - uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } + uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases } override fun mousePressed(button: Int, x: Int, y: Int) { GameController.mousePressed(button, x, y) - uiContainer.forEach { it.mousePressed(button, x, y) } + uiContainer.forEach { it.mousePressed(button, x, y) } // for MouseControlled UIcanvases } override fun mouseReleased(button: Int, x: Int, y: Int) { GameController.mouseReleased(button, x, y) - uiContainer.forEach { it.mouseReleased(button, x, y) } + uiContainer.forEach { it.mouseReleased(button, x, y) } // for MouseControlled UIcanvases } override fun mouseWheelMoved(change: Int) { GameController.mouseWheelMoved(change) - uiContainer.forEach { it.mouseWheelMoved(change) } + uiContainer.forEach { it.mouseWheelMoved(change) } // for MouseControlled UIcanvases } override fun controllerButtonPressed(controller: Int, button: Int) { GameController.controllerButtonPressed(controller, button) - uiContainer.forEach { it.controllerButtonPressed(controller, button) } + uiContainer.forEach { it.controllerButtonPressed(controller, button) } // for GamepadControlled UIcanvases } override fun controllerButtonReleased(controller: Int, button: Int) { GameController.controllerButtonReleased(controller, button) - uiContainer.forEach { it.controllerButtonReleased(controller, button) } + uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases } override fun getID(): Int = Terrarum.SCENE_ID_GAME @@ -352,7 +359,7 @@ constructor() : BasicGameState() { /** Send message to notifier UI and toggle the UI as opened. */ fun sendNotification(msg: Array) { (notifier.UI as Notification).sendNotification(Terrarum.appgc, UPDATE_DELTA, msg) - notifier.setAsOpening() + notifier.setAsOpen() } fun wakeDormantActors() { diff --git a/src/net/torvald/terrarum/StateMonitorCheck.kt b/src/net/torvald/terrarum/StateMonitorCheck.kt index bf9011f04..8596a3680 100644 --- a/src/net/torvald/terrarum/StateMonitorCheck.kt +++ b/src/net/torvald/terrarum/StateMonitorCheck.kt @@ -4,7 +4,7 @@ import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.ui.Typesetter import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UIHandler -import net.torvald.terrarum.ui.UITypable +import net.torvald.terrarum.ui.KeyboardControlled import org.newdawn.slick.Color import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics @@ -32,7 +32,7 @@ class StateMonitorCheck : BasicGameState() { } override fun keyPressed(key: Int, c: Char) { - //uiMonitorCheck.setAsClosing() + //uiMonitorCheck.setAsClose() } override fun getID(): Int = Terrarum.SCENE_ID_CONFIG_CALIBRATE diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index 268163705..b187d22c5 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -64,12 +64,11 @@ open class ActorWithBody : Actor(), Visible { get() = controllerVel!!.x internal set(value) { controllerVel!!.x = value } var walkY: Double - get() = controllerVel!!.x - internal set(value) { controllerVel!!.x = value } + get() = controllerVel!!.y + internal set(value) { controllerVel!!.y = value } /** * Physical properties. - * Values derived from ActorValue must be @Transient. */ var scale: Double get() = actorValue.getAsDouble(AVKey.SCALE) ?: 1.0 @@ -212,6 +211,8 @@ open class ActorWithBody : Actor(), Visible { var ccdCollided = false + var isWalking = false + init { // some initialiser goes here... } @@ -291,6 +292,7 @@ open class ActorWithBody : Actor(), Visible { * Actual physics thing (altering velocity) starts from here */ + // Combine velo and walk applyMovementVelocity() // applyBuoyancy() @@ -308,14 +310,13 @@ open class ActorWithBody : Actor(), Visible { // Set 'next' position (hitbox) from canonical and walking velocity setNewNextHitbox() - applyNormalForce() /** * solveCollision()? * If and only if: * This body is NON-STATIC and the other body is STATIC */ - setNewNextHitbox() displaceByCCD() + applyNormalForce() setHorizontalFriction() if (isPlayerNoClip) // or hanging on the rope, etc. @@ -394,21 +395,15 @@ open class ActorWithBody : Actor(), Visible { } } - /** - * FIXME the culprit! - * (5566 -> no collision but player does not "sink") - * (5567 -> collision) - * How to fix: - */ private fun applyNormalForce() { if (!isNoCollideWorld) { // axis Y. Use operand >= if (moveDelta.y >= 0.0) { // was moving downward? - if (isColliding(nextHitbox)) { + if (isColliding(nextHitbox)) { // FIXME if standing: standard box, if walking: top-squished box hitAndReflectY() grounded = true } - else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM)) { // actor hit something on its bottom + else if (isTouchingSide(nextHitbox, COLLIDING_BOTTOM) && !isColliding(nextHitbox)) { // actor hit something on its bottom grounded = true } else { // the actor is not grounded at all @@ -427,7 +422,7 @@ open class ActorWithBody : Actor(), Visible { if (isTouchingSide(nextHitbox, COLLIDING_LEFT) && isTouchingSide(nextHitbox, COLLIDING_RIGHT) && moveDelta.x != 0.0) { // check right and left // the actor is hitting the wall - hitAndReflectX() + //hitAndReflectX() } } } @@ -436,31 +431,32 @@ open class ActorWithBody : Actor(), Visible { * nextHitbox must NOT be altered before this method is called! */ private fun displaceByCCD() { + ccdCollided = false + if (!isNoCollideWorld){ + if (!isColliding(nextHitbox, COLLIDING_ALLSIDE)) + return + // do some CCD between hitbox and nextHitbox - val ccdBox = nextHitbox.clone()//.snapToPixel() - val ccdDelta = nextHitbox.toVector() to hitbox.toVector() - val deltaMax = Math.max(ccdDelta.x.abs(), ccdDelta.y.abs()) - // set ccdDelta so that CCD move a pixel per round - if (deltaMax > 1.0) - ccdDelta *= (1.0 / deltaMax) + val ccdDelta = (nextHitbox.toVector() - hitbox.toVector()) + if (ccdDelta.x != 0.0 || ccdDelta.y != 0.0) + ccdDelta.set(ccdDelta.setMagnitude(CCD_TICK)) + + //////TEST////// + ccdDelta.x = 0.0 + //////TEST////// + // Result: player CAN WALK with ccdDelta.x of zero, which means previous method is a shit. //println("deltaMax: $deltaMax") //println("ccdDelta: $ccdDelta") - while (!ccdDelta.isZero && isColliding(ccdBox, COLLIDING_ALLSIDE)) { - nextHitbox.translate(ccdDelta) + while (!ccdDelta.isZero && isColliding(nextHitbox, COLLIDING_ALLSIDE)) { + nextHitbox.translate(-ccdDelta) ccdCollided = true - - //ccdBox.reassign(nextHitbox).snapToPixel() - ccdBox.reassign(nextHitbox) } //println("ccdCollided: $ccdCollided") } - else { - ccdCollided = false - } } private fun hitAndReflectX() { @@ -625,7 +621,7 @@ open class ActorWithBody : Actor(), Visible { } return false*/ - return if (tyEnd <= 347) false else true + return if (tyEnd < 348) false else true } private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int { @@ -749,17 +745,23 @@ open class ActorWithBody : Actor(), Visible { /** - * Get highest friction value from feet tiles. + * Get highest friction value from surrounding tiles * @return */ internal val bodyFriction: Int get() { - /*var friction = 0 + var friction = 0 + val frictionCalcHitbox = if (isWalking) + Hitbox(nextHitbox.posX + 1.0, nextHitbox.posY + 1.0, + nextHitbox.width - 2.0, nextHitbox.height - 2.0) + else + nextHitbox.clone() // take highest value - val tilePosXStart = (hitbox.posX / TSIZE).roundInt() - val tilePosXEnd = (hitbox.hitboxEnd.x / TSIZE).roundInt() - val tilePosY = (hitbox.pointedY.plus(1) / TSIZE).roundInt() + val tilePosXStart = (frictionCalcHitbox.posX / TSIZE).floorInt() + val tilePosXEnd = (frictionCalcHitbox.hitboxEnd.x / TSIZE).floorInt() + val tilePosY = (frictionCalcHitbox.pointedY / TSIZE).floorInt() + for (x in tilePosXStart..tilePosXEnd) { val tile = world.getTileFromTerrain(x, tilePosY) val thisFriction = TilePropCodex.getProp(tile).friction @@ -767,16 +769,10 @@ open class ActorWithBody : Actor(), Visible { if (thisFriction > friction) friction = thisFriction } - return friction*/ - return 1 + return friction } fun Int.tileFrictionToMult(): Double = this / 16.0 - internal val feetFriction: Int - get() { - return 16 - } - /** * Get highest tile density from occupying tiles, fluid only */ diff --git a/src/net/torvald/terrarum/gameactors/PBSigrid.kt b/src/net/torvald/terrarum/gameactors/PBSigrid.kt index 144465ff0..bc880c826 100644 --- a/src/net/torvald/terrarum/gameactors/PBSigrid.kt +++ b/src/net/torvald/terrarum/gameactors/PBSigrid.kt @@ -54,7 +54,7 @@ object PBSigrid { p.actorValue[AVKey.INTELLIGENT] = true - p.actorValue[AVKey.LUMINOSITY] = 95487100 + p.actorValue[AVKey.LUMINOSITY] = 0//95487100 p.actorValue[AVKey.BASEDEFENCE] = 141 diff --git a/src/net/torvald/terrarum/gameactors/Player.kt b/src/net/torvald/terrarum/gameactors/Player.kt index 3e79a659b..04ee0530e 100644 --- a/src/net/torvald/terrarum/gameactors/Player.kt +++ b/src/net/torvald/terrarum/gameactors/Player.kt @@ -36,8 +36,10 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L /** how long the jump button has down, in frames */ internal var jumpCounter = 0 + internal var jumpAcc = 0.0 /** how long the walk button has down, in frames */ - internal var walkCounter = 0 + internal var walkCounterX = 0 + internal var walkCounterY = 0 @Transient private val MAX_JUMP_LENGTH = 17 // use 17; in internal frames private var readonly_totalX = 0.0 @@ -134,7 +136,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L * @author minjaesong */ private fun walkHorizontal(left: Boolean, absAxisVal: Float) { - if ((!walledLeft && left) || (!walledRight && !left)) { + if (true) {//(!walledLeft && left) || (!walledRight && !left)) { readonly_totalX = //veloX + /*actorValue.getAsDouble(AVKey.ACCEL)!! * actorValue.getAsDouble(AVKey.ACCELMULT)!! * @@ -145,7 +147,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L actorValue.getAsDouble(AVKey.ACCEL)!! * actorValue.getAsDouble(AVKey.ACCELMULT)!! * Math.sqrt(scale) * - applyVelo(walkCounter) * + applyVelo(walkCounterX) * (if (left) -1 else 1).toFloat() * absAxisVal @@ -153,7 +155,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkX += readonly_totalX walkX = absClamp(walkX, actorValue.getAsDouble(AVKey.SPEED)!! * actorValue.getAsDouble(AVKey.SPEEDMULT)!!) - walkCounter += 1 + walkCounterX += 1 // Heading flag if (left) @@ -162,6 +164,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkHeading = RIGHT // println("$walkCounter: ${readonly_totalX}") + isWalking = true } } @@ -176,13 +179,16 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L actorValue.getAsDouble(AVKey.ACCEL)!! * actorValue.getAsDouble(AVKey.ACCELMULT)!! * Math.sqrt(scale) * - applyVelo(walkCounter) * + applyVelo(walkCounterY) * (if (up) -1 else 1).toFloat() * absAxisVal - applyForce(Vector2(0.0, readonly_totalY)) + walkY += readonly_totalY + walkY = absClamp(walkY, actorValue.getAsDouble(AVKey.SPEED)!! * actorValue.getAsDouble(AVKey.SPEEDMULT)!!) - if (walkCounter <= WALK_FRAMES_TO_MAX_ACCEL) walkCounter += 1 + //if (walkCounterY <= WALK_FRAMES_TO_MAX_ACCEL) walkCounterY += 1 + + isWalking = true } private fun applyAccel(x: Int): Double { @@ -219,7 +225,8 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L //veloX = 0f - walkCounter = 0 + walkCounterX = 0 + isWalking = false } // stops; let the friction kick in by doing nothing to the velocity here @@ -245,7 +252,8 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L ///veloY = 0f - walkCounter = 0 + walkCounterY = 0 + isWalking = false } /** @@ -266,9 +274,11 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L var timedJumpCharge = init - init / len * jumpCounter if (timedJumpCharge < 0) timedJumpCharge = 0.0 - val jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value + jumpAcc = -pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value - applyForce(Vector2(0.0, -jumpAcc)) + applyForce(Vector2(0.0, jumpAcc)) + + if (jumpAcc != 0.0) println(jumpAcc) } // for mob ai: @@ -359,7 +369,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkHorizontal(true, AXIS_POSMAX) prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT) } // ↓F, ↓S - else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT) && isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) { + /*else if (isFuncDown(input, EnumKeyFunc.MOVE_LEFT) && isFuncDown(input, EnumKeyFunc.MOVE_RIGHT)) { if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) { walkHorizontal(false, AXIS_POSMAX) prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_RIGHT) @@ -367,7 +377,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkHorizontal(true, AXIS_POSMAX) prevHMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT) } - } + }*/ } /** @@ -388,7 +398,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkVertical(true, AXIS_POSMAX) prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP) } // ↓E, ↓D - else if (isFuncDown(input, EnumKeyFunc.MOVE_UP) && isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) { + /*else if (isFuncDown(input, EnumKeyFunc.MOVE_UP) && isFuncDown(input, EnumKeyFunc.MOVE_DOWN)) { if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) { walkVertical(false, AXIS_POSMAX) prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_DOWN) @@ -396,7 +406,7 @@ class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, L walkVertical(true, AXIS_POSMAX) prevVMoveKey = KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP) } - } + }*/ } } diff --git a/src/net/torvald/terrarum/gamecontroller/KeyMap.kt b/src/net/torvald/terrarum/gamecontroller/KeyMap.kt index d20e452ca..6b03c6b0e 100644 --- a/src/net/torvald/terrarum/gamecontroller/KeyMap.kt +++ b/src/net/torvald/terrarum/gamecontroller/KeyMap.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.gamecontroller +import net.torvald.terrarum.Terrarum import java.util.Hashtable /** @@ -10,11 +11,11 @@ object KeyMap { var map_code = Hashtable() init { - map_code.put(EnumKeyFunc.MOVE_UP, Key.E) - map_code.put(EnumKeyFunc.MOVE_LEFT, Key.S) - map_code.put(EnumKeyFunc.MOVE_DOWN, Key.D) - map_code.put(EnumKeyFunc.MOVE_RIGHT, Key.F) - map_code.put(EnumKeyFunc.JUMP, Key.SPACE) + map_code.put(EnumKeyFunc.MOVE_UP, Terrarum.getConfigInt("keyup")) + map_code.put(EnumKeyFunc.MOVE_LEFT, Terrarum.getConfigInt("keyleft")) + map_code.put(EnumKeyFunc.MOVE_DOWN, Terrarum.getConfigInt("keydown")) + map_code.put(EnumKeyFunc.MOVE_RIGHT, Terrarum.getConfigInt("keyright")) + map_code.put(EnumKeyFunc.JUMP, Terrarum.getConfigInt("keyjump")) map_code.put(EnumKeyFunc.UI_CONSOLE, Key.GRAVE) map_code.put(EnumKeyFunc.UI_BASIC_INFO, Key.F3) } @@ -23,7 +24,7 @@ object KeyMap { return map_code[fn]!! } - operator fun set(func: EnumKeyFunc, key: Int) { + fun set(func: EnumKeyFunc, key: Int) { map_code.put(func, key) } diff --git a/src/net/torvald/terrarum/gamemap/GameWorld.kt b/src/net/torvald/terrarum/gamemap/GameWorld.kt index 3e9327235..ebcc638d2 100644 --- a/src/net/torvald/terrarum/gamemap/GameWorld.kt +++ b/src/net/torvald/terrarum/gamemap/GameWorld.kt @@ -219,7 +219,7 @@ constructor(//properties @Transient val WIRE = 2 @Transient val TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE - @Transient val BITS: Byte = 1 // 1 for Byte, 2 for Char, 4 for Int, 8 for Long + @Transient val SIZEOF: Byte = MapLayer.SIZEOF @Transient val LAYERS: Byte = 4 // terrain, wall (terrainDamage + wallDamage), wire } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/gamemap/MapLayer.kt b/src/net/torvald/terrarum/gamemap/MapLayer.kt index 3e6469436..ae6599e4c 100644 --- a/src/net/torvald/terrarum/gamemap/MapLayer.kt +++ b/src/net/torvald/terrarum/gamemap/MapLayer.kt @@ -51,6 +51,7 @@ class MapLayer(var width: Int, var height: Int) : Iterable { companion object { @Transient const val RANGE = 256 + @Transient const val SIZEOF: Byte = 1 // 1 for 8-bit, 2 for 16-bit, ... } } diff --git a/src/net/torvald/terrarum/gamemap/PairedMapLayer.kt b/src/net/torvald/terrarum/gamemap/PairedMapLayer.kt index f12973e8f..30a82308d 100644 --- a/src/net/torvald/terrarum/gamemap/PairedMapLayer.kt +++ b/src/net/torvald/terrarum/gamemap/PairedMapLayer.kt @@ -80,7 +80,7 @@ class PairedMapLayer(width: Int, var height: Int) : Iterable { } companion object { - @Transient const val RANGE = 16 + @Transient const val SIZEOF: Byte = 1 // 1 for 8-bit, 2 for 16-bit, ... } } diff --git a/src/net/torvald/terrarum/mapdrawer/MapDrawer.kt b/src/net/torvald/terrarum/mapdrawer/MapDrawer.kt index b387be6ea..1e3369187 100644 --- a/src/net/torvald/terrarum/mapdrawer/MapDrawer.kt +++ b/src/net/torvald/terrarum/mapdrawer/MapDrawer.kt @@ -5,6 +5,7 @@ import net.torvald.terrarum.Terrarum import net.torvald.terrarum.tileproperties.TileNameCode import net.torvald.terrarum.tilestats.TileStats import com.jme3.math.FastMath +import net.torvald.colourutil.ColourTemp import org.newdawn.slick.* /** @@ -13,14 +14,13 @@ import org.newdawn.slick.* object MapDrawer { const val TILE_SIZE = 16 - private var envOverlayColourmap: Image = Image("./res/graphics/colourmap/black_body_col_1000_40000_K.png") - private val ENV_COLTEMP_LOWEST = 5500 private val ENV_COLTEMP_HIGHEST = 7500 val ENV_COLTEMP_NOON = 6500 // 6500 == sRGB White == untouched! - private var colTemp: Int = 0 + var colTemp: Int = 0 + private set private val TILES_COLD = intArrayOf( TileNameCode.ICE_MAGICAL @@ -49,7 +49,7 @@ object MapDrawer { colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON val zoom = Terrarum.ingame.screenZoom - g.color = getColourFromMap(colTemp) + g.color = ColourTemp(colTemp) //g.color = getColourFromMap(3022) g.fillRect( MapCamera.cameraX * zoom, @@ -70,18 +70,4 @@ object MapDrawer { return Math.round((ENV_COLTEMP_HIGHEST - ENV_COLTEMP_LOWEST) / 2 * FastMath.clamp(x, -1f, 1f) + colTempMedian) } - - fun getColourFromMap(K: Int): Color { - return envOverlayColourmap.getColor(colTempToImagePos(K), 0) - } - - private fun colTempToImagePos(K: Int): Int { - if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)") - return (K - 1000) / 10 - } - - @JvmStatic - fun getColTemp(): Int { - return colTemp - } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 1daeb3da8..5e782bf04 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -19,7 +19,7 @@ import java.util.* /** * Created by minjaesong on 16-03-14. */ -class BasicDebugInfoWindow:UICanvas { +class BasicDebugInfoWindow : UICanvas { override var width: Int = Terrarum.WIDTH override var height: Int = Terrarum.HEIGHT @@ -101,6 +101,8 @@ class BasicDebugInfoWindow:UICanvas { printLine(g, 5, "grounded $ccG${player.grounded}") printLine(g, 6, "noClip $ccG${player.noClip}") + printLine(g, 7, "jump $ccG${player.jumpAcc}") + val lightVal: String val mtX = mouseTileX.toString() val mtY = mouseTileY.toString() @@ -114,7 +116,7 @@ class BasicDebugInfoWindow:UICanvas { rawR.toString() + " " + rawG.toString() + " " + rawB.toString() + ")" - printLine(g, 7, "light@cursor $ccG$lightVal") + printLine(g, 8, "light@cursor $ccG$lightVal") val tileNo: String val tileNumRaw = Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1 @@ -122,18 +124,22 @@ class BasicDebugInfoWindow:UICanvas { val tiledmg = tileNumRaw % PairedMapLayer.RANGE tileNo = if (tileNumRaw == -1) "—" else "$tilenum:$tiledmg" - printLine(g, 8, "tile@cursor $ccG$tileNo ($mtX, $mtY)") + printLine(g, 9, "tile@cursor $ccG$tileNo ($mtX, $mtY)") /** * Second column */ printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested) - printLineColumn(g, 2, 2, "Env colour temp $ccG" + MapDrawer.getColTemp()) + printLineColumn(g, 2, 2, "Env colour temp $ccG" + MapDrawer.colTemp) printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame.world.time.elapsedSeconds()}" + " (${Terrarum.ingame.world.time.getFormattedTime()})") printLineColumn(g, 2, 6, "Mass $ccG${player.mass}") + printLineColumn(g, 2, 7, "p_WalkX $ccG${player.walkX}") + printLineColumn(g, 2, 8, "p_WalkY $ccG${player.walkY}") + + drawHistogram(g, LightmapRenderer.histogram, Terrarum.WIDTH - histogramW - 30, Terrarum.HEIGHT - histogramH - 30 @@ -220,7 +226,7 @@ class BasicDebugInfoWindow:UICanvas { private fun line(i: Int): Float = i * 10f - private fun column(i: Int): Float = 250f * (i - 1) + private fun column(i: Int): Float = 300f * (i - 1) override fun doOpening(gc: GameContainer, delta: Int) { diff --git a/src/net/torvald/terrarum/ui/ConsoleWindow.kt b/src/net/torvald/terrarum/ui/ConsoleWindow.kt index 11badfa5a..d25f7848c 100644 --- a/src/net/torvald/terrarum/ui/ConsoleWindow.kt +++ b/src/net/torvald/terrarum/ui/ConsoleWindow.kt @@ -13,7 +13,7 @@ import org.newdawn.slick.Input /** * Created by minjaesong on 15-12-31. */ -class ConsoleWindow : UICanvas, UITypable { +class ConsoleWindow : UICanvas, KeyboardControlled { internal var UIColour = Color(0xCC000000.toInt()) diff --git a/src/net/torvald/terrarum/ui/GamepadControlled.kt b/src/net/torvald/terrarum/ui/GamepadControlled.kt new file mode 100644 index 000000000..1ae4e8030 --- /dev/null +++ b/src/net/torvald/terrarum/ui/GamepadControlled.kt @@ -0,0 +1,12 @@ +package net.torvald.terrarum.ui + +/** + * Button pressing only. If you want stick-controls, use processInput() + * + * Created by minjaesong on 16-07-21. + */ +interface GamepadControlled { + fun controllerButtonPressed(controller: Int, button: Int) + + fun controllerButtonReleased(controller: Int, button: Int) +} \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt b/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt index 3f98ad59d..8576315d7 100644 --- a/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt +++ b/src/net/torvald/terrarum/ui/ItemSlotImageBuilder.kt @@ -23,10 +23,16 @@ object ItemSlotImageBuilder { SpriteSheet("./res/graphics/fonts/numeric_small.png", 5, 8), '0' ) - private val slotImage = Image("./res/graphics/gui/quickbar/item_slot.png") + val slotImage = Image("./res/graphics/gui/quickbar/item_slot.png") // must have same w/h as slotLarge + val slotLarge = Image("./res/graphics/gui/quickbar/item_slot_large.png") private val canvas = Image(slotImage.width, slotImage.height) + private val canvasLarge = Image(slotLarge.width, slotLarge.height) + + val slotImageSize = slotImage.width fun produce(color: Int, number: Int = -1): Image { + canvas.graphics.clear() + if (color == COLOR_BLACK) canvas.graphics.drawImage(slotImage, 0f, 0f, colourBlack) else if (color == COLOR_WHITE) @@ -41,12 +47,38 @@ object ItemSlotImageBuilder { canvas.graphics.color = colourBlack canvas.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(), - slotImage.width - 6f, - slotImage.height - 10f + slotImage.width - 10f, + slotImage.height - 13f ) } + return canvas } + fun produceLarge(color: Int, number: Int = -1): Image { + canvasLarge.graphics.clear() + + if (color == COLOR_BLACK) + canvasLarge.graphics.drawImage(slotLarge, 0f, 0f, colourBlack) + else if (color == COLOR_WHITE) + canvasLarge.graphics.drawImage(slotLarge, 0f, 0f, colourWhite) + + if (number >= 0) { + canvasLarge.graphics.font = numberFont + + if (color == COLOR_BLACK) + canvasLarge.graphics.color = colourWhite + else if (color == COLOR_WHITE) + canvasLarge.graphics.color = colourBlack + + canvasLarge.graphics.drawString(number.mod(UIQuickBar.SLOT_COUNT).toString(), + slotLarge.width - 10f, + slotLarge.height - 13f + ) + } + + return canvasLarge + } + } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UITypable.kt b/src/net/torvald/terrarum/ui/KeyboardControlled.kt similarity index 83% rename from src/net/torvald/terrarum/ui/UITypable.kt rename to src/net/torvald/terrarum/ui/KeyboardControlled.kt index 6502f0cf0..6de72d6e8 100644 --- a/src/net/torvald/terrarum/ui/UITypable.kt +++ b/src/net/torvald/terrarum/ui/KeyboardControlled.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.ui /** * Created by minjaesong on 16-03-06. */ -interface UITypable { +interface KeyboardControlled { fun keyPressed(key: Int, c: Char) fun keyReleased(key: Int, c: Char) diff --git a/src/net/torvald/terrarum/ui/UIClickable.kt b/src/net/torvald/terrarum/ui/MouseControlled.kt similarity index 69% rename from src/net/torvald/terrarum/ui/UIClickable.kt rename to src/net/torvald/terrarum/ui/MouseControlled.kt index a41040e5c..181d6a3b5 100644 --- a/src/net/torvald/terrarum/ui/UIClickable.kt +++ b/src/net/torvald/terrarum/ui/MouseControlled.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum.ui /** * Created by minjaesong on 16-03-06. */ -interface UIClickable { +interface MouseControlled { fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) @@ -13,9 +13,4 @@ interface UIClickable { fun mouseReleased(button: Int, x: Int, y: Int) fun mouseWheelMoved(change: Int) - - fun controllerButtonPressed(controller: Int, button: Int) - - fun controllerButtonReleased(controller: Int, button: Int) - } \ No newline at end of file diff --git a/src/net/torvald/terrarum/ui/UICanvas.kt b/src/net/torvald/terrarum/ui/UICanvas.kt index ae112a5ff..fab7feb38 100644 --- a/src/net/torvald/terrarum/ui/UICanvas.kt +++ b/src/net/torvald/terrarum/ui/UICanvas.kt @@ -11,14 +11,18 @@ interface UICanvas { var width: Int var height: Int + + var handler: UIHandler? + /** * In milliseconds */ var openCloseTime: Int + /** + * Usage: get() = handler!!.openCloseCounter + */ var openCloseTimer: Int - var handler: UIHandler? - fun update(gc: GameContainer, delta: Int) fun render(gc: GameContainer, g: Graphics) diff --git a/src/net/torvald/terrarum/ui/UIHandler.kt b/src/net/torvald/terrarum/ui/UIHandler.kt index 34c5bd79c..3713549d2 100644 --- a/src/net/torvald/terrarum/ui/UIHandler.kt +++ b/src/net/torvald/terrarum/ui/UIHandler.kt @@ -3,6 +3,7 @@ package net.torvald.terrarum.ui import net.torvald.terrarum.mapdrawer.MapCamera import net.torvald.terrarum.Terrarum import com.jme3.math.FastMath +import org.lwjgl.opengl.GL11 import org.newdawn.slick.* import org.newdawn.slick.state.StateBasedGame @@ -44,22 +45,25 @@ constructor(val UI: UICanvas) { set(value) { if (alwaysVisible) throw RuntimeException("[UIHandler] Tried to 'set visibility of' constant UI") - - field = value + if (value == true) { + isOpened = true + field = value + } + else { + isOpened = false + field = value + } } var opacity = 1f var scale = 1f - var openCloseCounter = 0 + var openCloseCounter: Int = 0 init { println("[UIHandler] Creating UI '${UI.javaClass.simpleName}'") - UIDrawnCanvas = Image( - //FastMath.nearestPowerOfTwo(UI.width), FastMath.nearestPowerOfTwo(UI.height)) - UI.width, UI.height) - UIDrawnCanvas.filter = Image.FILTER_LINEAR + UIDrawnCanvas = Image(UI.width, UI.height) UIGraphicInstance = UIDrawnCanvas.graphics } @@ -84,6 +88,7 @@ constructor(val UI: UICanvas) { else { UI.endOpening(gc, delta) isOpening = false + isClosing = false isOpened = true openCloseCounter = 0 } @@ -101,6 +106,7 @@ constructor(val UI: UICanvas) { else { UI.endClosing(gc, delta) isClosing = false + isOpening = false isOpened = false isVisible = false openCloseCounter = 0 @@ -113,8 +119,6 @@ constructor(val UI: UICanvas) { UIGraphicInstance.clear() UIGraphicInstance.font = Terrarum.gameFont - UIGraphicInstance.setAntiAlias(true) - UI.render(gc, UIGraphicInstance) if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) { ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale), @@ -151,39 +155,47 @@ constructor(val UI: UICanvas) { /** * Send OPEN signal to the attached UI. */ - fun setAsOpening() { + fun setAsOpen() { if (alwaysVisible) { throw RuntimeException("[UIHandler] Tried to 'open' constant UI") } - if (!isOpened && !isVisible) { + if (!isOpened && !isOpening) { isOpened = false isOpening = true + isClosing = false + isVisible = true } } /** * Send CLOSE signal to the attached UI. */ - fun setAsClosing() { + fun setAsClose() { if (alwaysVisible) { throw RuntimeException("[UIHandler] Tried to 'close' constant UI") } - isOpened = false - isClosing = true + if ((isOpening || isOpened) && !isClosing && isVisible) { + isOpened = false + isClosing = true + isOpening = false + } } + val isClosed: Boolean + get() = !isOpened && !isClosing && !isOpening + fun toggleOpening() { if (alwaysVisible) { throw RuntimeException("[UIHandler] Tried to 'toggle opening of' constant UI") } if (isVisible) { if (!isClosing) { - setAsClosing() + setAsClose() } } else { if (!isOpening) { - setAsOpening() + setAsOpen() } } } @@ -195,55 +207,55 @@ constructor(val UI: UICanvas) { } fun keyPressed(key: Int, c: Char) { - if (isVisible && UI is UITypable) { + if (isVisible && UI is KeyboardControlled) { UI.keyPressed(key, c) } } fun keyReleased(key: Int, c: Char) { - if (isVisible && UI is UITypable) { + if (isVisible && UI is KeyboardControlled) { UI.keyReleased(key, c) } } fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is MouseControlled) { UI.mouseMoved(oldx, oldy, newx, newy) } } fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is MouseControlled) { UI.mouseDragged(oldx, oldy, newx, newy) } } fun mousePressed(button: Int, x: Int, y: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is MouseControlled) { UI.mousePressed(button, x, y) } } fun mouseReleased(button: Int, x: Int, y: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is MouseControlled) { UI.mouseReleased(button, x, y) } } fun mouseWheelMoved(change: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is MouseControlled) { UI.mouseWheelMoved(change) } } fun controllerButtonPressed(controller: Int, button: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is GamepadControlled) { UI.controllerButtonPressed(controller, button) } } fun controllerButtonReleased(controller: Int, button: Int) { - if (isVisible && UI is UIClickable) { + if (isVisible && UI is GamepadControlled) { UI.controllerButtonReleased(controller, button) } } diff --git a/src/net/torvald/terrarum/ui/UIPieMenu.kt b/src/net/torvald/terrarum/ui/UIPieMenu.kt index 03c241a86..16686eba8 100644 --- a/src/net/torvald/terrarum/ui/UIPieMenu.kt +++ b/src/net/torvald/terrarum/ui/UIPieMenu.kt @@ -13,29 +13,31 @@ import org.newdawn.slick.Input * Created by minjaesong on 16-07-20. */ class UIPieMenu : UICanvas { - private val cellSize = 32 + private val cellSize = UIQuickBar.CELL_SIZE private val slotCount = UIQuickBar.SLOT_COUNT - private val roundRectRadius = 6 + private val slotDistanceFromCentre = cellSize * 2.7 override var width: Int = cellSize * 7 override var height: Int = width + + override var handler: UIHandler? = null + /** * In milliseconds */ override var openCloseTime: Int = 160 override var openCloseTimer: Int = 0 - - override var handler: UIHandler? = null + get() = handler!!.openCloseCounter private val smallenSize = 0.93f - var menuSelection: Int = -1 + var selection: Int = -1 override fun update(gc: GameContainer, delta: Int) { - if (menuSelection >= 0) + if (selection >= 0) Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = - menuSelection % quickbarSlots + selection % slotCount } override fun render(gc: GameContainer, g: Graphics) { @@ -45,17 +47,19 @@ class UIPieMenu : UICanvas { for (i in 0..slotCount - 1) { // set position val angle = Math.PI * 2.0 * (i.toDouble() / slotCount) + Math.PI // 180 deg monitor-wise - val slotCentrePoint = Vector2(0.0, cellSize * 3.0).setDirection(angle) + centrePoint + val slotCentrePoint = Vector2(0.0, slotDistanceFromCentre.toDouble()).setDirection(angle) + centrePoint // draw cells - g.color = if (menuSelection == i) Color(0xC0C0C0) else Color(0x404040) - g.drawImage(ItemSlotImageBuilder.produce( - if (menuSelection == i) - ItemSlotImageBuilder.COLOR_WHITE + val color = if (i == selection) + ItemSlotImageBuilder.COLOR_WHITE + else + ItemSlotImageBuilder.COLOR_BLACK + + g.drawImage( + if (i == selection) + ItemSlotImageBuilder.produceLarge(color, i + 1) else - ItemSlotImageBuilder.COLOR_BLACK, - i + 1 - ), + ItemSlotImageBuilder.produce(color, i + 1), slotCentrePoint.x.toFloat() - (cellSize / 2f), slotCentrePoint.y.toFloat() - (cellSize / 2f) ) @@ -70,38 +74,29 @@ class UIPieMenu : UICanvas { val centre = Vector2(Terrarum.WIDTH / 2.0, Terrarum.HEIGHT / 2.0) val deg = (centre - cursorPos).direction.toFloat() - menuSelection = Math.round(deg * slotCount / FastMath.TWO_PI) - if (menuSelection < 0) menuSelection += 10 + selection = Math.round(deg * slotCount / FastMath.TWO_PI) + if (selection < 0) selection += 10 + + // TODO add gamepad support } } override fun doOpening(gc: GameContainer, delta: Int) { - if (openCloseTimer < openCloseTime) { - openCloseTimer += delta - - handler!!.opacity = openCloseTimer.toFloat() / openCloseTime - handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) - } + handler!!.opacity = openCloseTimer.toFloat() / openCloseTime + handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) } override fun doClosing(gc: GameContainer, delta: Int) { - if (openCloseTimer < openCloseTime) { - openCloseTimer += delta - handler!!.isOpened = false - - handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime - handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) - } + handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime + handler!!.scale = smallenSize + (1f.minus(smallenSize) * handler!!.opacity) } override fun endOpening(gc: GameContainer, delta: Int) { - openCloseTimer = 0 handler!!.opacity = 1f handler!!.scale = 1f } override fun endClosing(gc: GameContainer, delta: Int) { - openCloseTimer = 0 handler!!.opacity = 0f handler!!.scale = 1f } diff --git a/src/net/torvald/terrarum/ui/UIQuickBar.kt b/src/net/torvald/terrarum/ui/UIQuickBar.kt index 4cf71897c..19753a635 100644 --- a/src/net/torvald/terrarum/ui/UIQuickBar.kt +++ b/src/net/torvald/terrarum/ui/UIQuickBar.kt @@ -1,5 +1,7 @@ package net.torvald.terrarum.ui +import net.torvald.terrarum.Terrarum +import net.torvald.terrarum.gameactors.AVKey import org.newdawn.slick.GameContainer import org.newdawn.slick.Graphics import org.newdawn.slick.Input @@ -7,58 +9,87 @@ import org.newdawn.slick.Input /** * Created by minjaesong on 16-07-20. */ -class UIQuickBar : UICanvas { - override var width: Int - get() = throw UnsupportedOperationException() - set(value) { - } - override var height: Int - get() = throw UnsupportedOperationException() - set(value) { - } +class UIQuickBar : UICanvas, MouseControlled { + private val gutter = 8 + override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT + override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.gameFont.lineHeight /** * In milliseconds */ - override var openCloseTime: Int - get() = throw UnsupportedOperationException() - set(value) { - } - override var openCloseTimer: Int - get() = throw UnsupportedOperationException() - set(value) { - } + override var openCloseTime: Int = 160 + override var openCloseTimer: Int = 0 + + private val startPointX = ItemSlotImageBuilder.slotLarge.width / 2 + private val startPointY = ItemSlotImageBuilder.slotLarge.height / 2 override var handler: UIHandler? = null + private var selection: Int + get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey._PLAYER_QUICKBARSEL)!! + set(value) { Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = value } + override fun update(gc: GameContainer, delta: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } override fun render(gc: GameContainer, g: Graphics) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + for (i in 0..SLOT_COUNT - 1) { + val color = if (i == selection) + ItemSlotImageBuilder.COLOR_WHITE + else + ItemSlotImageBuilder.COLOR_BLACK + + // draw slots + g.drawImage( + if (i == selection) + ItemSlotImageBuilder.produceLarge(color, i + 1) + else + ItemSlotImageBuilder.produce(color, i + 1), + startPointX + (CELL_SIZE + gutter).times(i).toFloat(), + startPointY.toFloat() + ) + // draw items + + } } override fun processInput(input: Input) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. } override fun doOpening(gc: GameContainer, delta: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + handler!!.opacity = openCloseTimer.toFloat() / openCloseTime } override fun doClosing(gc: GameContainer, delta: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + handler!!.opacity = (openCloseTime - openCloseTimer.toFloat()) / openCloseTime } override fun endOpening(gc: GameContainer, delta: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + handler!!.opacity = 1f } override fun endClosing(gc: GameContainer, delta: Int) { - throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates. + handler!!.opacity = 0f + } + + override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { + } + + override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { + } + + override fun mousePressed(button: Int, x: Int, y: Int) { + } + + override fun mouseReleased(button: Int, x: Int, y: Int) { + } + + override fun mouseWheelMoved(change: Int) { + selection = selection.plus(if (change > 1) 1 else if (change < -1) -1 else 0).mod(SLOT_COUNT) + if (selection < 0) selection += SLOT_COUNT } companion object { const val SLOT_COUNT = 10 + const val CELL_SIZE = 32 } } \ No newline at end of file diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 5c0b4e3c8..952a48e1e 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -2,6 +2,7 @@ package net.torvald.terrarum.weather import com.jme3.math.FastMath import net.torvald.JsonFetcher +import net.torvald.colourutil.ColourUtil import net.torvald.random.HQRNG import net.torvald.terrarum.Terrarum import net.torvald.terrarum.gamemap.WorldTime @@ -93,24 +94,47 @@ object WeatherMixer { Light10B(getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec)) fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color { - val gradMapWidth = image.width - val phaseThis = Math.round( - timeInSec.toFloat() / WorldTime.DAY_LENGTH.toFloat() * gradMapWidth - ) - val phaseNext = (phaseThis + 1) % WorldTime.DAY_LENGTH val dataPointDistance = WorldTime.DAY_LENGTH / image.width + val phaseThis: Int = timeInSec / dataPointDistance // x-coord in gradmap + val phaseNext: Int = (phaseThis + 1) % image.width + val colourThis = image.getColor(phaseThis, row) val colourNext = image.getColor(phaseNext, row) // interpolate R, G and B - val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance - val retColour = Color(0) - retColour.r = FastMath.interpolateLinear(scale, colourThis.r, colourNext.r) - retColour.g = FastMath.interpolateLinear(scale, colourThis.g, colourNext.g) - retColour.b = FastMath.interpolateLinear(scale, colourThis.b, colourNext.b) + val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0] - return retColour + val r = interpolateLinear(scale, colourThis.red, colourNext.red) + val g = interpolateLinear(scale, colourThis.green, colourNext.green) + val b = interpolateLinear(scale, colourThis.blue, colourNext.blue) + + val newCol = ColourUtil.toSlickColor(r, g, b) + + /* // very nice monitor code + // 65 -> 66 | 300 | 19623 | RGB8(255, 0, 255) -[41%]-> RGB8(193, 97, 23) | * `230`40`160` + // ^ step |width| time | colour from scale colour to | output + if (dataPointDistance == 300) + println("$phaseThis -> $phaseNext | $dataPointDistance | $timeInSec" + + " | ${colourThis.toStringRGB()} -[${scale.times(100).toInt()}%]-> ${colourNext.toStringRGB()}" + + " | * `$r`$g`$b`")*/ + + return newCol + } + + fun Color.toStringRGB() = "RGB8(${this.red}, ${this.green}, ${this.blue})" + + fun interpolateLinear(scale: Float, startValue: Int, endValue: Int): Int { + if (startValue == endValue) { + return startValue + } + if (scale <= 0f) { + return startValue + } + if (scale >= 1f) { + return endValue + } + return Math.round((1f - scale) * startValue + scale * endValue) } fun getWeatherList(classification: String) = weatherList[classification]!! diff --git a/work_files/graphics/weathers/.gitattributes b/work_files/graphics/weathers/.gitattributes new file mode 100644 index 000000000..ca82ef549 --- /dev/null +++ b/work_files/graphics/weathers/.gitattributes @@ -0,0 +1 @@ +*.{psd,tga,ogg} filter=lfs diff=lfs merge=lfs -text \ No newline at end of file