Compare commits

...

38 Commits

Author SHA1 Message Date
minjaesong
4f8c3591c2 80 fps with unsafe access 2019-06-08 03:00:47 +09:00
minjaesong
a1d51d4028 just a fixme tag 2019-06-07 22:16:38 +09:00
minjaesong
593a528d32 apparently I'm fucking dumb 2019-06-07 10:37:04 +09:00
minjaesong
4a99722f71 i discovered something to be looked at 2019-06-07 10:23:22 +09:00
Minjae Song
97f8aa6e6e weather to not use expensive math; colormap now also holds cvec 2019-06-05 21:22:27 +09:00
Minjae Song
85ab1b823d mod metadata: changed versioning scheme 2019-06-05 21:22:27 +09:00
minjaesong
812e9e5b76 light parallel failed attempt 2019-06-05 21:04:01 +09:00
minjaesong
a87866438f debugwindow: correct ui count 2019-06-01 04:47:20 +09:00
minjaesong
c692928c1a lightmap is now array of array because debug-ability > slight framerate drop 2019-06-01 04:06:36 +09:00
minjaesong
5ff0c22b0f cvec: java to kotlin 2019-06-01 03:49:14 +09:00
minjaesong
eb1273c561 migration wip java 9 modularise 2019-06-01 03:25:20 +09:00
minjaesong
50c110f34b fixed using wrong type of exception 2019-06-01 02:06:07 +09:00
minjaesong
c180953d7d fixtures won't spawn when there's block or other fixtures 2019-05-31 22:57:20 +09:00
minjaesong
a1ac9b177a fixing "roundworld anomaly": some actors won't render 2019-05-31 04:10:00 +09:00
minjaesong
c50d07b541 wip debugging "roundworld anomaly" 2019-05-30 23:35:01 +09:00
minjaesong
56fdb2f556 contracted itemcount string 2019-05-30 21:36:02 +09:00
minjaesong
d2ddca85a6 font: hangul update 2019-05-30 14:10:09 +09:00
minjaesong
9aa002f4cc tiki torch correctly spawns; gotta check for collision 2019-05-29 23:20:39 +09:00
minjaesong
3a5fcb9ba0 added definition for fixture null blockbox 2019-05-28 23:57:51 +09:00
minjaesong
7d5a37cd6d tiki torch spawns but is not centred 2019-05-28 22:46:10 +09:00
minjaesong
75c79d8ca2 no secondary click; tiki torch kinda spawns? 2019-05-26 22:55:50 +09:00
minjaesong
0b7a3a5636 disposable singletons to an array in loader; single float for both notification and tooltip 2019-05-24 20:38:35 +09:00
Minjae Song
c5e0de2393 stupid gimp 2019-05-22 12:57:20 +09:00
Minjae Song
19fb5b1319 tileable message float ui 2019-05-22 12:51:01 +09:00
minjaesong
2fff2c24cf cherrypicked from the branch test-cvec-for-light 2019-05-21 17:50:54 +09:00
minjaesong
92d5cac2ff furred npc test might delete later 2019-05-20 12:07:01 +09:00
minjaesong
471b0c805d font: new redesigned hangul 2019-05-14 13:16:10 +09:00
minjaesong
16b7457d08 font: hangul redraw wip -- less "laundry line" 2019-05-12 23:52:27 +09:00
minjaesong
5c20ceeedc font: hangul redraw wip 2019-05-12 17:09:46 +09:00
minjaesong
49df5f9676 gradle script fix typo and add assertion jvm option 2019-05-12 01:03:35 +09:00
minjaesong
48ba273317 comment 2019-05-08 21:23:42 +09:00
minjaesong
52d6955ffc blocksdrawer now draws wire 2019-05-04 18:19:08 +09:00
minjaesong
08f07e566d adding missing resources/moving zip files to lfs 2019-05-04 04:11:33 +09:00
minjaesong
c423190725 block functions now share one centralised core function 2019-05-04 03:29:59 +09:00
minjaesong
61078cf5a8 debug info for upcoming wires 2019-05-02 00:56:25 +09:00
minjaesong
eafdeddc94 fixed a long bug where item would be used twice but discounted by only one on single click 2019-05-01 23:26:01 +09:00
minjaesong
9050378e81 more comments 2019-04-30 03:06:19 +09:00
minjaesong
fecb20da13 sortedarraylist update; physball breaks the actor render dunno why 2019-04-30 02:52:09 +09:00
209 changed files with 2190 additions and 2660 deletions

1
.gitattributes vendored
View File

@@ -4,3 +4,4 @@
*.gz filter=lfs diff=lfs merge=lfs -text *.gz filter=lfs diff=lfs merge=lfs -text
*.opus filter=lfs diff=lfs merge=lfs -text *.opus filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text *.pdf filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text

5
.idea/compiler.xml generated
View File

@@ -4,10 +4,7 @@
<annotationProcessing> <annotationProcessing>
<profile default="true" name="Default" enabled="true" /> <profile default="true" name="Default" enabled="true" />
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="10"> <bytecodeTargetLevel target="8" />
<module name="terrarum_main" target="11" />
<module name="terrarum_test" target="11" />
</bytecodeTargetLevel>
</component> </component>
<component name="JavacSettings"> <component name="JavacSettings">
<option name="PREFER_TARGET_JDK_COMPILER" value="false" /> <option name="PREFER_TARGET_JDK_COMPILER" value="false" />

View File

@@ -0,0 +1,23 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ArrayEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConstantConditionIf" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="CsvValidation" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ExplicitThis" enabled="false" level="INFORMATION" enabled_by_default="false" />
<inspection_tool class="KotlinDoubleNegation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NullChecksToSafeCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantCompanionReference" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantExplicitType" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantGetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantSetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantUnitExpression" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantUnitReturnType" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveCurlyBracesFromTemplate" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveEmptyPrimaryConstructor" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveEmptySecondaryConstructorBody" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveRedundantBackticks" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveRedundantQualifierName" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RemoveSingleExpressionStringTemplate" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

8
.idea/markdown-exported-files.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownExportedFiles">
<htmlFiles />
<imageFiles />
<otherFiles />
</component>
</project>

View File

@@ -1,3 +1,3 @@
<component name="MarkdownNavigator.ProfileManager"> <component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" /> <settings default="" pdf-export="" plain-text-search-scope="Project Files" />
</component> </component>

2
.idea/misc.xml generated
View File

@@ -38,7 +38,7 @@
<property name="caretWidth" class="java.lang.Integer" /> <property name="caretWidth" class="java.lang.Integer" />
</properties> </properties>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -98,6 +98,11 @@
"256";"256";"BLOCK_LANTERN_IRON_REGULAR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"FXTR";"0";"0";"0";"0";"0";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A" "256";"256";"BLOCK_LANTERN_IRON_REGULAR";"0.0312";"0.0312";"0.0312";"0.0312";"1";"N/A";"FXTR";"0";"0";"0";"0";"0";"0";"16";"1.0000";"0.6372";"0.0000";"0.0000";"N/A";"N/A"
"257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"0";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A" "257";"257";"BLOCK_SUNSTONE";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"ROCK";"1";"0";"0";"0";"2";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"0";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A" "258";"258";"BLOCK_DAYLIGHT_CAPACITOR";"0.1252";"0.1252";"0.1252";"0.1252";"1";"N/A";"GLAS";"1";"0";"0";"0";"3";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
"4091";"0";"ACTORBLOCK_NO_COLLISION";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
"4092";"0";"ACTORBLOCK_FULL_COLLISION";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
"4093";"0";"ACTORBLOCK_ALLOW_MOVE_DOWN";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"1";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
"4094";"0";"ACTORBLOCK_NO_PASS_RIGHT";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
"4095";"0";"ACTORBLOCK_NO_PASS_LEFT";"0.0";"0.0";"0.0";"0.0";"1";"1";"NULL";"0";"0";"0";"0";"0";"0";"0";"0.0";"0.0";"0.0";"0.0";"N/A";"N/A"
"4096";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16" "4096";"0";"BLOCK_WATER";"0.1016";"0.0744";"0.0508";"0.0826";"100";"1000";"WATR";"0";"0";"0";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"005599A6";"16"
"4097";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32" "4097";"0";"BLOCK_LAVA";"0.9696";"0.9696";"0.9696";"0.9696";"100";"2600";"ROCK";"0";"0";"0";"0";"0";"0";"16";"0.7664";"0.2032";"0.0000";"0.0000";"FF4600E6";"32"
"-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A" "-1";"0";"BLOCK_NULL";"4.0000";"4.0000";"4.0000";"4.0000";"-1";"2600";"NULL";"0";"0";"1";"0";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"N/A";"N/A"
1 id drop name shdr shdg shdb shduv str dsty mate solid plat wall fall dlfn fv fr lumr lumg lumb lumuv colour vscs
98 256 256 BLOCK_LANTERN_IRON_REGULAR 0.0312 0.0312 0.0312 0.0312 1 N/A FXTR 0 0 0 0 0 0 16 1.0000 0.6372 0.0000 0.0000 N/A N/A
99 257 257 BLOCK_SUNSTONE 0.1252 0.1252 0.1252 0.1252 1 N/A ROCK 1 0 0 0 2 0 16 0.0000 0.0000 0.0000 0.0000 N/A N/A
100 258 258 BLOCK_DAYLIGHT_CAPACITOR 0.1252 0.1252 0.1252 0.1252 1 N/A GLAS 1 0 0 0 3 0 16 0.0000 0.0000 0.0000 0.0000 N/A N/A
101 4091 0 ACTORBLOCK_NO_COLLISION 0.0 0.0 0.0 0.0 1 1 NULL 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 N/A N/A
102 4092 0 ACTORBLOCK_FULL_COLLISION 0.0 0.0 0.0 0.0 1 1 NULL 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 N/A N/A
103 4093 0 ACTORBLOCK_ALLOW_MOVE_DOWN 0.0 0.0 0.0 0.0 1 1 NULL 0 1 0 0 0 0 0 0.0 0.0 0.0 0.0 N/A N/A
104 4094 0 ACTORBLOCK_NO_PASS_RIGHT 0.0 0.0 0.0 0.0 1 1 NULL 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 N/A N/A
105 4095 0 ACTORBLOCK_NO_PASS_LEFT 0.0 0.0 0.0 0.0 1 1 NULL 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 N/A N/A
106 4096 0 BLOCK_WATER 0.1016 0.0744 0.0508 0.0826 100 1000 WATR 0 0 0 0 0 0 16 0.0000 0.0000 0.0000 0.0000 005599A6 16
107 4097 0 BLOCK_LAVA 0.9696 0.9696 0.9696 0.9696 100 2600 ROCK 0 0 0 0 0 0 16 0.7664 0.2032 0.0000 0.0000 FF4600E6 32
108 -1 0 BLOCK_NULL 4.0000 4.0000 4.0000 4.0000 -1 2600 NULL 0 0 1 0 0 0 16 0.0000 0.0000 0.0000 0.0000 N/A N/A

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,5 +1,6 @@
"id";"classname" "id";"classname"
"8448";"net.torvald.terrarum.modulebasegame.items.PickaxeCopper" "8448";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper"
"8449";"net.torvald.terrarum.modulebasegame.items.PickaxeIron" "8449";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron"
"8450";"net.torvald.terrarum.modulebasegame.items.PickaxeSteel" "8450";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel"
"8466";"net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire" "8466";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire"
"8467";"net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester"
1 id classname
2 8448 net.torvald.terrarum.modulebasegame.items.PickaxeCopper net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper
3 8449 net.torvald.terrarum.modulebasegame.items.PickaxeIron net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron
4 8450 net.torvald.terrarum.modulebasegame.items.PickaxeSteel net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel
5 8466 net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire
6 8467 net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester

View File

@@ -1,4 +1,4 @@
import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.Material import net.torvald.terrarum.itemproperties.Material
import org.jetbrains.annotations.NotNull import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable import org.jetbrains.annotations.Nullable

View File

@@ -9,7 +9,7 @@ import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ActorWBMovable import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.itemproperties.Calculate import net.torvald.terrarum.itemproperties.Calculate
import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.Material import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
// following two are NOT UNUSED! // following two are NOT UNUSED!

View File

