Vier Gewinnt

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

  • Vier Gewinnt

    Hallo Leute!!
    Ich hoffe Ihr könnt mir weiterhelfen ! Ich sollte ein vier Gewinnt Spiel programmieren aber irgendwie gelingt mir das nicht so ganz (bin nicht gerade ein Profi mit C++ ;-))
    (Borland)

    Quellcode

    1. //---------------------------------------------------------------------------
    2. #include <vcl.h>
    3. #pragma hdrstop
    4. #include "FuckofPesiU.h"
    5. //---------------------------------------------------------------------------
    6. #pragma package(smart_init)
    7. #pragma resource "*.dfm"
    8. TForm1 *Form1;
    9. //---------------------------------------------------------------------------
    10. __fastcall TForm1::TForm1(TComponent* Owner)
    11. : TForm(Owner)
    12. {
    13. Stein[0]=Shape1;
    14. Stein[1]=Shape2;
    15. Stein[2]=Shape3;
    16. Stein[3]=Shape4;
    17. Stein[4]=Shape5;
    18. Stein[5]=Shape6;
    19. Stein[6]=Shape7;
    20. Stein[7]=Shape8;
    21. Stein[8]=Shape9;
    22. Stein[9]=Shape10;
    23. Stein[10]=Shape11;
    24. Stein[11]=Shape12;
    25. Stein[12]=Shape13;
    26. Stein[13]=Shape14;
    27. Stein[14]=Shape15;
    28. Stein[15]=Shape16;
    29. Spielfeld [0] [0] = Shape17;
    30. Spielfeld [0] [1] = Shape18;
    31. Spielfeld [0] [2] = Shape19;
    32. Spielfeld [0] [3] = Shape20;
    33. Spielfeld [1] [0] = Shape21;
    34. Spielfeld [1] [1] = Shape22;
    35. Spielfeld [1] [2] = Shape23;
    36. Spielfeld [1] [3] = Shape24;
    37. Spielfeld [2] [0] = Shape25;
    38. Spielfeld [2] [1] = Shape26;
    39. Spielfeld [2] [2] = Shape27;
    40. Spielfeld [2] [3] = Shape28;
    41. Spielfeld [3] [0] = Shape29;
    42. Spielfeld [3] [1] = Shape30;
    43. Spielfeld [3] [2] = Shape31;
    44. Spielfeld [3] [3] = Shape32;
    45. for (int spalte=0; spalte <=3; spalte++)
    46. for (int zeile=0; zeile <=3; zeile++)
    47. {
    48. Spielfeld [zeile][spalte] -> Left = 200 + spalte * 49;
    49. Spielfeld [zeile][spalte] -> Top = 200 + zeile * 49;
    50. Feld[zeile][spalte]=NULL;
    51. }
    52. for (int cnt=0; cnt<=15; cnt++)
    53. {
    54. if (cnt<=7)
    55. {Stein[cnt]->Left=60+cnt*45;
    56. Stein [cnt]->Top=65;}
    57. if (cnt<=7)
    58. {Stein[cnt]->Left=400+(cnt-8)*45;
    59. Stein [cnt]->Top=65;}
    60. }
    61. }
    62. //---------------------------------------------------------------------------
    63. void __fastcall TForm1::Shape1MouseDown(TObject *Sender,
    64. TMouseButton Button, TShiftState Shift, int X, int Y)
    65. {
    66. Stone = Shape1;
    67. Stone -> Left = xrich=0;
    68. Stone -> Top = yrich=0;
    69. }
    70. //---------------------------------------------------------------------------
    71. void __fastcall TForm1::Shape2MouseDown(TObject *Sender,
    72. TMouseButton Button, TShiftState Shift, int X, int Y)
    73. {
    74. Stone = Shape2;
    75. Stone -> Left = xrich=0;
    76. Stone -> Top = yrich=0;
    77. }
    78. //---------------------------------------------------------------------------
    79. void __fastcall TForm1::Shape3MouseDown(TObject *Sender,
    80. TMouseButton Button, TShiftState Shift, int X, int Y)
    81. {
    82. Stone = Shape3;
    83. Stone -> Left = xrich=0;
    84. Stone -> Top = yrich=0;
    85. }
    86. //---------------------------------------------------------------------------
    87. void __fastcall TForm1::Shape4MouseDown(TObject *Sender,
    88. TMouseButton Button, TShiftState Shift, int X, int Y)
    89. {
    90. Stone = Shape4;
    91. Stone -> Left = xrich=0;
    92. Stone -> Top = yrich=0;
    93. }
    94. //---------------------------------------------------------------------------
    95. void __fastcall TForm1::Shape5MouseDown(TObject *Sender,
    96. TMouseButton Button, TShiftState Shift, int X, int Y)
    97. {
    98. Stone = Shape5;
    99. Stone -> Left = xrich=0;
    100. Stone -> Top = yrich=0;
    101. }
    102. //---------------------------------------------------------------------------
    103. void __fastcall TForm1::Shape6MouseDown(TObject *Sender,
    104. TMouseButton Button, TShiftState Shift, int X, int Y)
    105. {
    106. Stone = Shape6;
    107. Stone -> Left = xrich=0;
    108. Stone -> Top = yrich=0;
    109. }
    110. //---------------------------------------------------------------------------
    111. void __fastcall TForm1::Shape7MouseDown(TObject *Sender,
    112. TMouseButton Button, TShiftState Shift, int X, int Y)
    113. {
    114. Stone = Shape7;
    115. Stone -> Left = xrich=0;
    116. Stone -> Top = yrich=0;
    117. }
    118. //---------------------------------------------------------------------------
    119. void __fastcall TForm1::Shape8MouseDown(TObject *Sender,
    120. TMouseButton Button, TShiftState Shift, int X, int Y)
    121. {
    122. Stone = Shape8;
    123. Stone -> Left = xrich=0;
    124. Stone -> Top = yrich=0;
    125. }
    126. //---------------------------------------------------------------------------
    127. void __fastcall TForm1::Shape9MouseDown(TObject *Sender,
    128. TMouseButton Button, TShiftState Shift, int X, int Y)
    129. {
    130. Stone = Shape9;
    131. Stone -> Left = xrich=0;
    132. Stone -> Top = yrich=0;
    133. }
    134. //---------------------------------------------------------------------------
    135. void __fastcall TForm1::Shape10MouseDown(TObject *Sender,
    136. TMouseButton Button, TShiftState Shift, int X, int Y)
    137. {
    138. Stone = Shape10;
    139. Stone -> Left = xrich=0;
    140. Stone -> Top = yrich=0;
    141. }
    142. //---------------------------------------------------------------------------
    143. void __fastcall TForm1::Shape11MouseDown(TObject *Sender,
    144. TMouseButton Button, TShiftState Shift, int X, int Y)
    145. {
    146. Stone = Shape11;
    147. Stone -> Left = xrich=0;
    148. Stone -> Top = yrich=0;
    149. }
    150. //---------------------------------------------------------------------------
    151. void __fastcall TForm1::Shape12MouseDown(TObject *Sender,
    152. TMouseButton Button, TShiftState Shift, int X, int Y)
    153. {
    154. Stone = Shape12;
    155. Stone -> Left = xrich=0;
    156. Stone -> Top = yrich=0;
    157. }
    158. //---------------------------------------------------------------------------
    159. void __fastcall TForm1::Shape13MouseDown(TObject *Sender,
    160. TMouseButton Button, TShiftState Shift, int X, int Y)
    161. {
    162. Stone = Shape13;
    163. Stone -> Left = xrich=0;
    164. Stone -> Top = yrich=0;
    165. }
    166. //---------------------------------------------------------------------------
    Alles anzeigen
    Bilder
    • vier Gewinnt.JPG

      279,26 kB, 1.202×738, 598 mal angesehen
  • Quellcode

    1. void __fastcall TForm1::Shape14MouseDown(TObject *Sender,
    2. TMouseButton Button, TShiftState Shift, int X, int Y)
    3. {
    4. Stone = Shape14;
    5. Stone -> Left = xrich=0;
    6. Stone -> Top = yrich=0;
    7. }
    8. //---------------------------------------------------------------------------
    9. void __fastcall TForm1::Shape15MouseDown(TObject *Sender,
    10. TMouseButton Button, TShiftState Shift, int X, int Y)
    11. {
    12. Stone = Shape15;
    13. Stone -> Left = xrich=0;
    14. Stone -> Top = yrich=0;
    15. }
    16. //---------------------------------------------------------------------------
    17. void __fastcall TForm1::Shape16MouseDown(TObject *Sender,
    18. TMouseButton Button, TShiftState Shift, int X, int Y)
    19. {
    20. Stone = Shape16;
    21. Stone -> Left = xrich=0;
    22. Stone -> Top = yrich=0;
    23. }
    24. //---------------------------------------------------------------------------
    25. void __fastcall TForm1::Shape1MouseMove(TObject *Sender, TShiftState Shift,
    26. int X, int Y)
    27. {
    28. bool active = Shift.Contains(ssLeft);
    29. if (active)
    30. {
    31. Stone->Left = Stone ->Left +X - Stone->Width/2;
    32. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    33. }
    34. }
    35. //---------------------------------------------------------------------------
    36. void __fastcall TForm1::Shape2MouseMove(TObject *Sender, TShiftState Shift,
    37. int X, int Y)
    38. {
    39. bool active = Shift.Contains(ssLeft);
    40. if (active)
    41. {
    42. Stone->Left = Stone ->Left +X - Stone->Width/2;
    43. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    44. }
    45. }
    46. //---------------------------------------------------------------------------
    47. void __fastcall TForm1::Shape3MouseMove(TObject *Sender, TShiftState Shift,
    48. int X, int Y)
    49. {
    50. bool active = Shift.Contains(ssLeft);
    51. if (active)
    52. {
    53. Stone->Left = Stone ->Left +X - Stone->Width/2;
    54. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    55. }
    56. }
    57. //---------------------------------------------------------------------------
    58. void __fastcall TForm1::Shape4MouseMove(TObject *Sender, TShiftState Shift,
    59. int X, int Y)
    60. {
    61. bool active = Shift.Contains(ssLeft);
    62. if (active)
    63. {
    64. Stone->Left = Stone ->Left +X - Stone->Width/2;
    65. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    66. }
    67. }
    68. //---------------------------------------------------------------------------
    69. void __fastcall TForm1::Shape5MouseMove(TObject *Sender, TShiftState Shift,
    70. int X, int Y)
    71. {
    72. bool active = Shift.Contains(ssLeft);
    73. if (active)
    74. {
    75. Stone->Left = Stone ->Left +X - Stone->Width/2;
    76. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    77. }
    78. }
    79. //---------------------------------------------------------------------------
    80. void __fastcall TForm1::Shape6MouseMove(TObject *Sender, TShiftState Shift,
    81. int X, int Y)
    82. {
    83. bool active = Shift.Contains(ssLeft);
    84. if (active)
    85. {
    86. Stone->Left = Stone ->Left +X - Stone->Width/2;
    87. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    88. }
    89. }
    90. //---------------------------------------------------------------------------
    91. void __fastcall TForm1::Shape7MouseMove(TObject *Sender, TShiftState Shift,
    92. int X, int Y)
    93. {
    94. bool active = Shift.Contains(ssLeft);
    95. if (active)
    96. {
    97. Stone->Left = Stone ->Left +X - Stone->Width/2;
    98. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    99. }
    100. }
    101. //---------------------------------------------------------------------------
    102. void __fastcall TForm1::Shape8MouseMove(TObject *Sender, TShiftState Shift,
    103. int X, int Y)
    104. {
    105. bool active = Shift.Contains(ssLeft);
    106. if (active)
    107. {
    108. Stone->Left = Stone ->Left +X - Stone->Width/2;
    109. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    110. }
    111. }
    112. //---------------------------------------------------------------------------
    113. void __fastcall TForm1::Shape9MouseMove(TObject *Sender, TShiftState Shift,
    114. int X, int Y)
    115. {
    116. bool active = Shift.Contains(ssLeft);
    117. if (active)
    118. {
    119. Stone->Left = Stone ->Left +X - Stone->Width/2;
    120. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    121. }
    122. }
    123. //---------------------------------------------------------------------------
    124. void __fastcall TForm1::Shape10MouseMove(TObject *Sender,
    125. TShiftState Shift, int X, int Y)
    126. {
    127. bool active = Shift.Contains(ssLeft);
    128. if (active)
    129. {
    130. Stone->Left = Stone ->Left +X - Stone->Width/2;
    131. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    132. }
    133. }
    134. //---------------------------------------------------------------------------
    135. void __fastcall TForm1::Shape11MouseMove(TObject *Sender,
    136. TShiftState Shift, int X, int Y)
    137. {
    138. bool active = Shift.Contains(ssLeft);
    139. if (active)
    140. {
    141. Stone->Left = Stone ->Left +X - Stone->Width/2;
    142. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    143. }
    144. }
    145. //---------------------------------------------------------------------------
    146. void __fastcall TForm1::Shape12MouseMove(TObject *Sender,
    147. TShiftState Shift, int X, int Y)
    148. {
    149. bool active = Shift.Contains(ssLeft);
    150. if (active)
    151. {
    152. Stone->Left = Stone ->Left +X - Stone->Width/2;
    153. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    154. }
    155. }
    156. //---------------------------------------------------------------------------
    157. void __fastcall TForm1::Shape13MouseMove(TObject *Sender,
    158. TShiftState Shift, int X, int Y)
    159. {
    160. bool active = Shift.Contains(ssLeft);
    161. if (active)
    162. {
    163. Stone->Left = Stone ->Left +X - Stone->Width/2;
    164. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    165. }
    166. }
    167. //---------------------------------------------------------------------------
    168. void __fastcall TForm1::Shape14MouseMove(TObject *Sender,
    169. TShiftState Shift, int X, int Y)
    170. {
    171. bool active = Shift.Contains(ssLeft);
    172. if (active)
    173. {
    174. Stone->Left = Stone ->Left +X - Stone->Width/2;
    175. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    176. }
    177. }
    178. //---------------------------------------------------------------------------
    179. void __fastcall TForm1::Shape15MouseMove(TObject *Sender,
    180. TShiftState Shift, int X, int Y)
    181. {
    182. bool active = Shift.Contains(ssLeft);
    183. if (active)
    184. {
    185. Stone->Left = Stone ->Left +X - Stone->Width/2;
    186. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    187. }
    188. }
    189. //---------------------------------------------------------------------------
    190. void __fastcall TForm1::Shape16MouseMove(TObject *Sender,
    191. TShiftState Shift, int X, int Y)
    192. {
    193. bool active = Shift.Contains(ssLeft);
    194. if (active)
    195. {
    196. Stone->Left = Stone ->Left +X - Stone->Width/2;
    197. Stone->Top = Stone ->Top +Y - Stone->Height/2;
    198. }
    199. }
    200. //---------------------------------------------------------------------------
    Alles anzeigen


    Bitte helft mir !! ;(
  • d0nut schrieb:

    du musst uns schon irgendwie mitteilen was nicht funktioniert.
    ;) sry

    also die Aufgabenstellung lautet:

    Ich muss ein Shape nehmen (Stone) Und es über einer Spalte ablegen und dann muss das Shape automatisch so weit runter gehen
    bis es entweder von dem untesten Shape gefangen wird oder wenn in dem Shape darunter schon ein anderer Stein liegt.

    mein problem ist es wie kann ich eine abfrage machen damit in der listbox notiert wird wo der Stein liegt
    und 2tens soll der Stein innerhalb von dem rechteck shape zentriert werden.
    3. wie programmiere ich dass der Stein automatisch darunter geht ??
    4. soll wenn 4 steine der selben farbe senkrecht, waagrecht oder diagonal nebeneinander liegen
    eine meldung kommen wer gewonnen hat.
    (am ende des ersten beitrages ist ein bild von dem programm)
  • na da hast du ja noch einiges vor.
    Ich würde den Weg erstmal anders gehen. Anstatt gleich bei Drag und Drop anzufangen, reagiere doch erstmal nur auf Klicks auf die Spalte.
    Das ist doch wesentlich einfacher. Sind auch nur alles Shapes im Spielfeld Array.

    Und dann machst du erstmal Spielfeld[spalte][0] grün... und dann nimmst du noch eine toggle variable damit zwischen grün und blau abgewechselt wird...
    und ... und ... und...

    ihr habt doch bestimmt unterrichtsmaterialien dazu.