random visible und out

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

  • random visible und out

    GML-Quellcode

    1. global.Turn = 1 /// Spieler am Zug
    2. global.Turn = 0 /// Computer am Zug Code unten




    GML-Quellcode

    1. if (global.Turn==0)
    2. {
    3. global.select = choose(0,1,2,3,4,5,6,7,8)
    4. {
    5. if (global.select == 0)
    6. {
    7. if object_exists(obj_Kreis_0)
    8. {
    9. obj_Kreis_0.visible = true
    10. global.Turn = 1
    11. exit;
    12. }
    13. else
    14. {
    15. exit;
    16. }
    17. }
    18. }
    19. {
    20. if (global.select == 1)
    21. {
    22. if object_exists(obj_Kreis_1)
    23. {
    24. obj_Kreis_1.visible = true
    25. global.Turn = 1
    26. exit;
    27. }
    28. else
    29. {
    30. exit;
    31. }
    32. }
    33. }
    34. {
    35. if (global.select == 2)
    36. {
    37. if object_exists(obj_Kreis_2)
    38. {
    39. obj_Kreis_2.visible = true
    40. global.Turn = 1
    41. exit;
    42. }
    43. else
    44. {
    45. exit;
    46. }
    47. }
    48. }
    49. {
    50. if (global.select == 3)
    51. {
    52. if object_exists(obj_Kreis_3)
    53. {
    54. obj_Kreis_1.visible = true
    55. global.Turn = 1
    56. exit;
    57. }
    58. else
    59. {
    60. exit;
    61. }
    62. }
    63. }
    64. {
    65. if (global.select == 4)
    66. {
    67. if object_exists(obj_Kreis_4)
    68. {
    69. obj_Kreis_4.visible = true
    70. global.Turn = 1
    71. exit;
    72. }
    73. else
    74. {
    75. exit;
    76. }
    77. }
    78. }
    79. if (global.select == 5)
    80. {
    81. if object_exists(obj_Kreis_5)
    82. {
    83. obj_Kreis_5.visible = true
    84. global.Turn += 1
    85. exit;
    86. }
    87. else
    88. {
    89. exit;
    90. }
    91. }
    92. {
    93. if (global.select == 6)
    94. {
    95. if object_exists(obj_Kreis_6)
    96. {
    97. obj_Kreis_6.visible = true
    98. global.Turn += 1
    99. exit;
    100. }
    101. else
    102. {
    103. exit;
    104. }
    105. }
    106. }
    107. {
    108. if (global.select == 7)
    109. {
    110. if object_exists(obj_Kreis_7)
    111. {
    112. obj_Kreis_7.visible = true
    113. global.Turn = 1
    114. exit;
    115. }
    116. else
    117. {
    118. exit;
    119. }
    120. }
    121. }
    122. {
    123. if (global.select == 8)
    124. {
    125. if object_exists(obj_Kreis_8)
    126. {
    127. obj_Kreis_8.visible = true
    128. global.Turn = 1
    129. exit;
    130. }
    131. else
    132. {
    133. exit;
    134. }
    135. }
    136. }
    137. }
    Alles anzeigen


    Am anfang ist global.Turn = 1 und der Spieler clickt auf ein Feld (Tic-Tac-Toe), wobei das Kreuz auf diesem Feld visible wird.

    GML-Quellcode

    1. if (global.Turn==1)
    2. {
    3. obj_Kreuz_0.visible = true;
    4. with (obj_Kreis_0)
    5. {
    6. instance_destroy();
    7. }
    8. global.Turn = 0;
    9. }

    dieser auf alle 9 Kreuze wie bei den Kreisen, einfach beim Objekt mit mouse left press Event.

    Wenn ich auf ein Kreuz drücke, gehen zwei oder gar drei Kreise visible, obwohl ich die Variable wieder auf global.Turn =0 gesetzt habe. und wenn ich dann wieder ein Kreuz setzte, geht das Programm nicht mehr weiter... wenn man das Problem nicht versteht einfach nochmals fragen, versuche es dann besser zu veranschaulichen. Es soll einfach wenn ein obj_Kreis visible wird, die Variable auf 1 gesetzt werden, dass das Kreuz gesetzt werden kann.
  • GML-Quellcode

    1. if (global.Turn == 0)
    2. {
    3. global.select = choose(0,1,2,3,4,5,6,7,8)
    4. {
    5. if (global.select == 0)
    6. {
    7. if instance_exists(obj_Kreis_0)
    8. {
    9. obj_Kreis_0.visible = true;
    10. with (obj_Kreuz_0)
    11. {
    12. instance_destroy();
    13. }
    14. global.Turn = 1;
    15. }
    16. else
    17. {
    18. exit;
    19. }
    20. }
    21. }
    22. {
    23. if (global.select == 1)
    24. {
    25. if instance_exists(obj_Kreis_1)
    26. {
    27. obj_Kreis_1.visible = true;
    28. with (obj_Kreuz_1)
    29. {
    30. instance_destroy();
    31. }
    32. global.Turn = 1;
    33. }
    34. else
    35. {
    36. exit;
    37. }
    38. }
    39. }
    40. {
    41. if (global.select == 2)
    42. {
    43. if instance_exists(obj_Kreis_2)
    44. {
    45. obj_Kreis_2.visible = true;
    46. with (obj_Kreuz_2)
    47. {
    48. instance_destroy();
    49. }
    50. global.Turn = 1;
    51. }
    52. else
    53. {
    54. exit;
    55. }
    56. }
    57. }
    58. if (global.select == 3)
    59. {
    60. if instance_exists(obj_Kreis_3)
    61. {
    62. obj_Kreis_3.visible = true;
    63. with (obj_Kreuz_3)
    64. {
    65. instance_destroy();
    66. }
    67. global.Turn = 1;
    68. }
    69. else
    70. {
    71. exit;
    72. }
    73. }
    74. {
    75. if (global.select == 4)
    76. {
    77. if instance_exists(obj_Kreis_4)
    78. {
    79. obj_Kreis_4.visible = true;
    80. with (obj_Kreuz_4)
    81. {
    82. instance_destroy();
    83. }
    84. global.Turn = 1;
    85. }
    86. else
    87. {
    88. exit;
    89. }
    90. }
    91. }
    92. {
    93. if (global.select == 5)
    94. {
    95. if instance_exists(obj_Kreis_5)
    96. {
    97. obj_Kreis_5.visible = true;
    98. with (obj_Kreuz_5)
    99. {
    100. instance_destroy();
    101. }
    102. global.Turn = 1;
    103. }
    104. else
    105. {
    106. exit;
    107. }
    108. }
    109. if (global.select == 6)
    110. {
    111. if instance_exists(obj_Kreis_6)
    112. {
    113. obj_Kreis_6.visible = true;
    114. with (obj_Kreuz_6)
    115. {
    116. instance_destroy();
    117. }
    118. global.Turn = 1;
    119. }
    120. else
    121. {
    122. exit;
    123. }
    124. }
    125. }
    126. {
    127. if (global.select == 7)
    128. {
    129. if instance_exists(obj_Kreis_7)
    130. {
    131. obj_Kreis_7.visible = true;
    132. with (obj_Kreuz_7)
    133. {
    134. instance_destroy();
    135. }
    136. global.Turn = 1;
    137. }
    138. else
    139. {
    140. exit;
    141. }
    142. }
    143. }
    144. {
    145. if (global.select == 8)
    146. {
    147. if instance_exists(obj_Kreis_8)
    148. {
    149. obj_Kreis_8.visible = true;
    150. with (obj_Kreuz_8)
    151. {
    152. instance_destroy();
    153. }
    154. global.Turn = 1;
    155. }
    156. else
    157. {
    158. exit;
    159. }
    160. }
    161. }
    162. }
    Alles anzeigen

    wurde noch verbessert... nur noch dass problem, dass wenn ich auf ein X clicke im Tic-Tac-toe, dass dann mehrere Kreise spawnen....
  • GML-Quellcode

    1. ​if (global.Turn == 0)
    2. {
    3. global.select = irandom(8)
    4. {
    5. if (global.select == 0)
    6. {
    7. if (instance_exists(obj_Kreis_0))
    8. {
    9. obj_Kreis_0.visible = true;
    10. with (obj_Kreuz_0)
    11. {
    12. instance_destroy();
    13. }
    14. global.Turn = 1;
    15. }
    16. }
    17. else
    18. {
    19. exit;
    20. }
    21. }
    Alles anzeigen


    was mach ich dass die Zah random generiert wird...? was stimmt nicht?
  • ehm will nur wissen versteht niemand mein Problem xD?
    habe jetzt noch geändert

    GML-Quellcode

    1. global.select = random (8)


    es wird immer nur noch °Kreis 1 visible was mach ich falsch?

    GML-Quellcode

    1. /// Step Event Kreis
    2. if (global.Turn == 0)
    3. {
    4. global.select = random(8)
    5. {
    6. if (global.select == 0)
    7. {
    8. if (instance_exists(obj_Kreis_0))
    9. {
    10. obj_Kreis_0.visible = true;
    11. with (obj_Kreuz_0)
    12. {
    13. instance_destroy();
    14. }
    15. global.Turn = 1;
    16. }
    17. }
    18. else
    19. {
    20. exit;
    21. }
    22. }
    23. {
    24. if (global.select == 1)
    25. {
    26. if (instance_exists(obj_Kreis_1))
    27. {
    28. obj_Kreis_1.visible = true;
    29. with (obj_Kreuz_1)
    30. {
    31. instance_destroy();
    32. }
    33. global.Turn = 1;
    34. }
    35. }
    36. else
    37. {
    38. exit;
    39. }
    40. }
    41. {
    42. if (global.select == 2)
    43. {
    44. if (instance_exists(obj_Kreis_2))
    45. {
    46. obj_Kreis_2.visible = true;
    47. with (obj_Kreuz_2)
    48. {
    49. instance_destroy();
    50. }
    51. global.Turn = 1;
    52. }
    53. }
    54. else
    55. {
    56. exit;
    57. }
    58. }
    59. {
    60. if (global.select == 3)
    61. {
    62. if (instance_exists(obj_Kreis_3))
    63. {
    64. obj_Kreis_3.visible = true;
    65. with (obj_Kreuz_3)
    66. {
    67. instance_destroy();
    68. }
    69. global.Turn = 1;
    70. }
    71. }
    72. else
    73. {
    74. exit;
    75. }
    76. }
    77. {
    78. if (global.select == 4)
    79. {
    80. if (instance_exists(obj_Kreis_4))
    81. {
    82. obj_Kreis_4.visible = true;
    83. with (obj_Kreuz_4)
    84. {
    85. instance_destroy();
    86. }
    87. global.Turn = 1;
    88. }
    89. }
    90. else
    91. {
    92. exit;
    93. }
    94. }
    95. {
    96. if (global.select == 5)
    97. {
    98. if (instance_exists(obj_Kreis_5))
    99. {
    100. obj_Kreis_5.visible = true;
    101. with (obj_Kreuz_5)
    102. {
    103. instance_destroy();
    104. }
    105. global.Turn = 1;
    106. }
    107. }
    108. else
    109. {
    110. exit;
    111. }
    112. }
    113. {
    114. if (global.select == 6)
    115. {
    116. if (instance_exists(obj_Kreis_6))
    117. {
    118. obj_Kreis_6.visible = true;
    119. with (obj_Kreuz_6)
    120. {
    121. instance_destroy();
    122. }
    123. global.Turn = 1;
    124. }
    125. }
    126. else
    127. {
    128. exit;
    129. }
    130. }
    131. {
    132. if (global.select == 7)
    133. {
    134. if (instance_exists(obj_Kreis_7))
    135. {
    136. obj_Kreis_7.visible = true;
    137. with (obj_Kreuz_7)
    138. {
    139. instance_destroy();
    140. }
    141. global.Turn = 1;
    142. }
    143. }
    144. else
    145. {
    146. exit;
    147. }
    148. }
    149. {
    150. if (global.select == 8)
    151. {
    152. if (instance_exists(obj_Kreis_8))
    153. {
    154. obj_Kreis_8.visible = true;
    155. with (obj_Kreuz_8)
    156. {
    157. instance_destroy();
    158. }
    159. global.Turn = 1;
    160. }
    161. }
    162. else
    163. {
    164. exit;
    165. }
    166. }
    167. }
    Alles anzeigen