@@ -14,29 +14,25 @@ entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
# Release date in YYYY-MM-DD # Release date in YYYY-MM-DD
releasedate=2017-07-14 releasedate=2017-07-14
# The version, must be ^[0-9]+(\.[0-9]+)*$ in regex # The version, must follow Semver 2.0.0 scheme (https://semver.org/)
# e.g. 0.1 0.1.1347
# e.g. 1 1.0.58385.02
# e.g. 26558 0.0.0.0.0.1
version=0.2.0 version=0.2.0
# External JARs the module might use, separate multiple by semicolon (;) # External JARs the module might use, separate multiple by semicolon (;)
libraries= libraries=
# Modules that must be pre-installed, separate multiple by semicolon (;) # Modules that must be pre-installed, separate multiple by semicolon (;)
# Dependency syntax: "module name space allowed 444.44+" # Dependency syntax: "module's identification name (aka folder name) spaces allowed versionnumber"
# Version number: + means equal or higher, ! means this exact number, - denotes interval, * is wildcard # Versionnumber: + means equal or higher, ! means this exact number, - denotes interval, * is wildcard
# the default is equal or lower # the default is equal or lower. When fields are omitted (e.g. 3, 1.65), those fields will be ignored
# e.g. 1.4+ would allow 1.4, 0.6, 1.13, 1.42, 1.4.0, 1.4.4456 # e.g. 1.4+ would allow any future versions including 1.4.0; PATCH versions are ignored: 1.6.0, 1.13.0, 1.42.0, 1.4.0, 1.4.4456
# e.g. 10+.2 would allow 10.2, 10.1, 11.0 but would not allow any integer version (v10.0 != v10) # e.g. 4.2.25 would allow any future versions including 4.2.25; any older patches such as 4.2.17 will be disallowd
# e.g. 10.4! would allow 10.4, 9.4, 8.4, 7.4 # e.g. 10.4! is same as 10.4; would allow any PATCH versions as the numbers is ignored
# e.g. 10.3-11.4 would allow 10.3, 10.7, 10.12676, 11.0, 11.4 but not integer v11, 10.3.12 etc. # e.g. 10.3-11.4 would allow any versions between and including stated versions; PATCH versions are ignored: 10.3.0, 10.7.0, 10.3.676, 11.0.0, 11.4.9999
# e.g. 13!.5 would allow 13.0, 13.1, 13.2, 13.3, 13.4 and 13.5 # e.g. 10.3.2-10.4.5 would allow any versions between and including stated versions; PATCH versions are checked
# e.g. * would allow any version possible # e.g. 3!.1+ would allow any future MINOR versions including 3.1; PATH versions are ignored: 3.1, 3.4.22, 3.6, 3.1415926
# e.g. *.* would allow any version on that scheme # e.g. * would allow any version possible, as it won't check MINOR and PATCH versions
# e.g. *! would only allow all integer version
# NOTE: it's your responsibility that your mod's version scheme would not be a total mess! # NOTE: it's your responsibility that your mod's version scheme would not be a total mess!
# real world examples: # real world examples:
# BaseGame 1.0+; CommandLineRenewed 2!.0+; Basegame 1!.0+; ScreenRecorder *; MyScrRecHack 1.* # basegame 1.0.0+; command line refresh 2!.+; my_little_hack 0.*
# Can you decode them? This is for hypothetical screen recorder mod. # Can you decode them? This is for hypothetical screen recorder mod.
dependency= dependency=

View File

@@ -0,0 +1,40 @@
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
SPRITESHEET=mods/basegame/sprites/test_furry/furbud_
EXTENSION=.tga
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
CONFIG=SIZE 48,56;ORIGINX 29
# note to self: don't implement skeleton hierarchy: there's too many exceptions
# besides, you have "ALL" key.
! a skeleton also defines what body parts (images) be used.
! you can also write multiline text using reverse solidus; this is a feature of .properties
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
! are painted first, and any object that comes before it will paint over it. In other words, this list is
! first reversed then being iterated.
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
HAIR 0,32;HEAD 0,32;\
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
TAIL_0 0,13;TAIL_1 0,13
# skeleton_stand is used for testing purpose
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
ANIM_IDLE_1=TAIL_1 0,-999
ANIM_IDLE_2=TAIL_1 0,-999;\
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
HAIR_FORE 0,-1;HEADGEAR 0,-1

View File

@@ -0,0 +1,40 @@
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
SPRITESHEET=mods/basegame/sprites/test_furry/furbudglow_
EXTENSION=.tga
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
CONFIG=SIZE 48,56;ORIGINX 29
# note to self: don't implement skeleton hierarchy: there's too many exceptions
# besides, you have "ALL" key.
! a skeleton also defines what body parts (images) be used.
! you can also write multiline text using reverse solidus; this is a feature of .properties
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
! are painted first, and any object that comes before it will paint over it. In other words, this list is
! first reversed then being iterated.
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
HAIR 0,32;HEAD 0,32;\
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
TAIL_0 0,13;TAIL_1 0,13
# skeleton_stand is used for testing purpose
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
ANIM_IDLE_1=TAIL_1 0,-999
ANIM_IDLE_2=TAIL_1 0,-999;\
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
HAIR_FORE 0,-1;HEADGEAR 0,-1

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -2,6 +2,7 @@
SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/test_ SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/test_
EXTENSION=.tga EXTENSION=.tga
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1) # defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
CONFIG=SIZE 48,56;ORIGINX 29 CONFIG=SIZE 48,56;ORIGINX 29
# note to self: don't implement skeleton hierarchy: there's too many exceptions # note to self: don't implement skeleton hierarchy: there's too many exceptions
@@ -13,14 +14,15 @@ CONFIG=SIZE 48,56;ORIGINX 29
! are painted first, and any object that comes before it will paint over it. In other words, this list is ! are painted first, and any object that comes before it will paint over it. In other words, this list is
! first reversed then being iterated. ! first reversed then being iterated.
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations. ! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
# TODO right now accessory points are explicitly defined. Should they be injected in run-time? # TODO right now accessory points are explicitly defined. Should they be injected in run-time? In that case, certain names (e.g. headgear, held_item) will act as an anchor.
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\ SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\ ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
HAIR 0,32;HEAD 0,32;\ HAIR 0,32;HEAD 0,32;\
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\ UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\ FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\ FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12 ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
TAIL0 0,13
# skeleton_stand is used for testing purpose # skeleton_stand is used for testing purpose
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND

View File

@@ -40,6 +40,8 @@ uniform vec4 colourFilter = vec4(1, 1, 1, 1); // used by WALL to darken it
uniform ivec2 cameraTranslation = ivec2(0, 0); uniform ivec2 cameraTranslation = ivec2(0, 0);
uniform float drawBreakage = 1f; // set it to 0f to not draw breakage; non-zero value to draw it
ivec2 getTileXY(int tileNumber) { ivec2 getTileXY(int tileNumber) {
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x)); return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
@@ -108,7 +110,13 @@ void main() {
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend); vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
vec4 finalBreakage = texture2D(tilesAtlas, finalUVCoordForBreakage); vec4 finalBreakage;
if (drawBreakage == 0f) {
finalBreakage = vec4(0f);
}
else {
finalBreakage = texture2D(tilesAtlas, finalUVCoordForBreakage);
}
vec4 finalColor = vec4(mix(finalTile.rgb, finalBreakage.rgb, finalBreakage.a), finalTile.a); vec4 finalColor = vec4(mix(finalTile.rgb, finalBreakage.rgb, finalBreakage.a), finalTile.a);

View File

@@ -56,8 +56,9 @@ task gamedebug(type: JavaExec) {
classpath sourceSets.main.runtimeClasspath classpath sourceSets.main.runtimeClasspath
main = 'net.torvald.terrarum.AppLoader' main = 'net.torvald.terrarum.AppLoader'
group = "Application" group = "Application"
description = "Launches the game with debuy key." description = "Launches the game with the debug key."
args = ["isdev=true"] args = ["isdev=true"]
jvmArgs = ["-ea"]
} }
task spriteassembler(type: JavaExec) { task spriteassembler(type: JavaExec) {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/gdx-backend-lwjgl3.jar.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/gdx-controllers-lwjgl3.jar.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/gdx-nightly-20170610.zip.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/gdx-nightly-20181111.zip.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/gdx-nightly-20190112.zip.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/javadoc/lwjgl3-javadoc.zip LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/jogg-0.0.7.jar.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/jorbis-0.0.17.jar.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/libjinput.zip.gz LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/luaj-jse-3.0.2.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,367 +0,0 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.badlogic.gdx.backends.lwjgl.audio;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
import com.badlogic.gdx.Audio;
import com.badlogic.gdx.audio.AudioDevice;
import com.badlogic.gdx.audio.AudioRecorder;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.badlogic.gdx.utils.IntArray;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.LongMap;
import com.badlogic.gdx.utils.ObjectMap;
import static org.lwjgl.openal.AL10.*;
/** @author Nathan Sweet */
public class OpenALAudio implements Audio {
private final int deviceBufferSize;
private final int deviceBufferCount;
private IntArray idleSources, allSources;
private LongMap<Integer> soundIdToSource;
private IntMap<Long> sourceToSoundId;
private long nextSoundId = 0;
private ObjectMap<String, Class<? extends OpenALSound>> extensionToSoundClass = new ObjectMap();
private ObjectMap<String, Class<? extends OpenALMusic>> extensionToMusicClass = new ObjectMap();
private OpenALSound[] recentSounds;
private int mostRecetSound = -1;
Array<OpenALMusic> music = new Array(false, 1, OpenALMusic.class);
boolean noDevice = false;
public OpenALAudio () {
this(16, 9, 512);
}
public OpenALAudio (int simultaneousSources, int deviceBufferCount, int deviceBufferSize) {
this.deviceBufferSize = deviceBufferSize;
this.deviceBufferCount = deviceBufferCount;
registerSound("ogg", Ogg.Sound.class);
registerMusic("ogg", Ogg.Music.class);
registerSound("wav", Wav.Sound.class);
registerMusic("wav", Wav.Music.class);
registerSound("mp3", Mp3.Sound.class);
registerMusic("mp3", Mp3.Music.class);
try {
AL.create();
} catch (LWJGLException ex) {
noDevice = true;
ex.printStackTrace();
return;
}
allSources = new IntArray(false, simultaneousSources);
for (int i = 0; i < simultaneousSources; i++) {
int sourceID = alGenSources();
if (alGetError() != AL_NO_ERROR) break;
allSources.add(sourceID);
}
idleSources = new IntArray(allSources);
soundIdToSource = new LongMap<Integer>();
sourceToSoundId = new IntMap<Long>();
FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6)
.put(new float[] {0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 0.0f}).flip();
alListener(AL_ORIENTATION, orientation);
FloatBuffer velocity = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_VELOCITY, velocity);
FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f}).flip();
alListener(AL_POSITION, position);
recentSounds = new OpenALSound[simultaneousSources];
}
public void registerSound (String extension, Class<? extends OpenALSound> soundClass) {
if (extension == null) throw new IllegalArgumentException("extension cannot be null.");
if (soundClass == null) throw new IllegalArgumentException("soundClass cannot be null.");
extensionToSoundClass.put(extension, soundClass);
}
public void registerMusic (String extension, Class<? extends OpenALMusic> musicClass) {
if (extension == null) throw new IllegalArgumentException("extension cannot be null.");
if (musicClass == null) throw new IllegalArgumentException("musicClass cannot be null.");
extensionToMusicClass.put(extension, musicClass);
}
public OpenALSound newSound (FileHandle file) {
if (file == null) throw new IllegalArgumentException("file cannot be null.");
Class<? extends OpenALSound> soundClass = extensionToSoundClass.get(file.extension().toLowerCase());
if (soundClass == null) throw new GdxRuntimeException("Unknown file extension for sound: " + file);
try {
return soundClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file);
} catch (Exception ex) {
throw new GdxRuntimeException("Error creating sound " + soundClass.getName() + " for file: " + file, ex);
}
}
public OpenALMusic newMusic (FileHandle file) {
if (file == null) throw new IllegalArgumentException("file cannot be null.");
Class<? extends OpenALMusic> musicClass = extensionToMusicClass.get(file.extension().toLowerCase());
if (musicClass == null) throw new GdxRuntimeException("Unknown file extension for music: " + file);
try {
return musicClass.getConstructor(new Class[] {OpenALAudio.class, FileHandle.class}).newInstance(this, file);
} catch (Exception ex) {
throw new GdxRuntimeException("Error creating music " + musicClass.getName() + " for file: " + file, ex);
}
}
int obtainSource (boolean isMusic) {
if (noDevice) return 0;
for (int i = 0, n = idleSources.size; i < n; i++) {
int sourceId = idleSources.get(i);
int state = alGetSourcei(sourceId, AL_SOURCE_STATE);
if (state != AL_PLAYING && state != AL_PAUSED) {
if (isMusic) {
idleSources.removeIndex(i);
} else {
if (sourceToSoundId.containsKey(sourceId)) {
long soundId = sourceToSoundId.get(sourceId);
sourceToSoundId.remove(sourceId);
soundIdToSource.remove(soundId);
}
long soundId = nextSoundId++;
sourceToSoundId.put(sourceId, soundId);
soundIdToSource.put(soundId, sourceId);
}
alSourceStop(sourceId);
alSourcei(sourceId, AL_BUFFER, 0);
AL10.alSourcef(sourceId, AL10.AL_GAIN, 1);
AL10.alSourcef(sourceId, AL10.AL_PITCH, 1);
AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f);
return sourceId;
}
}
return -1;
}
void freeSource (int sourceID) {
if (noDevice) return;
alSourceStop(sourceID);
alSourcei(sourceID, AL_BUFFER, 0);
if (sourceToSoundId.containsKey(sourceID)) {
long soundId = sourceToSoundId.remove(sourceID);
soundIdToSource.remove(soundId);
}
idleSources.add(sourceID);
}
void freeBuffer (int bufferID) {
if (noDevice) return;
for (int i = 0, n = idleSources.size; i < n; i++) {
int sourceID = idleSources.get(i);
if (alGetSourcei(sourceID, AL_BUFFER) == bufferID) {
if (sourceToSoundId.containsKey(sourceID)) {
long soundId = sourceToSoundId.remove(sourceID);
soundIdToSource.remove(soundId);
}
alSourceStop(sourceID);
alSourcei(sourceID, AL_BUFFER, 0);
}
}
}
void stopSourcesWithBuffer (int bufferID) {
if (noDevice) return;
for (int i = 0, n = idleSources.size; i < n; i++) {
int sourceID = idleSources.get(i);
if (alGetSourcei(sourceID, AL_BUFFER) == bufferID) {
if (sourceToSoundId.containsKey(sourceID)) {
long soundId = sourceToSoundId.remove(sourceID);
soundIdToSource.remove(soundId);
}
alSourceStop(sourceID);
}
}
}
void pauseSourcesWithBuffer (int bufferID) {
if (noDevice) return;
for (int i = 0, n = idleSources.size; i < n; i++) {
int sourceID = idleSources.get(i);
if (alGetSourcei(sourceID, AL_BUFFER) == bufferID)
alSourcePause(sourceID);
}
}
void resumeSourcesWithBuffer (int bufferID) {
if (noDevice) return;
for (int i = 0, n = idleSources.size; i < n; i++) {
int sourceID = idleSources.get(i);
if (alGetSourcei(sourceID, AL_BUFFER) == bufferID) {
if (alGetSourcei(sourceID, AL_SOURCE_STATE) == AL_PAUSED)
alSourcePlay(sourceID);
}
}
}
public void update () {
if (noDevice) return;
for (int i = 0; i < music.size; i++)
music.items[i].update();
}
public long getSoundId (int sourceId) {
if (!sourceToSoundId.containsKey(sourceId)) return -1;
return sourceToSoundId.get(sourceId);
}
public void stopSound (long soundId) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
alSourceStop(sourceId);
}
public void pauseSound (long soundId) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
alSourcePause(sourceId);
}
public void resumeSound (long soundId) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
if (alGetSourcei(sourceId, AL_SOURCE_STATE) == AL_PAUSED)
alSourcePlay(sourceId);
}
public void setSoundGain (long soundId, float volume) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
AL10.alSourcef(sourceId, AL10.AL_GAIN, volume);
}
public void setSoundLooping (long soundId, boolean looping) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
alSourcei(sourceId, AL10.AL_LOOPING, looping ? AL10.AL_TRUE : AL10.AL_FALSE);
}
public void setSoundPitch (long soundId, float pitch) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
AL10.alSourcef(sourceId, AL10.AL_PITCH, pitch);
}
public void setSoundPan (long soundId, float pan, float volume) {
if (!soundIdToSource.containsKey(soundId)) return;
int sourceId = soundIdToSource.get(soundId);
AL10.alSource3f(sourceId, AL10.AL_POSITION, MathUtils.cos((pan - 1) * MathUtils.PI / 2), 0,
MathUtils.sin((pan + 1) * MathUtils.PI / 2));
AL10.alSourcef(sourceId, AL10.AL_GAIN, volume);
}
public void dispose () {
if (noDevice) return;
for (int i = 0, n = allSources.size; i < n; i++) {
int sourceID = allSources.get(i);
int state = alGetSourcei(sourceID, AL_SOURCE_STATE);
if (state != AL_STOPPED) alSourceStop(sourceID);
alDeleteSources(sourceID);
}
sourceToSoundId.clear();
soundIdToSource.clear();
AL.destroy();
while (AL.isCreated()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
}
public AudioDevice newAudioDevice (int sampleRate, final boolean isMono) {
if (noDevice) return new AudioDevice() {
@Override
public void writeSamples (float[] samples, int offset, int numSamples) {
}
@Override
public void writeSamples (short[] samples, int offset, int numSamples) {
}
@Override
public void setVolume (float volume) {
}
@Override
public boolean isMono () {
return isMono;
}
@Override
public int getLatency () {
return 0;
}
@Override
public void dispose () {
}
};
return new OpenALAudioDevice(this, sampleRate, isMono, deviceBufferSize, deviceBufferCount);
}
public AudioRecorder newAudioRecorder (int samplingRate, boolean isMono) {
if (noDevice) return new AudioRecorder() {
@Override
public void read (short[] samples, int offset, int numSamples) {
}
@Override
public void dispose () {
}
};
return new JavaSoundAudioRecorder(samplingRate, isMono);
}
/** Retains a list of the most recently played sounds and stops the sound played least recently if necessary for a new sound to
* play */
protected void retain (OpenALSound sound, boolean stop) {
// Move the pointer ahead and wrap
mostRecetSound++;
mostRecetSound %= recentSounds.length;
if (stop) {
// Stop the least recent sound (the one we are about to bump off the buffer)
if (recentSounds[mostRecetSound] != null) recentSounds[mostRecetSound].stop();
}
recentSounds[mostRecetSound] = sound;
}
/** Removes the disposed sound from the least recently played list */
public void forget (OpenALSound sound) {
for (int i = 0; i < recentSounds.length; i++) {
if (recentSounds[i] == sound) recentSounds[i] = null;
}
}
}

