Auto Tiling Kollisionen spielen verrückt

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Auto Tiling Kollisionen spielen verrückt

    Servus gm-d Community,
    Ich habe vor kurzem das Layout von meinen Tileset sheets geändert, weshalb ich auch entsprechend das Script anpassen musste.
    Vorher hatte ich das Ganze mathematisch geordnet (Nach dem Binärsystem, Oben Links beginnend), nun allerdings in einem optisch schöneren und leichter zusammzustellbaren Format.

    Entsprechend musste ich meinen Code anpassen.

    Nun habe ich allerdings das Problem das die Kollisonsüberprüfungen eigenartige Ergebnisse liefern, weshalb auch das Tiling nicht mehr ganz will.
    Der wesentliche Unterschied ist, dass ich die Tilegröße von 32 auf 16 pixel reduziert habe, wofür ich mir allerdings extra ein Attribut bereit gestellt hatte.

    Ich denke mal nicht das es nötig ist, dass ihr euch jeden Fall einzeln anguckt, da diese an sich stimmen sollten.
    Das einzige Problem sind meine Kollisionen, wie der debug Modus schön zeigt.

    Ich hoffe, dass ihr irgendwo Logikfehler finden könnt.
    Spoiler anzeigen

    GML-Quellcode

    1. var dst, obj, U, D, L, R, UL, UR, DL, DR;
    2. dst = 16; //Distance between each other
    3. obj = object_index; //Only autotile with instances like yourself
    4. U = instance_position(x,y-dst,obj); //Up
    5. D = instance_position(x,y+dst,obj); //Down
    6. L = instance_position(x-dst,y,obj); //Left
    7. R = instance_position(x+dst,y,obj); //Right
    8. UL = instance_position(x-dst,y-dst,obj); //UpLeft
    9. UR = instance_position(x+dst,y-dst,obj); //UpRight
    10. DL = instance_position(x-dst,y+dst,obj); //DownLeft
    11. DR = instance_position(x+dst,y+dst,obj); //DownRight
    12. image_speed = 0; //Don't play the animation
    13. //Cases Start//
    14. // Block'o'9
    15. if (!U && D && !L && R && !UL && !UR && !DL && DR)
    16. {
    17. image_index = 0;
    18. }
    19. if (!U && (D) && (L) && (R) && !UL && !UR && (DL) && (DR))
    20. {
    21. image_index = 1;
    22. }
    23. if (!U && (D) && (L) && !R && !UL && !UR && (DL) && !DR)
    24. {
    25. image_index = 2;
    26. }
    27. if ((U) && (D) && !L && (R) && !UL && (UR) && !DL && (DR))
    28. {
    29. image_index = 15;
    30. }
    31. if ((U) && (D) && (L) && (R) && (UL) && (UR) && (DL) && (DR))
    32. {
    33. image_index = 16;
    34. }
    35. if ((U) && (D) && (L) && !R && (UL) && !UR && (DL) && !DR)
    36. {
    37. image_index = 17;
    38. }
    39. if ((U) && !D && !L && (R) && !UL && (UR) && !DL && !DR)
    40. {
    41. image_index = 30;
    42. }
    43. if ((U) && !D && (L) && (R) && (UL) && (UR) && !DL && !DR)
    44. {
    45. image_index = 31;
    46. }
    47. if((U) && !D && (L) && !R && (UL) && !UR && !DL && !DR)
    48. {
    49. image_index = 32;
    50. }
    51. //Platform Horizontal
    52. if (!U && !D && !L && (R) && !UL && !UR && !DL && !DR)
    53. {
    54. image_index = 3;
    55. }
    56. if (!U && !D && (L) && (R) && !UL && !UR && !DL && !DR)
    57. {
    58. image_index = 4;
    59. }
    60. if (!U && !D && (L) && !R && !UL && !UR && !DL && !DR)
    61. {
    62. image_index = 5;
    63. }
    64. //Edge + Inner Edge
    65. if (!U && (D) && !L && (R) && !UL && !UR && !DL && !DR)
    66. {
    67. image_index = 18;
    68. }
    69. if (!U && (D) && (L) && !R && !UL && !UR && !DL && !DR)
    70. {
    71. image_index = 19;
    72. }
    73. if ((U) && !D && !L && (R) && !UL && !UR && !DL && !DR)
    74. {
    75. image_index = 33;
    76. }
    77. if ((U) && !D && (L) && !R && !UL && !UR && !DL && !DR)
    78. {
    79. image_index = 34;
    80. }
    81. //image_index 35 is free
    82. //Single Platform
    83. if (!U && !D && !L && !R && !UL && !UR && !DL && !DR)
    84. {
    85. image_index = 20;
    86. }
    87. //Platform Vertical
    88. if (!U && (D) && !L && !R && !UL && !UR && !DL && !DR)
    89. {
    90. image_index = 6;
    91. }
    92. if ((U) && (D) && !L && !R && !UL && !UR && !DL && !DR)
    93. {
    94. image_index = 21;
    95. }
    96. if ((U) && !D && !L && !R && !UL && !UR && !DL && !DR)
    97. {
    98. image_index = 36;
    99. }
    100. //T Crossings
    101. if ((U) && (D) && (L) && !R && !UL && !UR && !DL && !DR)
    102. {
    103. image_index = 7;
    104. }
    105. if ((U) && (D) && (L) && !R && (UL) && !UR && !DL && !DR)
    106. {
    107. image_index = 8;
    108. }
    109. if ((U) && (D) && (L) && !R && !UL && !UR && (DL) && !DR)
    110. {
    111. image_index = 9;
    112. }
    113. if ((U) && !D && (L) && (R) && !UL && !UR && !DL && !DR)
    114. {
    115. image_index = 22;
    116. }
    117. if ((U) && !D && (L) && (R) && (UL) && !UR && !DL && !DR)
    118. {
    119. image_index = 23;
    120. }
    121. if ((U) && !D && (L) && (R) && !UL && (UR) && !DL && !DR)
    122. {
    123. image_index = 24;
    124. }
    125. if ((U) && (D) && !L && (R) && !UL && !UR && !DL && !DR)
    126. {
    127. image_index = 37;
    128. }
    129. if ((U) && (D) && !L && (R) && !UL && (UR) && !DL && !DR)
    130. {
    131. image_index = 38;
    132. }
    133. if ((U) && (D) && !L && (R) && !UL && !UR && !DL && (DR))
    134. {
    135. image_index = 39;
    136. }
    137. if (!U && (D) && (L) && (R) && !UL && !UR && !DL && !DR)
    138. {
    139. image_index = 52;
    140. }
    141. if (!U && (D) && (L) && (R) && !UL && !UR && (DL) && !DR)
    142. {
    143. image_index = 53;
    144. }
    145. if (!U && (D) && (L) && (R) &&!UL && !UR && !DL && (DR))
    146. {
    147. image_index = 54;
    148. }
    149. // image_index 10 is free
    150. // image_index 25 is free
    151. // image_index 40 is free
    152. // image_index 55 is free
    153. //Additional Inner Edges
    154. if ((U) && (D) && (L) && (R) && !UL && !UR && !DL && !DR)
    155. {
    156. image_index = 11;
    157. }
    158. if ((U) && (D) && (L) && (R) && (UL) && !UR && !DL && !DR)
    159. {
    160. image_index = 12;
    161. }
    162. if ((U) && (D) && (L) && (R) && !UL && (UR) && !DL && !DR)
    163. {
    164. image_index = 13;
    165. }
    166. if ((U) && (D) && (L) && (R) && (UL) && (UR) && !DL && !DR)
    167. {
    168. image_index = 14;
    169. }
    170. if ((U) && (D) && (L) && (R) && !UL && !UR && (DL) && !DR)
    171. {
    172. image_index = 26;
    173. }
    174. if ((U) && (D) && (L) && (R) && (UL) && !UR && (DL) && !DR)
    175. {
    176. image_index = 27;
    177. }
    178. if ((U) && (D) && (L) && (R) && !UL && (UR) && (DL) && !DR)
    179. {
    180. image_index = 28;
    181. }
    182. if ((U) && (D) && (L) && (R) && (UL) && (UR) && (DL) && !DR)
    183. {
    184. image_index = 29;
    185. }
    186. if ((U) && (D) && (L) && (R) && !UL && !UR && !DL && (DR))
    187. {
    188. image_index = 41;
    189. }
    190. if ((U) && (D) && (L) && (R) && (UL) && !UR && !DL && (DR))
    191. {
    192. image_index = 42;
    193. }
    194. if ((U) && (D) && (L) && (R) && !UL && (UR) && !DL && (DR))
    195. {
    196. image_index = 43;
    197. }
    198. if ((U) && (D) && (L) && (R) && (UL) && (UR) && !DL && (DR))
    199. {
    200. image_index = 44;
    201. }
    202. if ((U) && (D) && (L) && (R) && !UL && !UR && (DL) && (DR))
    203. {
    204. image_index = 56;
    205. }
    206. if ((U) && (D) && (L) && (R) && (UL) && !UR && (DL) && (DR))
    207. {
    208. image_index = 57;
    209. }
    210. if ((U) && (D) && (L) && (R) && !UL && (UR) && (DL) && (DR))
    211. {
    212. image_index = 58;
    213. }
    214. //image_index 59 is the same as 16
    215. // image_index 45-51 is free
    Alles anzeigen


    Ich rufe das Script nach einer Sekunde (room_speed) auf, um sicher zu gehen, dass alle Block Instanzen bereits platziert sind.


    EDIT: @instance_position: Das war jetzt bis zuletzt noch ein Versuch, in der Hoffnung dass andere Ergebnisse ausgespuckt werden. Jedoch wurde auch das nichts. Normalerweise habe ich place_meeting benutzt, wobei das ergebniss ja in beiden fallen logischer weise gleich sein muss.. Entweder null oder eben nicht null.

    MfG,
    Yivo

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von Yivo ()

  • was spricht denn gegen eine Bitweise Errechnung der Tilepositionen?

    Den Artikel musste ich zwar tief aus meinen Erinnerungen holen, erklärt das Prinzip aber ziemlich gut und ist eigentlich leicht verständlich:
    saltgames.com/2010/a-bitwise-method-for-applying-tilemaps/
    Ist auch relativ leicht im Game Maker umsetzbar.

    Im übrigen ist Code, der über 200 Zeilen ausschließlich aus if Abfragen besteht, enorm überdimensioniert und ineffizient.
  • Ich bin gerade dabei sämtliche Tilesets an Leute zu verkaufen, welche allerdings nie mit den Bit Layout klar kommen.
    Klar, zum einen kann man sagen, dass sie wissen sollten, was sie kaufen, aber zum anderen wollte ich denen halt ein verständliches Format liefern, einfach nur um die Arbeit für beide Seiten zu erleichtern.
    Und ja, ich würde hier und da im Code noch eine Menge kürzen und verschachteln können, aber dafür wollte ich erstmal, dass eben das Grundlegende wieder funktioniert.
    Das verrückte daran ist ja, dass das Ganze vorher schon perfekt lief.
    Bei der abgeänderten Version spielen wiederrum die Kollisionen verrückt.

    MfG
    Yivo

    EDIT: Argh.. Mein Problem war ein dämlicher Denkfehler..
    In machen Fällen spielen die diagonalen Kollisionen überhaupt keine Rolle (z.B. bei einzelnen Plattformen), weshalb dann keine Abfrage zutraf und das Ergebnis wie entsprechend war.

    Somit sollten wir hier fertig sein ^^ Danke.

    MfG,
    Yivo

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von Yivo () aus folgendem Grund: Gramm0r