View File

@@ -1,561 +0,0 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.badlogic.gdx.graphics;
import com.badlogic.gdx.utils.NumberUtils;
/** A color class, holding the r, g, b and alpha component as floats in the range [0,1]. All methods perform clamping on the
* internal values after execution.
*
* @author mzechner */
public class Color {
public static final Color WHITE = new Color(1, 1, 1,1);
public static final Color LIGHT_GRAY = new Color(0xbfbfbfff);
public static final Color GRAY = new Color(0x7f7f7fff);
public static final Color DARK_GRAY = new Color(0x3f3f3fff);
public static final Color BLACK = new Color(0, 0, 0, 1);
/** Convenience for frequently used <code>WHITE.toFloatBits()</code> */
public static final float WHITE_FLOAT_BITS = WHITE.toFloatBits();
public static final Color CLEAR = new Color(0, 0, 0, 0);
public static final Color BLUE = new Color(0, 0, 1, 1);
public static final Color NAVY = new Color(0, 0, 0.5f, 1);
public static final Color ROYAL = new Color(0x4169e1ff);
public static final Color SLATE = new Color(0x708090ff);
public static final Color SKY = new Color(0x87ceebff);
public static final Color CYAN = new Color(0, 1, 1, 1);
public static final Color TEAL = new Color(0, 0.5f, 0.5f, 1);
public static final Color GREEN = new Color(0x00ff00ff);
public static final Color CHARTREUSE = new Color(0x7fff00ff);
public static final Color LIME = new Color(0x32cd32ff);
public static final Color FOREST = new Color(0x228b22ff);
public static final Color OLIVE = new Color(0x6b8e23ff);
public static final Color YELLOW = new Color(0xffff00ff);
public static final Color GOLD = new Color(0xffd700ff);
public static final Color GOLDENROD = new Color(0xdaa520ff);
public static final Color ORANGE = new Color(0xffa500ff);
public static final Color BROWN = new Color(0x8b4513ff);
public static final Color TAN = new Color(0xd2b48cff);
public static final Color FIREBRICK = new Color(0xb22222ff);
public static final Color RED = new Color(0xff0000ff);
public static final Color SCARLET = new Color(0xff341cff);
public static final Color CORAL = new Color(0xff7f50ff);
public static final Color SALMON = new Color(0xfa8072ff);
public static final Color PINK = new Color(0xff69b4ff);
public static final Color MAGENTA = new Color(1, 0, 1, 1);
public static final Color PURPLE = new Color(0xa020f0ff);
public static final Color VIOLET = new Color(0xee82eeff);
public static final Color MAROON = new Color(0xb03060ff);
/** the red, green, blue and alpha components **/
public float r, g, b, a;
/** Constructs a new Color with all components set to 0. */
public Color () {
}
/** @see #rgba8888ToColor(Color, int) */
public Color (int rgba8888) {
rgba8888ToColor(this, rgba8888);
}
/** Constructor, sets the components of the color
*
* @param r the red component
* @param g the green component
* @param b the blue component
* @param a the alpha component */
public Color (float r, float g, float b, float a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
/** Constructs a new color using the given color
*
* @param color the color */
public Color (Color color) {
set(color);
}
/** Sets this color to the given color.
*
* @param color the Color */
public Color set (Color color) {
this.r = color.r;
this.g = color.g;
this.b = color.b;
this.a = color.a;
return this;
}
/** Multiplies the this color and the given color
*
* @param color the color
* @return this color. */
public Color mul (Color color) {
this.r *= color.r;
this.g *= color.g;
this.b *= color.b;
this.a *= color.a;
return this;
}
/** Multiplies all components of this Color with the given value.
*
* @param value the value
* @return this color */
public Color mul (float value) {
this.r *= value;
this.g *= value;
this.b *= value;
this.a *= value;
return this;
}
/** Adds the given color to this color.
*
* @param color the color
* @return this color */
public Color add (Color color) {
this.r += color.r;
this.g += color.g;
this.b += color.b;
this.a += color.a;
return this;
}
/** Subtracts the given color from this color
*
* @param color the color
* @return this color */
public Color sub (Color color) {
this.r -= color.r;
this.g -= color.g;
this.b -= color.b;
this.a -= color.a;
return this;
}
/** Sets this Color's component values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Color for chaining */
public Color set (float r, float g, float b, float a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
return this;
}
/** Sets this color's component values through an integer representation.
*
* @return this Color for chaining
* @see #rgba8888ToColor(Color, int) */
public Color set (int rgba) {
rgba8888ToColor(this, rgba);
return this;
}
/** Adds the given color component values to this Color's values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Color for chaining */
public Color add (float r, float g, float b, float a) {
this.r += r;
this.g += g;
this.b += b;
this.a += a;
return this;
}
/** Subtracts the given values from this Color's component values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Color for chaining */
public Color sub (float r, float g, float b, float a) {
this.r -= r;
this.g -= g;
this.b -= b;
this.a -= a;
return this;
}
/** Multiplies this Color's color components by the given ones.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Color for chaining */
public Color mul (float r, float g, float b, float a) {
this.r *= r;
this.g *= g;
this.b *= b;
this.a *= a;
return this;
}
/** Linearly interpolates between this color and the target color by t which is in the range [0,1]. The result is stored in
* this color.
* @param target The target color
* @param t The interpolation coefficient
* @return This color for chaining. */
public Color lerp (final Color target, final float t) {
this.r += t * (target.r - this.r);
this.g += t * (target.g - this.g);
this.b += t * (target.b - this.b);
this.a += t * (target.a - this.a);
return this;
}
/** Linearly interpolates between this color and the target color by t which is in the range [0,1]. The result is stored in
* this color.
* @param r The red component of the target color
* @param g The green component of the target color
* @param b The blue component of the target color
* @param a The alpha component of the target color
* @param t The interpolation coefficient
* @return This color for chaining. */
public Color lerp (final float r, final float g, final float b, final float a, final float t) {
this.r += t * (r - this.r);
this.g += t * (g - this.g);
this.b += t * (b - this.b);
this.a += t * (a - this.a);
return this;
}
/** Multiplies the RGB values by the alpha. */
public Color premultiplyAlpha () {
r *= a;
g *= a;
b *= a;
return this;
}
@Override
public boolean equals (Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Color color = (Color)o;
return toIntBits() == color.toIntBits();
}
@Override
public int hashCode () {
int result = (r != +0.0f ? NumberUtils.floatToIntBits(r) : 0);
result = 31 * result + (g != +0.0f ? NumberUtils.floatToIntBits(g) : 0);
result = 31 * result + (b != +0.0f ? NumberUtils.floatToIntBits(b) : 0);
result = 31 * result + (a != +0.0f ? NumberUtils.floatToIntBits(a) : 0);
return result;
}
/** Packs the color components into a 32-bit integer with the format ABGR and then converts it to a float. Alpha is compressed
* from 0-255 to 0-254 to avoid using float bits in the NaN range (see {@link NumberUtils#intToFloatColor(int)}).
* @return the packed color as a 32-bit float */
public float toFloatBits () {
int color = ((int)(255 * a) << 24) | ((int)(255 * b) << 16) | ((int)(255 * g) << 8) | ((int)(255 * r));
return NumberUtils.intToFloatColor(color);
}
/** Packs the color components into a 32-bit integer with the format ABGR.
* @return the packed color as a 32-bit int. */
public int toIntBits () {
return ((int)(255 * a) << 24) | ((int)(255 * b) << 16) | ((int)(255 * g) << 8) | ((int)(255 * r));
}
/** Returns the color encoded as hex string with the format RRGGBBAA. */
public String toString () {
String value = Integer
.toHexString(((int)(255 * r) << 24) | ((int)(255 * g) << 16) | ((int)(255 * b) << 8) | ((int)(255 * a)));
while (value.length() < 8)
value = "0" + value;
return value;
}
/** Returns a new color from a hex string with the format RRGGBBAA.
* @see #toString() */
public static Color valueOf (String hex) {
hex = hex.charAt(0) == '#' ? hex.substring(1) : hex;
int r = Integer.valueOf(hex.substring(0, 2), 16);
int g = Integer.valueOf(hex.substring(2, 4), 16);
int b = Integer.valueOf(hex.substring(4, 6), 16);
int a = hex.length() != 8 ? 255 : Integer.valueOf(hex.substring(6, 8), 16);
return new Color(r / 255f, g / 255f, b / 255f, a / 255f);
}
/** Packs the color components into a 32-bit integer with the format ABGR and then converts it to a float. Note that no range
* checking is performed for higher performance.
* @param r the red component, 0 - 255
* @param g the green component, 0 - 255
* @param b the blue component, 0 - 255
* @param a the alpha component, 0 - 255
* @return the packed color as a float
* @see NumberUtils#intToFloatColor(int) */
public static float toFloatBits (int r, int g, int b, int a) {
int color = (a << 24) | (b << 16) | (g << 8) | r;
float floatColor = NumberUtils.intToFloatColor(color);
return floatColor;
}
/** Packs the color components into a 32-bit integer with the format ABGR and then converts it to a float.
* @return the packed color as a 32-bit float
* @see NumberUtils#intToFloatColor(int) */
public static float toFloatBits (float r, float g, float b, float a) {
int color = ((int)(255 * a) << 24) | ((int)(255 * b) << 16) | ((int)(255 * g) << 8) | ((int)(255 * r));
return NumberUtils.intToFloatColor(color);
}
/** Packs the color components into a 32-bit integer with the format ABGR. Note that no range checking is performed for higher
* performance.
* @param r the red component, 0 - 255
* @param g the green component, 0 - 255
* @param b the blue component, 0 - 255
* @param a the alpha component, 0 - 255
* @return the packed color as a 32-bit int */
public static int toIntBits (int r, int g, int b, int a) {
return (a << 24) | (b << 16) | (g << 8) | r;
}
public static int alpha (float alpha) {
return (int)(alpha * 255.0f);
}
public static int luminanceAlpha (float luminance, float alpha) {
return ((int)(luminance * 255.0f) << 8) | (int)(alpha * 255);
}
public static int rgb565 (float r, float g, float b) {
return ((int)(r * 31) << 11) | ((int)(g * 63) << 5) | (int)(b * 31);
}
public static int rgba4444 (float r, float g, float b, float a) {
return ((int)(r * 15) << 12) | ((int)(g * 15) << 8) | ((int)(b * 15) << 4) | (int)(a * 15);
}
public static int rgb888 (float r, float g, float b) {
return ((int)(r * 255) << 16) | ((int)(g * 255) << 8) | (int)(b * 255);
}
public static int rgba8888 (float r, float g, float b, float a) {
return ((int)(r * 255) << 24) | ((int)(g * 255) << 16) | ((int)(b * 255) << 8) | (int)(a * 255);
}
public static int argb8888 (float a, float r, float g, float b) {
return ((int)(a * 255) << 24) | ((int)(r * 255) << 16) | ((int)(g * 255) << 8) | (int)(b * 255);
}
public static int rgb565 (Color color) {
return ((int)(color.r * 31) << 11) | ((int)(color.g * 63) << 5) | (int)(color.b * 31);
}
public static int rgba4444 (Color color) {
return ((int)(color.r * 15) << 12) | ((int)(color.g * 15) << 8) | ((int)(color.b * 15) << 4) | (int)(color.a * 15);
}
public static int rgb888 (Color color) {
return ((int)(color.r * 255) << 16) | ((int)(color.g * 255) << 8) | (int)(color.b * 255);
}
public static int rgba8888 (Color color) {
return ((int)(color.r * 255) << 24) | ((int)(color.g * 255) << 16) | ((int)(color.b * 255) << 8) | (int)(color.a * 255);
}
public static int argb8888 (Color color) {
return ((int)(color.a * 255) << 24) | ((int)(color.r * 255) << 16) | ((int)(color.g * 255) << 8) | (int)(color.b * 255);
}
/** Sets the Color components using the specified integer value in the format RGB565. This is inverse to the rgb565(r, g, b)
* method.
*
* @param color The Color to be modified.
* @param value An integer color value in RGB565 format. */
public static void rgb565ToColor (Color color, int value) {
color.r = ((value & 0x0000F800) >>> 11) / 31f;
color.g = ((value & 0x000007E0) >>> 5) / 63f;
color.b = ((value & 0x0000001F) >>> 0) / 31f;
}
/** Sets the Color components using the specified integer value in the format RGBA4444. This is inverse to the rgba4444(r, g,
* b, a) method.
*
* @param color The Color to be modified.
* @param value An integer color value in RGBA4444 format. */
public static void rgba4444ToColor (Color color, int value) {
color.r = ((value & 0x0000f000) >>> 12) / 15f;
color.g = ((value & 0x00000f00) >>> 8) / 15f;
color.b = ((value & 0x000000f0) >>> 4) / 15f;
color.a = ((value & 0x0000000f)) / 15f;
}
/** Sets the Color components using the specified integer value in the format RGB888. This is inverse to the rgb888(r, g, b)
* method.
*
* @param color The Color to be modified.
* @param value An integer color value in RGB888 format. */
public static void rgb888ToColor (Color color, int value) {
color.r = ((value & 0x00ff0000) >>> 16) / 255f;
color.g = ((value & 0x0000ff00) >>> 8) / 255f;
color.b = ((value & 0x000000ff)) / 255f;
}
/** Sets the Color components using the specified integer value in the format RGBA8888. This is inverse to the rgba8888(r, g,
* b, a) method.
*
* @param color The Color to be modified.
* @param value An integer color value in RGBA8888 format. */
public static void rgba8888ToColor (Color color, int value) {
color.r = ((value & 0xff000000) >>> 24) / 255f;
color.g = ((value & 0x00ff0000) >>> 16) / 255f;
color.b = ((value & 0x0000ff00) >>> 8) / 255f;
color.a = ((value & 0x000000ff)) / 255f;
}
/** Sets the Color components using the specified integer value in the format ARGB8888. This is the inverse to the argb8888(a,
* r, g, b) method
*
* @param color The Color to be modified.
* @param value An integer color value in ARGB8888 format. */
public static void argb8888ToColor (Color color, int value) {
color.a = ((value & 0xff000000) >>> 24) / 255f;
color.r = ((value & 0x00ff0000) >>> 16) / 255f;
color.g = ((value & 0x0000ff00) >>> 8) / 255f;
color.b = ((value & 0x000000ff)) / 255f;
}
/** Sets the Color components using the specified float value in the format ABGB8888.
* @param color The Color to be modified. */
public static void abgr8888ToColor (Color color, float value) {
int c = NumberUtils.floatToIntColor(value);
color.a = ((c & 0xff000000) >>> 24) / 255f;
color.b = ((c & 0x00ff0000) >>> 16) / 255f;
color.g = ((c & 0x0000ff00) >>> 8) / 255f;
color.r = ((c & 0x000000ff)) / 255f;
}
/** Sets the RGB Color components using the specified Hue-Saturation-Value. Note that HSV components are voluntary not clamped
* to preserve high range color and can range beyond typical values.
* @param h The Hue in degree from 0 to 360
* @param s The Saturation from 0 to 1
* @param v The Value (brightness) from 0 to 1
* @return The modified Color for chaining. */
public Color fromHsv (float h, float s, float v) {
float x = (h / 60f + 6) % 6;
int i = (int)x;
float f = x - i;
float p = v * (1 - s);
float q = v * (1 - s * f);
float t = v * (1 - s * (1 - f));
switch (i) {
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
default:
r = v;
g = p;
b = q;
}
//return clamp();
return this;
}
/** Sets RGB components using the specified Hue-Saturation-Value. This is a convenient method for
* {@link #fromHsv(float, float, float)}. This is the inverse of {@link #toHsv(float[])}.
* @param hsv The Hue, Saturation and Value components in that order.
* @return The modified Color for chaining. */
public Color fromHsv (float[] hsv) {
return fromHsv(hsv[0], hsv[1], hsv[2]);
}
/** Extract Hue-Saturation-Value. This is the inverse of {@link #fromHsv(float[])}.
* @param hsv The HSV array to be modified.
* @return HSV components for chaining. */
public float[] toHsv (float[] hsv) {
float max = Math.max(Math.max(r, g), b);
float min = Math.min(Math.min(r, g), b);
float range = max - min;
if (range == 0) {
hsv[0] = 0;
} else if (max == r) {
hsv[0] = (60 * (g - b) / range + 360) % 360;
} else if (max == g) {
hsv[0] = 60 * (b - r) / range + 120;
} else {
hsv[0] = 60 * (r - g) / range + 240;
}
if (max > 0) {
hsv[1] = 1 - min / max;
} else {
hsv[1] = 0;
}
hsv[2] = max;
return hsv;
}
/** @return a copy of this color */
public Color cpy () {
return new Color(this);
}
}

16
src/module-info.java.wtf Normal file
View File

@@ -0,0 +1,16 @@
module terrarum {
requires gdx;
requires gdx.backend.lwjgl;
requires gdx.controllers;
requires jxinput;
requires gson;
requires GetCpuName;
requires TerrarumSansBitmap;
requires kotlin.stdlib;
requires java.desktop;
requires java.logging;
requires TerranVirtualDisk;
requires commons.codec;
requires commons.csv;
requires Terrarum.Joise;
}

View File

@@ -32,7 +32,17 @@ class KDHeapifiedTree(actors: List<ActorWBMovable>) {
private fun Int.getActor() = nodes[this] private fun Int.getActor() = nodes[this]
private fun Int.getLeft() = this * 2 + 1 private fun Int.getLeft() = this * 2 + 1
private fun Int.getRight() = this * 2 + 2 private fun Int.getRight() = this * 2 + 2
private fun Int.set(value: ActorWBMovable?) { nodes[this] = value } private fun Int.set(value: ActorWBMovable?) {
try {
nodes[this] = value
}
catch (_: ArrayIndexOutOfBoundsException) {
// modification of the private fun expandArray()
val prevNodes = nodes.copyOf() + value
Array<ActorWBMovable?>(prevNodes.size * 2, { null })
create(prevNodes.toList(), 0, 0)
}
}
private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value } private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value }
private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value } private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value }

View File

@@ -1,9 +1,13 @@
package net.torvald.aa package net.torvald.aa
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.Hitbox
import net.torvald.terrarum.sqr
/** /**
* Created by minjaesong on 2019-04-18. * Created by minjaesong on 2019-04-18.
*/ */
/*class KDTree(points: List<ActorWithBody>) { class KDTree(points: List<ActorWithBody>) {
companion object { companion object {
const val DIMENSION = 2 const val DIMENSION = 2
@@ -15,7 +19,7 @@ package net.torvald.aa
root = create(points, 0) root = create(points, 0)
} }
fun findNearest(query: ActorWithBody) = getNearest(root!!, query, 0) fun findNearest(query: ActorWithBody) = getNearest(root!!, query.hitbox, 0)
private fun create(points: List<ActorWithBody>, depth: Int): KDNode? { private fun create(points: List<ActorWithBody>, depth: Int): KDNode? {
if (points.isEmpty()) { if (points.isEmpty()) {
@@ -34,21 +38,21 @@ package net.torvald.aa
} }
} }
private fun getNearest(currentNode: KDNode, query: ActorWithBody, depth: Int = 0): KDNode { private fun getNearest(currentNode: KDNode, actorHitbox: Hitbox, depth: Int = 0): KDNode {
val direction = currentNode.compare(query, depth % DIMENSION) val direction = currentNode.compare(actorHitbox, depth % DIMENSION)
val next = if (direction < 0) currentNode.left else currentNode.right val next = if (direction < 0) currentNode.left else currentNode.right
val other = if (direction < 0) currentNode.right else currentNode.left val other = if (direction < 0) currentNode.right else currentNode.left
var best = if (next == null) currentNode else getNearest(next, query, depth + 1) // traverse to leaf var best = if (next == null) currentNode else getNearest(next, actorHitbox, depth + 1) // traverse to leaf
if (currentNode.position.distSqr(query) < best.position.distSqr(query)) { if (currentNode.position.distSqr(actorHitbox) < best.position.distSqr(actorHitbox)) {
best = currentNode best = currentNode
} }
if (other != null) { if (other != null) {
if (currentNode.position.dimDistSqr(query, depth % DIMENSION) < best.position.distSqr(query)) { if (currentNode.position.dimDistSqr(actorHitbox, depth % DIMENSION) < best.position.distSqr(actorHitbox)) {
val bestCandidate = getNearest(other, query, depth + 1) val bestCandidate = getNearest(other, actorHitbox, depth + 1)
if (bestCandidate.position.distSqr(query) < best.position.distSqr(query)) { if (bestCandidate.position.distSqr(actorHitbox) < best.position.distSqr(actorHitbox)) {
best = bestCandidate best = bestCandidate
} }
} }
@@ -58,14 +62,15 @@ package net.torvald.aa
} }
data class KDNode(val left: KDNode?, val right: KDNode?, val actor: ActorWithBody, val position: Hitbox) { data class KDNode(val left: KDNode?, val right: KDNode?, val actor: ActorWithBody, val position: Hitbox) {
fun compare(other: ActorWithBody, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension) //fun compare(other: ActorWithBody, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension)
fun compare(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension) - this.position.getDimensionalPoint(dimension)
} }
private fun Hitbox.distSqr(other: Hitbox) { private fun Hitbox.distSqr(other: Hitbox): Double {
var dist = 0.0 var dist = 0.0
for (i in 0 until DIMENSION) for (i in 0 until DIMENSION)
dist += (this.getDimensionalPoint(i) - other.getDimensionalPoint(i)).sqr() dist += (this.getDimensionalPoint(i) - other.getDimensionalPoint(i)).sqr()
return dist
} }
private fun Hitbox.dimDistSqr(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension).minus(this.getDimensionalPoint(dimension)).sqr() private fun Hitbox.dimDistSqr(other: Hitbox, dimension: Int) = other.getDimensionalPoint(dimension).minus(this.getDimensionalPoint(dimension)).sqr()
@@ -74,4 +79,4 @@ package net.torvald.aa
internal fun ActorWithBody.getDimensionalPoint(depth: Int) = this.hitbox.getDimensionalPoint(depth) internal fun ActorWithBody.getDimensionalPoint(depth: Int) = this.hitbox.getDimensionalPoint(depth)
// TODO take ROUNDWORLD into account // TODO take ROUNDWORLD into account
internal fun Hitbox.getDimensionalPoint(depth: Int) = internal fun Hitbox.getDimensionalPoint(depth: Int) =
if (depth % KDTree.DIMENSION == 0) this.canonicalX else this.canonicalY*/ if (depth % KDTree.DIMENSION == 0) this.canonicalX else this.canonicalY

View File

@@ -1,5 +1,6 @@
package net.torvald.colourutil package net.torvald.colourutil
import com.badlogic.gdx.graphics.Color
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.colourutil.CIELChabUtil.toLCh import net.torvald.colourutil.CIELChabUtil.toLCh
import net.torvald.colourutil.CIELChabUtil.toLab import net.torvald.colourutil.CIELChabUtil.toLab
@@ -7,7 +8,6 @@ import net.torvald.colourutil.CIELabUtil.toLab
import net.torvald.colourutil.CIEXYZUtil.toXYZ import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.CIEXYZUtil.toColor import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIELabUtil.toXYZ import net.torvald.colourutil.CIELabUtil.toXYZ
import com.badlogic.gdx.graphics.Color
/** /**
* Cylindrical modification of CIELab colour space * Cylindrical modification of CIELab colour space
* *

View File

@@ -1,12 +1,12 @@
package net.torvald.colourutil package net.torvald.colourutil
import com.badlogic.gdx.graphics.Color
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.colourutil.CIELabUtil.toLab import net.torvald.colourutil.CIELabUtil.toLab
import net.torvald.colourutil.CIEXYZUtil.toColor import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIEXYZUtil.toRGB import net.torvald.colourutil.CIEXYZUtil.toRGB
import net.torvald.colourutil.CIEXYZUtil.toXYZ import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.CIELabUtil.toXYZ import net.torvald.colourutil.CIELabUtil.toXYZ
import com.badlogic.gdx.graphics.Color
/** /**
* A modification of CIEXYZ that is useful for surface colours * A modification of CIEXYZ that is useful for surface colours

View File

@@ -2,7 +2,6 @@ package net.torvald.colourutil
import com.jme3.math.FastMath import com.jme3.math.FastMath
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import net.torvald.colourutil.CIELabUtil.toXYZ
import net.torvald.colourutil.CIEXYZUtil.toColor import net.torvald.colourutil.CIEXYZUtil.toColor
import net.torvald.colourutil.CIEXYZUtil.toRGB import net.torvald.colourutil.CIEXYZUtil.toRGB
import net.torvald.colourutil.CIEXYZUtil.toXYZ import net.torvald.colourutil.CIEXYZUtil.toXYZ

View File

@@ -0,0 +1,478 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.torvald.gdx.graphics
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.utils.NumberUtils
/** A color class, holding the r, g, b and alpha component as floats in the range [0,1]. All methods perform clamping on the
* internal values after execution.
*
* @author mzechner
*/
class Cvec {
/** the red, green, blue and alpha components */
var r: Float = 0.toFloat()
var g: Float = 0.toFloat()
var b: Float = 0.toFloat()
var a: Float = 0.toFloat()
/** Constructs a new Cvec with all components set to 0. */
constructor() {}
/** @see .rgba8888ToCvec
*/
constructor(rgba8888: Int) {
rgba8888ToCvec(this, rgba8888)
}
constructor(color: Color) {
this.r = color.r
this.g = color.g
this.b = color.b
this.a = color.a
}
/** Constructor, sets the components of the color
*
* @param r the red component
* @param g the green component
* @param b the blue component
* @param a the alpha component
*/
constructor(r: Float, g: Float, b: Float, a: Float) {
this.r = r
this.g = g
this.b = b
this.a = a
}
/** Constructs a new color using the given color
*
* @param color the color
*/
constructor(color: Cvec) {
set(color)
}
/** Sets this color to the given color.
*
* @param color the Cvec
*/
fun set(color: Cvec): Cvec {
this.r = color.r
this.g = color.g
this.b = color.b
this.a = color.a
return this
}
/** Multiplies the this color and the given color
*
* @param color the color
* @return this color.
*/
fun mul(color: Cvec): Cvec {
this.r *= color.r
this.g *= color.g
this.b *= color.b
this.a *= color.a
return this
}
/** Multiplies all components of this Cvec with the given value.
*
* @param value the value
* @return this color
*/
fun mul(value: Float): Cvec {
this.r *= value
this.g *= value
this.b *= value
this.a *= value
return this
}
/** Adds the given color to this color.
*
* @param color the color
* @return this color
*/
fun add(color: Cvec): Cvec {
this.r += color.r
this.g += color.g
this.b += color.b
this.a += color.a
return this
}
/** Subtracts the given color from this color
*
* @param color the color
* @return this color
*/
fun sub(color: Cvec): Cvec {
this.r -= color.r
this.g -= color.g
this.b -= color.b
this.a -= color.a
return this
}
/** Sets this Cvec's component values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Cvec for chaining
*/
operator fun set(r: Float, g: Float, b: Float, a: Float): Cvec {
this.r = r
this.g = g
this.b = b
this.a = a
return this
}
/** Sets this color's component values through an integer representation.
*
* @return this Cvec for chaining
* @see .rgba8888ToCvec
*/
fun set(rgba: Int): Cvec {
rgba8888ToCvec(this, rgba)
return this
}
/** Adds the given color component values to this Cvec's values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Cvec for chaining
*/
fun add(r: Float, g: Float, b: Float, a: Float): Cvec {
this.r += r
this.g += g
this.b += b
this.a += a
return this
}
/** Subtracts the given values from this Cvec's component values.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Cvec for chaining
*/
fun sub(r: Float, g: Float, b: Float, a: Float): Cvec {
this.r -= r
this.g -= g
this.b -= b
this.a -= a
return this
}
/** Multiplies this Cvec's color components by the given ones.
*
* @param r Red component
* @param g Green component
* @param b Blue component
* @param a Alpha component
*
* @return this Cvec for chaining
*/
fun mul(r: Float, g: Float, b: Float, a: Float): Cvec {
this.r *= r
this.g *= g
this.b *= b
this.a *= a
return this
}
/** Linearly interpolates between this color and the target color by t which is in the range [0,1]. The result is stored in
* this color.
* @param target The target color
* @param t The interpolation coefficient
* @return This color for chaining.
*/
fun lerp(target: Cvec, t: Float): Cvec {
this.r += t * (target.r - this.r)
this.g += t * (target.g - this.g)
this.b += t * (target.b - this.b)
this.a += t * (target.a - this.a)
return this
}
/** Linearly interpolates between this color and the target color by t which is in the range [0,1]. The result is stored in
* this color.
* @param r The red component of the target color
* @param g The green component of the target color
* @param b The blue component of the target color
* @param a The alpha component of the target color
* @param t The interpolation coefficient
* @return This color for chaining.
*/
fun lerp(r: Float, g: Float, b: Float, a: Float, t: Float): Cvec {
this.r += t * (r - this.r)
this.g += t * (g - this.g)
this.b += t * (b - this.b)
this.a += t * (a - this.a)
return this
}
/** Multiplies the RGB values by the alpha. */
fun premultiplyAlpha(): Cvec {
r *= a
g *= a
b *= a
return this
}
override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o == null || javaClass != o.javaClass) return false
val color = o as Cvec?
return toIntBits() == color!!.toIntBits()
}
override fun hashCode(): Int {
var result = if (r != +0.0f) NumberUtils.floatToIntBits(r) else 0
result = 31 * result + if (g != +0.0f) NumberUtils.floatToIntBits(g) else 0
result = 31 * result + if (b != +0.0f) NumberUtils.floatToIntBits(b) else 0
result = 31 * result + if (a != +0.0f) NumberUtils.floatToIntBits(a) else 0
return result
}
/** Packs the color components into a 32-bit integer with the format ABGR and then converts it to a float. Alpha is compressed
* from 0-255 to 0-254 to avoid using float bits in the NaN range (see [NumberUtils.intToFloatColor]).
* @return the packed color as a 32-bit float
*/
fun toFloatBits(): Float {
val color = (255 * a).toInt() shl 24 or ((255 * b).toInt() shl 16) or ((255 * g).toInt() shl 8) or (255 * r).toInt()
return NumberUtils.intToFloatColor(color)
}
/** Packs the color components into a 32-bit integer with the format ABGR.
* @return the packed color as a 32-bit int.
*/
fun toIntBits(): Int {
return (255 * a).toInt() shl 24 or ((255 * b).toInt() shl 16) or ((255 * g).toInt() shl 8) or (255 * r).toInt()
}
/** Returns the color encoded as hex string with the format RRGGBBAA. */
override fun toString(): String {
var value = Integer
.toHexString((255 * r).toInt() shl 24 or ((255 * g).toInt() shl 16) or ((255 * b).toInt() shl 8) or (255 * a).toInt())
while (value.length < 8)
value = "0$value"
return value
}
/** Sets the RGB Cvec components using the specified Hue-Saturation-Value. Note that HSV components are voluntary not clamped
* to preserve high range color and can range beyond typical values.
* @param h The Hue in degree from 0 to 360
* @param s The Saturation from 0 to 1
* @param v The Value (brightness) from 0 to 1
* @return The modified Cvec for chaining.
*/
fun fromHsv(h: Float, s: Float, v: Float): Cvec {
val x = (h / 60f + 6) % 6
val i = x.toInt()
val f = x - i
val p = v * (1 - s)
val q = v * (1 - s * f)
val t = v * (1 - s * (1 - f))
when (i) {
0 -> {
r = v
g = t
b = p
}
1 -> {
r = q
g = v
b = p
}
2 -> {
r = p
g = v
b = t
}
3 -> {
r = p
g = q
b = v
}
4 -> {
r = t
g = p
b = v
}
else -> {
r = v
g = p
b = q
}
}
//return clamp();
return this
}
/** Sets RGB components using the specified Hue-Saturation-Value. This is a convenient method for
* [.fromHsv]. This is the inverse of [.toHsv].
* @param hsv The Hue, Saturation and Value components in that order.
* @return The modified Cvec for chaining.
*/
fun fromHsv(hsv: FloatArray): Cvec {
return fromHsv(hsv[0], hsv[1], hsv[2])
}
/** Extract Hue-Saturation-Value. This is the inverse of [.fromHsv].
* @param hsv The HSV array to be modified.
* @return HSV components for chaining.
*/
fun toHsv(hsv: FloatArray): FloatArray {
val max = Math.max(Math.max(r, g), b)
val min = Math.min(Math.min(r, g), b)
val range = max - min
if (range == 0f) {
hsv[0] = 0f
}
else if (max == r) {
hsv[0] = (60 * (g - b) / range + 360) % 360
}
else if (max == g) {
hsv[0] = 60 * (b - r) / range + 120
}
else {
hsv[0] = 60 * (r - g) / range + 240
}
if (max > 0) {
hsv[1] = 1 - min / max
}
else {
hsv[1] = 0f
}
hsv[2] = max
return hsv
}
/** @return a copy of this color
*/
fun cpy(): Cvec {
return Cvec(this)
}
companion object {
val WHITE = Cvec(1f, 1f, 1f, 1f)
/** Returns a new color from a hex string with the format RRGGBBAA.
* @see .toString
*/
fun valueOf(hex: String): Cvec {
var hex = hex
hex = if (hex[0] == '#') hex.substring(1) else hex
val r = Integer.valueOf(hex.substring(0, 2), 16)
val g = Integer.valueOf(hex.substring(2, 4), 16)
val b = Integer.valueOf(hex.substring(4, 6), 16)
val a = if (hex.length != 8) 255 else Integer.valueOf(hex.substring(6, 8), 16)
return Cvec(r / 255f, g / 255f, b / 255f, a / 255f)
}
/** Packs the color components into a 32-bit integer with the format ABGR. Note that no range checking is performed for higher
* performance.
* @param r the red component, 0 - 255
* @param g the green component, 0 - 255
* @param b the blue component, 0 - 255
* @param a the alpha component, 0 - 255
* @return the packed color as a 32-bit int
*/
fun toIntBits(r: Int, g: Int, b: Int, a: Int): Int {
return a shl 24 or (b shl 16) or (g shl 8) or r
}
fun alpha(alpha: Float): Int {
return (alpha * 255.0f).toInt()
}
fun rgba8888(r: Float, g: Float, b: Float, a: Float): Int {
return (r * 255).toInt() shl 24 or ((g * 255).toInt() shl 16) or ((b * 255).toInt() shl 8) or (a * 255).toInt()
}
fun argb8888(a: Float, r: Float, g: Float, b: Float): Int {
return (a * 255).toInt() shl 24 or ((r * 255).toInt() shl 16) or ((g * 255).toInt() shl 8) or (b * 255).toInt()
}
fun rgba8888(color: Cvec): Int {
return (color.r * 255).toInt() shl 24 or ((color.g * 255).toInt() shl 16) or ((color.b * 255).toInt() shl 8) or (color.a * 255).toInt()
}
fun argb8888(color: Cvec): Int {
return (color.a * 255).toInt() shl 24 or ((color.r * 255).toInt() shl 16) or ((color.g * 255).toInt() shl 8) or (color.b * 255).toInt()
}
/** Sets the Cvec components using the specified integer value in the format RGBA8888. This is inverse to the rgba8888(r, g,
* b, a) method.
*
* @param color The Cvec to be modified.
* @param value An integer color value in RGBA8888 format.
*/
fun rgba8888ToCvec(color: Cvec, value: Int) {
color.r = (value and -0x1000000).ushr(24) / 255f
color.g = (value and 0x00ff0000).ushr(16) / 255f
color.b = (value and 0x0000ff00).ushr(8) / 255f
color.a = (value and 0x000000ff) / 255f
}
/** Sets the Cvec components using the specified integer value in the format ARGB8888. This is the inverse to the argb8888(a,
* r, g, b) method
*
* @param color The Cvec to be modified.
* @param value An integer color value in ARGB8888 format.
*/
fun argb8888ToCvec(color: Cvec, value: Int) {
color.a = (value and -0x1000000).ushr(24) / 255f
color.r = (value and 0x00ff0000).ushr(16) / 255f
color.g = (value and 0x0000ff00).ushr(8) / 255f
color.b = (value and 0x000000ff) / 255f
}
/** Sets the Cvec components using the specified float value in the format ABGB8888.
* @param color The Cvec to be modified.
*/
fun abgr8888ToCvec(color: Cvec, value: Float) {
val c = NumberUtils.floatToIntColor(value)
color.a = (c and -0x1000000).ushr(24) / 255f
color.b = (c and 0x00ff0000).ushr(16) / 255f
color.g = (c and 0x0000ff00).ushr(8) / 255f
color.r = (c and 0x000000ff) / 255f
}
}
}

View File

@@ -1,6 +1,7 @@
package com.badlogic.gdx.graphics; package net.torvald.gdx.graphics;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.utils.StreamUtils; import com.badlogic.gdx.utils.StreamUtils;
import java.io.IOException; import java.io.IOException;

View File

@@ -5,23 +5,15 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Screen import com.badlogic.gdx.Screen
import com.badlogic.gdx.backends.lwjgl.LwjglApplication import com.badlogic.gdx.backends.lwjgl.LwjglApplication
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.math.Affine2
import com.jme3.math.FastMath
import net.torvald.colourutil.CIEYXY
import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.CIEXYZUtil.toColorRaw import net.torvald.colourutil.CIEXYZUtil.toColorRaw
import net.torvald.colourutil.CIEXYZUtil.toColor import net.torvald.colourutil.CIEXYZUtil.toXYZ
import net.torvald.colourutil.RGB import net.torvald.colourutil.CIEYXY
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.inUse import net.torvald.terrarum.inUse
import java.awt.BorderLayout
import java.awt.Dimension import java.awt.Dimension
import javax.swing.* import javax.swing.*
import kotlin.math.pow
const val WIDTH = 1200 const val WIDTH = 1200

View File

@@ -11,12 +11,17 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
*/ */
interface HasAssembledSprite { interface HasAssembledSprite {
/** ADL path for main sprite. Necessary. */
var animDescPath: String var animDescPath: String
/** ADL path for glow sprite. Optional. */
var animDescPathGlow: String?
// FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?) // FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?)
fun reassembleSprite(sprite: SpriteAnimation) { fun reassembleSprite(sprite: SpriteAnimation, spriteGlow: SpriteAnimation? = null) {
_rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite) _rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite)
if (spriteGlow != null)
_rebuild(ADProperties(Gdx.files.internal(animDescPathGlow).read()), spriteGlow)
} }
/*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) { /*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) {

View File

@@ -6,9 +6,9 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplication
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.PixmapIO2
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.gdx.graphics.PixmapIO2
import net.torvald.terrarum.gdxClearAndSetBlend import net.torvald.terrarum.gdxClearAndSetBlend
import net.torvald.terrarum.inUse import net.torvald.terrarum.inUse
import java.awt.BorderLayout import java.awt.BorderLayout
@@ -95,6 +95,7 @@ class SpriteAssemblerApp(val gdxWindow: SpriteAssemblerPreview) : JFrame() {
} }
panelCode.font = Font(Font.MONOSPACED, Font.PLAIN, 12) panelCode.font = Font(Font.MONOSPACED, Font.PLAIN, 12)
panelCode.text = "Enter your descriptor code here…"
panelAnimationsList.model = DefaultListModel() panelAnimationsList.model = DefaultListModel()
panelBodypartsList.model = DefaultListModel() panelBodypartsList.model = DefaultListModel()
@@ -257,7 +258,7 @@ class SpriteAssemblerPreview: Game() {
renderTexture = Texture(1, 1, Pixmap.Format.RGBA8888) renderTexture = Texture(1, 1, Pixmap.Format.RGBA8888)
} }
private val bgCol = Color(.62f,.79f,1f,1f) private val bgCol = Color(.62f, .79f, 1f, 1f)
private var doAssemble = false private var doAssemble = false
private lateinit var assembleProp: ADProperties private lateinit var assembleProp: ADProperties
@@ -278,7 +279,7 @@ class SpriteAssemblerPreview: Game() {
} }
gdxClearAndSetBlend(.62f,.79f,1f,1f) gdxClearAndSetBlend(bgCol)
batch.inUse { batch.inUse {

View File

@@ -13,31 +13,32 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.FrameBuffer;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.ScreenUtils; import com.badlogic.gdx.utils.ScreenUtils;
import com.github.strikerx3.jxinput.XInputDevice; import com.github.strikerx3.jxinput.XInputDevice;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import net.torvald.util.ArrayListMap; import net.torvald.gdx.graphics.PixmapIO2;
import net.torvald.getcpuname.GetCpuName; import net.torvald.getcpuname.GetCpuName;
import net.torvald.terrarum.blockstats.MinimapComposer;
import net.torvald.terrarum.controller.GdxControllerAdapter; import net.torvald.terrarum.controller.GdxControllerAdapter;
import net.torvald.terrarum.controller.TerrarumController; import net.torvald.terrarum.controller.TerrarumController;
import net.torvald.terrarum.controller.XinputControllerAdapter; import net.torvald.terrarum.controller.XinputControllerAdapter;
import net.torvald.terrarum.gamecontroller.KeyToggler; import net.torvald.terrarum.gamecontroller.KeyToggler;
import net.torvald.terrarum.imagefont.TinyAlphNum; import net.torvald.terrarum.imagefont.TinyAlphNum;
import net.torvald.terrarum.modulebasegame.Ingame; import net.torvald.terrarum.modulebasegame.Ingame;
import net.torvald.terrarum.modulebasegame.IngameRenderer;
import net.torvald.terrarum.utils.JsonFetcher; import net.torvald.terrarum.utils.JsonFetcher;
import net.torvald.terrarum.utils.JsonWriter; import net.torvald.terrarum.utils.JsonWriter;
import net.torvald.terrarum.worlddrawer.BlocksDrawer; import net.torvald.terrarum.worlddrawer.BlocksDrawer;
import net.torvald.terrarum.worlddrawer.LightmapRenderer; import net.torvald.terrarum.worlddrawer.LightmapRenderer;
import net.torvald.terrarumsansbitmap.gdx.GameFontBase; import net.torvald.terrarumsansbitmap.gdx.GameFontBase;
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack; import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack;
import net.torvald.util.ArrayListMap;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.Random; import java.util.Random;
import static net.torvald.terrarum.TerrarumKt.gdxClearAndSetBlend; import static net.torvald.terrarum.TerrarumKt.gdxClearAndSetBlend;
@@ -181,7 +182,7 @@ public class AppLoader implements ApplicationListener {
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */ /** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
public static TerrarumController gamepad = null; public static TerrarumController gamepad = null;
public static float gamepadDeadzone = 0.2f; public static float gamepadDeadzone = 0.3f;
/** /**
@@ -205,9 +206,9 @@ public class AppLoader implements ApplicationListener {
try { processor = GetCpuName.getModelName(); } try { processor = GetCpuName.getModelName(); }
catch (IOException e1) { processor = "Unknown"; } catch (IOException e1) { processor = "Unknown CPU"; }
try { processorVendor = GetCpuName.getCPUID(); } try { processorVendor = GetCpuName.getCPUID(); }
catch (IOException e2) { processorVendor = "Unknown"; } catch (IOException e2) { processorVendor = "Unknown CPU"; }
ShaderProgram.pedantic = false; ShaderProgram.pedantic = false;
@@ -255,8 +256,8 @@ public class AppLoader implements ApplicationListener {
public static TextureRegion logo; public static TextureRegion logo;
public static AudioDevice audioDevice; public static AudioDevice audioDevice;
private Color gradWhiteTop = new Color(0xf8f8f8ff); private com.badlogic.gdx.graphics.Color gradWhiteTop = new com.badlogic.gdx.graphics.Color(0xf8f8f8ff);
private Color gradWhiteBottom = new Color(0xd8d8d8ff); private com.badlogic.gdx.graphics.Color gradWhiteBottom = new com.badlogic.gdx.graphics.Color(0xd8d8d8ff);
public Screen screen; public Screen screen;
public static int screenW = 0; public static int screenW = 0;
@@ -284,11 +285,15 @@ public class AppLoader implements ApplicationListener {
private FrameBuffer renderFBO; private FrameBuffer renderFBO;
public static CommonResourcePool resourcePool; public static CommonResourcePool resourcePool;
public static HashSet<File> tempFilePool = new HashSet();
public static HashSet<Disposable> disposableSingletonsPool = new HashSet();
@Override @Override
public void create() { public void create() {
resourcePool = CommonResourcePool.INSTANCE; resourcePool = CommonResourcePool.INSTANCE;
newTempFile("wenquanyi.tga"); // temp file required by the font
// set basis of draw // set basis of draw
logoBatch = new SpriteBatch(); logoBatch = new SpriteBatch();
@@ -376,13 +381,6 @@ public class AppLoader implements ApplicationListener {
} }
/**
* @link http://bilgin.esme.org/BitsAndBytes/KalmanFilterforDummies
*/
private void updateKalmanRenderDelta() {
// moved to LwjglGraphics
}
@Override @Override
public void render() { public void render() {
Gdx.gl.glDisable(GL20.GL_DITHER); Gdx.gl.glDisable(GL20.GL_DITHER);
@@ -520,11 +518,12 @@ public class AppLoader implements ApplicationListener {
screen.dispose(); screen.dispose();
} }
IngameRenderer.INSTANCE.dispose(); //IngameRenderer.INSTANCE.dispose();
PostProcessor.INSTANCE.dispose(); //PostProcessor.INSTANCE.dispose();
MinimapComposer.INSTANCE.dispose(); //MinimapComposer.INSTANCE.dispose();
//FloatDrawer.INSTANCE.dispose();
Terrarum.INSTANCE.dispose(); //Terrarum.INSTANCE.dispose();
shaderBayerSkyboxFill.dispose(); shaderBayerSkyboxFill.dispose();
shaderHicolour.dispose(); shaderHicolour.dispose();
@@ -542,10 +541,11 @@ public class AppLoader implements ApplicationListener {
textureWhiteCircle.dispose(); textureWhiteCircle.dispose();
logo.getTexture().dispose(); logo.getTexture().dispose();
disposableSingletonsPool.forEach(Disposable::dispose);
ModMgr.INSTANCE.disposeMods(); ModMgr.INSTANCE.disposeMods();
// delete temp files deleteTempfiles();
new File("./tmp_wenquanyi.tga").delete(); // FIXME this is pretty much ad-hoc
} }
@Override @Override
@@ -688,6 +688,7 @@ public class AppLoader implements ApplicationListener {
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem)); System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
System.out.println(String.format("os.version = %s", OSVersion)); System.out.println(String.format("os.version = %s", OSVersion));
System.out.println(String.format("default directory: %s", defaultDir)); System.out.println(String.format("default directory: %s", defaultDir));
System.out.println(String.format("java version = %s", System.getProperty("java.version")));
} }
private static void createDirs() { private static void createDirs() {
@@ -701,6 +702,17 @@ public class AppLoader implements ApplicationListener {
//dirs.forEach { if (!it.exists()) it.mkdirs() } //dirs.forEach { if (!it.exists()) it.mkdirs() }
} }
public static File newTempFile(String filename) {
File tempfile = new File("./tmp_" + filename);
tempFilePool.add(tempfile);
return tempfile;
}
private static void deleteTempfiles() {
for (File file : tempFilePool) {
file.delete();
}
}
// CONFIG // // CONFIG //

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import javax.naming.OperationNotSupportedException import net.torvald.gdx.graphics.Cvec
/** /**
* Created by minjaesong on 2017-06-17. * Created by minjaesong on 2017-06-17.
@@ -19,9 +19,11 @@ class GdxColorMap {
height = pixmap.height height = pixmap.height
is2D = pixmap.height > 1 is2D = pixmap.height > 1
data = kotlin.IntArray(pixmap.width * pixmap.height) { dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
pixmap.getPixel(it % pixmap.width, it / pixmap.width) pixmap.getPixel(it % pixmap.width, it / pixmap.width)
} }
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
pixmap.dispose() pixmap.dispose()
} }
@@ -31,39 +33,49 @@ class GdxColorMap {
height = pixmap.height height = pixmap.height
is2D = pixmap.height > 1 is2D = pixmap.height > 1
data = kotlin.IntArray(pixmap.width * pixmap.height) { dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
pixmap.getPixel(it % pixmap.width, it / pixmap.width) pixmap.getPixel(it % pixmap.width, it / pixmap.width)
} }
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
if (disposePixmap) pixmap.dispose() if (disposePixmap) pixmap.dispose()
} }
constructor(color: Color) { constructor(color: Color) {
data = intArrayOf(color.toIntBits()) dataRaw = intArrayOf(color.toIntBits())
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
width = 1 width = 1
height = 1 height = 1
is2D = false is2D = false
} }
constructor(gradStart: Color, gradEnd: Color) { constructor(gradStart: Color, gradEnd: Color) {
data = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits()) dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
dataCvec = dataRaw.map { Cvec(it) }.toTypedArray()
width = 1 width = 1
height = 2 height = 2
is2D = true is2D = true
} }
private val data: IntArray private val dataRaw: IntArray
private val dataGdxColor: Array<Color>
private val dataCvec: Array<Cvec>
val width: Int val width: Int
val height: Int val height: Int
val is2D: Boolean val is2D: Boolean
fun get(x: Int, y: Int): Color = Color(data[y * width + x]) fun get(x: Int, y: Int): Color = dataGdxColor[y * width + x]
operator fun get(x: Int): Color = if (is2D) throw OperationNotSupportedException("This is 2D color map") else Color(data[x]) operator fun get(x: Int): Color = if (is2D) throw UnsupportedOperationException("This is 2D color map") else dataGdxColor[x]
fun getRaw(x: Int, y: Int): RGBA8888 = data[y * width + x] fun getRaw(x: Int, y: Int): RGBA8888 = dataRaw[y * width + x]
fun getRaw(x: Int): RGBA8888 = if (is2D) throw OperationNotSupportedException("This is 2D color map") else data[x] fun getRaw(x: Int): RGBA8888 = if (is2D) throw UnsupportedOperationException("This is 2D color map") else dataRaw[x]
//fun getAsCvec(x: Int, y: Int): Cvec = dataCvec[y * width + x]
override fun toString(): String { override fun toString(): String {
val sb = StringBuilder() val sb = StringBuilder()

View File

@@ -7,7 +7,7 @@ import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
import com.badlogic.gdx.graphics.* import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.jme3.math.FastMath import com.badlogic.gdx.graphics.Color
import net.torvald.terrarumsansbitmap.gdx.GameFontBase import net.torvald.terrarumsansbitmap.gdx.GameFontBase
/** /**

View File

@@ -3,13 +3,13 @@ package net.torvald.terrarum
import com.badlogic.gdx.Screen import com.badlogic.gdx.Screen
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Queue import com.badlogic.gdx.utils.Queue
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.realestate.LandUtil import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.ui.ConsoleWindow import net.torvald.terrarum.ui.ConsoleWindow
import net.torvald.util.SortedArrayList import net.torvald.util.SortedArrayList
import java.util.*
import java.util.concurrent.locks.Lock import java.util.concurrent.locks.Lock
/** /**
@@ -75,7 +75,15 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
override fun resize(width: Int, height: Int) { override fun resize(width: Int, height: Int) {
} }
/**
* You ABSOLUTELY must call this in your child classes (```super.dispose()```) and the AppLoader to properly
* dispose of the world, which uses unsafe memory allocation.
* Failing to do this will result to a memory leak!
*/
override fun dispose() { override fun dispose() {
printdbg(this, "Thank you for properly disposing the world!")
world.dispose()
} }
//////////// ////////////
@@ -95,16 +103,18 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
} }
/** /**
* I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
*
* Event for triggering held item's `startSecondaryUse(Float)` * Event for triggering held item's `startSecondaryUse(Float)`
*/ */
open fun worldSecondaryClickStart(delta: Float) { //open fun worldSecondaryClickStart(delta: Float) { }
}
/** /**
* I have decided that left and right clicks must do the same thing, so no secondary use from now on. --Torvald on 2019-05-26
*
* Event for triggering held item's `endSecondaryUse(Float)` * Event for triggering held item's `endSecondaryUse(Float)`
*/ */
open fun worldSecondaryClickEnd(delta: Float) { //open fun worldSecondaryClickEnd(delta: Float) { }
}
/** /**
* Event for triggering fixture update when something is placed/removed on the world. * Event for triggering fixture update when something is placed/removed on the world.
@@ -127,6 +137,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
/** /**
* Wire version of terrainChanged() event * Wire version of terrainChanged() event
*
* @param old previous settings of conduits in bit set format.
* @param new current settings of conduits in bit set format.
*/ */
open fun queueWireChangedEvent(old: Int, new: Int, position: Long) { open fun queueWireChangedEvent(old: Int, new: Int, position: Long) {
val (x, y) = LandUtil.resolveBlockAddr(world, position) val (x, y) = LandUtil.resolveBlockAddr(world, position)
@@ -143,11 +156,11 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
if (actorContainerActive.size == 0 && actorContainerInactive.size == 0) if (actorContainerActive.size == 0 && actorContainerInactive.size == 0)
throw IllegalArgumentException("Actor with ID $ID does not exist.") throw IllegalArgumentException("Actor with ID $ID does not exist.")
var index = actorContainerActive.binarySearch(ID) var actor = actorContainerActive.searchFor(ID) { it.referenceID!! }
if (index < 0) { if (actor == null) {
index = actorContainerInactive.binarySearch(ID) actor = actorContainerInactive.searchFor(ID) { it.referenceID!! }
if (index < 0) { if (actor == null) {
/*JOptionPane.showMessageDialog( /*JOptionPane.showMessageDialog(
null, null,
"Actor with ID $ID does not exist.", "Actor with ID $ID does not exist.",
@@ -156,36 +169,14 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
throw IllegalArgumentException("Actor with ID $ID does not exist.") throw IllegalArgumentException("Actor with ID $ID does not exist.")
} }
else else
return actorContainerInactive[index] return actor
} }
else else
return actorContainerActive[index] return actor
} }
fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID!!) //fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID!!)
//fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
fun ArrayList<*>.binarySearch(ID: Int): Int {
// code from collections/Collections.kt
var low = 0
var high = this.size - 1
while (low <= high) {
val mid = (low + high).ushr(1) // safe from overflows
val midVal = get(mid)!!
if (ID > midVal.hashCode())
low = mid + 1
else if (ID < midVal.hashCode())
high = mid - 1
else
return mid // key found
}
return -(low + 1) // key not found
}
fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID!!)
fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
open fun removeActor(ID: Int) = removeActor(getActorByID(ID)) open fun removeActor(ID: Int) = removeActor(getActorByID(ID))
/** /**
@@ -199,9 +190,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
open fun removeActor(actor: Actor?) { open fun removeActor(actor: Actor?) {
if (actor == null) return if (actor == null) return
val indexToDelete = actorContainerActive.binarySearch(actor.referenceID!!) val indexToDelete = actorContainerActive.searchFor(actor.referenceID!!) { it.referenceID!! }
if (indexToDelete >= 0) { if (indexToDelete != null) {
actorContainerActive.removeAt(indexToDelete) actorContainerActive.remove(indexToDelete)
} }
} }
@@ -223,13 +214,13 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
if (actorContainerActive.size == 0) if (actorContainerActive.size == 0)
false false
else else
actorContainerActive.binarySearch(ID) >= 0 actorContainerActive.searchFor(ID) { it.referenceID!! } != null
fun isInactive(ID: Int): Boolean = fun isInactive(ID: Int): Boolean =
if (actorContainerInactive.size == 0) if (actorContainerInactive.size == 0)
false false
else else
actorContainerInactive.binarySearch(ID) >= 0 actorContainerInactive.searchFor(ID) { it.referenceID!! } != null
/** /**
* actorContainerActive extensions * actorContainerActive extensions

View File

@@ -4,9 +4,9 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.AppLoader.*
import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.itemproperties.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.itemproperties.MaterialCodex import net.torvald.terrarum.itemproperties.MaterialCodex
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.utils.CSVFetcher

View File

@@ -11,13 +11,15 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.badlogic.gdx.math.Matrix4 import com.badlogic.gdx.math.Matrix4
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.gamecontroller.KeyToggler import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.ui.BasicDebugInfoWindow import net.torvald.terrarum.ui.BasicDebugInfoWindow
import net.torvald.terrarum.worlddrawer.BlocksDrawer
/** /**
* Must be called by the App Loader * Must be called by the App Loader
*/ */
object PostProcessor { object PostProcessor : Disposable {
private lateinit var batch: SpriteBatch // not nulling to save some lines of code private lateinit var batch: SpriteBatch // not nulling to save some lines of code
private lateinit var shapeRenderer: ShapeRenderer private lateinit var shapeRenderer: ShapeRenderer
@@ -37,7 +39,13 @@ object PostProcessor {
private val debugUI = BasicDebugInfoWindow() private val debugUI = BasicDebugInfoWindow()
fun dispose() { private var functionRowHelper = Texture(Gdx.files.internal("assets/graphics/function_row_help.png"))
init {
AppLoader.disposableSingletonsPool.add(this)
}
override fun dispose() {
batch.dispose() batch.dispose()
shapeRenderer.dispose() shapeRenderer.dispose()
try { try {
@@ -78,6 +86,25 @@ object PostProcessor {
drawSafeArea() drawSafeArea()
} }
if (KeyToggler.isOn(Input.Keys.F1)) {
batch.color = Color.WHITE
batch.inUse {
it.draw(functionRowHelper,
(AppLoader.screenW - functionRowHelper.width) / 2f,
functionRowHelper.height.toFloat(),
functionRowHelper.width.toFloat(),
functionRowHelper.height * -1f
)
}
}
if (KeyToggler.isOn(Input.Keys.F10)) {
batch.color = Color.WHITE
batch.inUse {
AppLoader.fontSmallNumbers.draw(it, "Wire draw bits: ${BlocksDrawer.drawWires.toString(2)}", 2f, 2f)
}
}
if (KeyToggler.isOn(Input.Keys.F3)) { if (KeyToggler.isOn(Input.Keys.F3)) {
if (!debugUI.isOpened && !debugUI.isOpening) debugUI.setAsOpen() if (!debugUI.isOpened && !debugUI.isOpening) debugUI.setAsOpen()
batch.inUse { debugUI.renderUI(batch, camera) } batch.inUse { debugUI.renderUI(batch, camera) }

View File

@@ -10,9 +10,9 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.badlogic.gdx.utils.Disposable
import com.badlogic.gdx.utils.GdxRuntimeException import com.badlogic.gdx.utils.GdxRuntimeException
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.util.CircularArray
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.AppLoader.*
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
@@ -23,6 +23,7 @@ import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.GameFontBase import net.torvald.terrarumsansbitmap.gdx.GameFontBase
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.util.CircularArray
import org.lwjgl.BufferUtils import org.lwjgl.BufferUtils
import java.io.File import java.io.File
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
@@ -37,7 +38,7 @@ typealias RGBA8888 = Int
* *
* LibGDX Version Created by minjaesong on 2017-06-15. * LibGDX Version Created by minjaesong on 2017-06-15.
*/ */
object Terrarum : Screen { object Terrarum : Screen, Disposable {
/** /**
* All singleplayer "Player" must have this exact reference ID. * All singleplayer "Player" must have this exact reference ID.
@@ -196,7 +197,6 @@ object Terrarum : Screen {
init { init {
println("$NAME version ${AppLoader.getVERSION_STRING()}") println("$NAME version ${AppLoader.getVERSION_STRING()}")
println("Java Runtime version ${System.getProperty("java.version")}")
println("LibGDX version ${com.badlogic.gdx.Version.VERSION}") println("LibGDX version ${com.badlogic.gdx.Version.VERSION}")
@@ -213,6 +213,9 @@ object Terrarum : Screen {
setGamepadButtonLabels() setGamepadButtonLabels()
AppLoader.disposableSingletonsPool.add(this)
} }
private fun setGamepadButtonLabels() { private fun setGamepadButtonLabels() {
@@ -613,6 +616,10 @@ fun blendNormal(batch: SpriteBatch) {
// - https://www.andersriggelsen.dk/glblendfunc.php // - https://www.andersriggelsen.dk/glblendfunc.php
} }
fun gdxClearAndSetBlend(color: Color) {
gdxClearAndSetBlend(color.r, color.g, color.b, color.a)
}
fun gdxClearAndSetBlend(r: Float, g: Float, b: Float, a: Float) { fun gdxClearAndSetBlend(r: Float, g: Float, b: Float, a: Float) {
Gdx.gl.glClearColor(r,g,b,a) Gdx.gl.glClearColor(r,g,b,a)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)

View File

@@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.badlogic.gdx.graphics.Color
import net.torvald.terrarumsansbitmap.gdx.GameFontBase import net.torvald.terrarumsansbitmap.gdx.GameFontBase

View File

@@ -27,12 +27,10 @@ import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConYaml
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
import net.torvald.terrarum.serialise.ReadLayerData
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.worlddrawer.CreateTileAtlas import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarum.worlddrawer.LightmapRenderer import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarum.worlddrawer.WorldCamera
import java.io.FileInputStream
/** /**
* Created by minjaesong on 2017-09-02. * Created by minjaesong on 2017-09-02.
@@ -129,7 +127,10 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
printdbg(this, "Intro pre-load") printdbg(this, "Intro pre-load")
demoWorld = ReadLayerData(FileInputStream(ModMgr.getFile("basegame", "demoworld"))) demoWorld = GameWorldExtension(1, 64, 64, 0L, 0L, 0)
printdbg(this, "Demo world gen complete")
// set time to summer // set time to summer
demoWorld.time.addTime(WorldTime.DAY_LENGTH * 32) demoWorld.time.addTime(WorldTime.DAY_LENGTH * 32)
@@ -138,14 +139,14 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
cameraNodes = kotlin.FloatArray(nodeCount) { it -> cameraNodes = kotlin.FloatArray(nodeCount) { it ->
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt() val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt()
var travelDownCounter = 0 var travelDownCounter = 0
while (!BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid) { while (travelDownCounter < demoWorld.height && !BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid) {
travelDownCounter += 4 travelDownCounter += 4
} }
travelDownCounter * CreateTileAtlas.TILE_SIZE.toFloat() travelDownCounter * CreateTileAtlas.TILE_SIZE.toFloat()
} }
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) { cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false) {
init { init {
setHitboxDimension(2, 2, 0, 0) setHitboxDimension(2, 2, 0, 0)
hitbox.setPosition( hitbox.setPosition(

View File

@@ -5,12 +5,13 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.Ingame import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText
import net.torvald.terrarum.ui.UIItemTextButton import net.torvald.terrarum.ui.UIItemTextButton
/*** /***
@@ -90,6 +91,8 @@ class UIItemInventoryElem(
if (item != null && itemImage != null) { if (item != null && itemImage != null) {
val amountString = amount.toItemCountText()
blendNormal(batch) blendNormal(batch)
// item image // item image
@@ -103,7 +106,7 @@ class UIItemInventoryElem(
if (AppLoader.IS_DEVELOPMENT_BUILD) { if (AppLoader.IS_DEVELOPMENT_BUILD) {
Terrarum.fontGame.draw(batch, Terrarum.fontGame.draw(batch,
// print static id, dynamic id, and count // print static id, dynamic id, and count
"${item!!.originalID}/${item!!.dynamicID}" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else ""), "${item!!.originalID}/${item!!.dynamicID}" + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else ""),
posX + textOffsetX, posX + textOffsetX,
posY + textOffsetY posY + textOffsetY
) )
@@ -111,7 +114,7 @@ class UIItemInventoryElem(
else { else {
Terrarum.fontGame.draw(batch, Terrarum.fontGame.draw(batch,
// print name and amount in parens // print name and amount in parens
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") + item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else "") +
// TEMPORARY print eqipped slot info as well // TEMPORARY print eqipped slot info as well
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""), (if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
@@ -188,7 +191,7 @@ class UIItemInventoryElem(
// equip da shit // equip da shit
val itemEquipSlot = item!!.equipPosition val itemEquipSlot = item!!.equipPosition
if (itemEquipSlot == GameItem.EquipPosition.NULL) { if (itemEquipSlot == GameItem.EquipPosition.NULL) {
TODO("Equip position is NULL, does this mean it's single-consume items like a potion?") TODO("Equip position is NULL, does this mean it's single-consume items like a potion? (from item: \"$item\" with itemID: ${item?.originalID}/${item?.dynamicID})")
} }
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying val player = (Terrarum.ingame!! as Ingame).actorNowPlaying

View File

@@ -5,12 +5,13 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.itemproperties.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.Ingame import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText
import net.torvald.terrarum.ui.UIItemTextButton import net.torvald.terrarum.ui.UIItemTextButton
/** /**
@@ -107,7 +108,7 @@ class UIItemInventoryElemSimple(
} }
// draw item count when applicable // draw item count when applicable
else if (item!!.stackable) { else if (item!!.stackable) {
val amountString = amount.toString() val amountString = amount.toItemCountText()
// highlight item count (blocks/walls) if the item is equipped // highlight item count (blocks/walls) if the item is equipped
if (equippedSlot != null) { if (equippedSlot != null) {

View File

@@ -116,7 +116,7 @@ object Block {
const val DAYLIGHT_CAPACITOR = 258 const val DAYLIGHT_CAPACITOR = 258
const val ACTORBLOCK_NO_COLLISION = 4191 const val ACTORBLOCK_NO_COLLISION = 4091
const val ACTORBLOCK_FULL_COLLISION = 4092 const val ACTORBLOCK_FULL_COLLISION = 4092
const val ACTORBLOCK_ALLOW_MOVE_DOWN = 4093 const val ACTORBLOCK_ALLOW_MOVE_DOWN = 4093
const val ACTORBLOCK_NO_PASS_RIGHT = 4094 const val ACTORBLOCK_NO_PASS_RIGHT = 4094
@@ -127,4 +127,12 @@ object Block {
const val WATER = 4095 const val WATER = 4095
const val NULL = -1 const val NULL = -1
val actorblocks = listOf(
ACTORBLOCK_NO_COLLISION,
ACTORBLOCK_FULL_COLLISION,
ACTORBLOCK_ALLOW_MOVE_DOWN,
ACTORBLOCK_NO_PASS_RIGHT,
ACTORBLOCK_NO_PASS_LEFT
)
} }

View File

@@ -1,12 +1,10 @@
package net.torvald.terrarum.blockproperties package net.torvald.terrarum.blockproperties
import com.badlogic.gdx.graphics.Color import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.AppLoader.printmsg import net.torvald.terrarum.AppLoader.printmsg
import net.torvald.terrarum.gameworld.FluidType import net.torvald.terrarum.gameworld.FluidType
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.MapLayer
import net.torvald.terrarum.gameworld.PairedMapLayer
import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.utils.CSVFetcher
import net.torvald.terrarum.worlddrawer.LightmapRenderer import net.torvald.terrarum.worlddrawer.LightmapRenderer
import org.apache.commons.csv.CSVRecord import org.apache.commons.csv.CSVRecord
@@ -20,7 +18,7 @@ object BlockCodex {
private var blockProps = HashMap<Int, BlockProp>() private var blockProps = HashMap<Int, BlockProp>()
/** 4096 */ /** 4096 */
const val MAX_TERRAIN_TILES = MapLayer.RANGE * PairedMapLayer.RANGE const val MAX_TERRAIN_TILES = GameWorld.TILES_SUPPORTED
private val nullProp = BlockProp() private val nullProp = BlockProp()
@@ -110,7 +108,7 @@ object BlockCodex {
prop.shadeColG = floatVal(record, "shdg") / LightmapRenderer.MUL_FLOAT prop.shadeColG = floatVal(record, "shdg") / LightmapRenderer.MUL_FLOAT
prop.shadeColB = floatVal(record, "shdb") / LightmapRenderer.MUL_FLOAT prop.shadeColB = floatVal(record, "shdb") / LightmapRenderer.MUL_FLOAT
prop.shadeColA = floatVal(record, "shduv") / LightmapRenderer.MUL_FLOAT prop.shadeColA = floatVal(record, "shduv") / LightmapRenderer.MUL_FLOAT
prop.opacity = Color(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA) prop.opacity = Cvec(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
prop.strength = intVal(record, "str") prop.strength = intVal(record, "str")
prop.density = intVal(record, "dsty") prop.density = intVal(record, "dsty")
@@ -119,7 +117,7 @@ object BlockCodex {
prop.lumColG = floatVal(record, "lumg") / LightmapRenderer.MUL_FLOAT prop.lumColG = floatVal(record, "lumg") / LightmapRenderer.MUL_FLOAT
prop.lumColB = floatVal(record, "lumb") / LightmapRenderer.MUL_FLOAT prop.lumColB = floatVal(record, "lumb") / LightmapRenderer.MUL_FLOAT
prop.lumColA = floatVal(record, "lumuv") / LightmapRenderer.MUL_FLOAT prop.lumColA = floatVal(record, "lumuv") / LightmapRenderer.MUL_FLOAT
prop.internalLumCol = Color(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA) prop.internalLumCol = Cvec(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
prop.friction = intVal(record, "fr") prop.friction = intVal(record, "fr")
prop.viscosity = intVal(record, "vscs") prop.viscosity = intVal(record, "vscs")

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.blockproperties package net.torvald.terrarum.blockproperties
import com.badlogic.gdx.graphics.Color import net.torvald.gdx.graphics.Cvec
/** /**
* Created by minjaesong on 2016-02-16. * Created by minjaesong on 2016-02-16.
@@ -17,7 +17,7 @@ class BlockProp {
var shadeColB = 0f var shadeColB = 0f
var shadeColA = 0f var shadeColA = 0f
lateinit var opacity: Color lateinit var opacity: Cvec
var strength: Int = 0 var strength: Int = 0
var density: Int = 0 var density: Int = 0
@@ -36,12 +36,12 @@ class BlockProp {
var lumColG = 0f var lumColG = 0f
var lumColB = 0f var lumColB = 0f
var lumColA = 0f var lumColA = 0f
lateinit var internalLumCol: Color lateinit var internalLumCol: Cvec
/** /**
* @param luminosity * @param luminosity
*/ */
inline val luminosity: Color inline val luminosity: Cvec
get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction) get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction)
var drop: Int = 0 var drop: Int = 0

Some files were not shown because too many files have changed in this diff Show More