IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

jeu en delphi


Sujet :

Delphi

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut jeu en delphi
    Bonjour à tous
    je sui en train de faire un petit jeu en delphi. Il s'agit d'un champ de bataille sur carte. Mais comment faire pour que losqu'une unité passe sur une rivière, elle perde des points.
    Voici mon code source :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
     
    unit Unit2;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
     
    type
      TForm2 = class(TForm)
        Panel1: TPanel;
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        Button5: TButton;
        Button6: TButton;
        Button7: TButton;
        Button8: TButton;
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Edit4: TEdit;
        Edit5: TEdit;
        Edit6: TEdit;
        Edit7: TEdit;
        Button9: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Button8Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure Button7Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form2: TForm2;
     
    implementation
     
    uses Unit1;
     
    {$R *.dfm}
     
    procedure TForm2.Button1Click(Sender: TObject);
    begin
    case unite of
    1 : begin Form1.Image11.Top:=Form1.Image11.Top-15;
              Form1.Image11.Left:=Form1.Image11.left-15; end;
    2 : begin Form1.Image2.Top:=Form1.Image2.Top-15;
              Form1.Image2.Left:=Form1.Image2.left-15; end;
    3 : begin Form1.Image3.Top:=Form1.Image3.Top-15;
              Form1.Image3.Left:=Form1.Image3.left-15; end;
    4 : begin Form1.Image4.Top:=Form1.Image4.Top-15;
              Form1.Image4.Left:=Form1.Image4.left-15; end;
    5 : begin Form1.Image6.Top:=Form1.Image6.Top-15;
              Form1.Image6.Left:=Form1.Image6.left-15; end;
    6 : begin Form1.Image5.Top:=Form1.Image5.Top-15;
              Form1.Image5.Left:=Form1.Image5.left-15; end;
    7 : begin Form1.Image8.Top:=Form1.Image8.Top-15;
              Form1.Image8.Left:=Form1.Image8.left-15; end;
    8 : begin Form1.Image7.Top:=Form1.Image7.Top-15;
              Form1.Image7.Left:=Form1.Image7.left-15; end;
     9 : begin Form1.Image12.Top:=Form1.Image12.Top-15;
              Form1.Image12.Left:=Form1.Image12.left-15; end;
    10 : begin Form1.Image14.Top:=Form1.Image14.Top-15;
              Form1.Image14.Left:=Form1.Image14.left-15; end;
    11 : begin Form1.Image13.Top:=Form1.Image13.Top-15;
              Form1.Image13.Left:=Form1.Image13.left-15; end;
     
     12 : begin Form1.Image18.Top:=Form1.Image18.Top-15;
              Form1.Image18.Left:=Form1.Image18.left-15; end;
    13 : begin Form1.Image21.Top:=Form1.Image21.Top-15;
              Form1.Image21.Left:=Form1.Image21.left-15; end;
     14 : begin Form1.Image10.Top:=Form1.Image10.Top-15;
              Form1.Image10.Left:=Form1.Image10.left-15; end;
     15 : begin Form1.Image9.Top:=Form1.Image9.Top-15;
              Form1.Image9.Left:=Form1.Image9.left-15; end;
    16 : begin Form1.Image17.Top:=Form1.Image17.Top-15;
              Form1.Image17.Left:=Form1.Image17.left-15; end;
     
    17 : begin Form1.Image19.Top:=Form1.Image19.Top-15;
              Form1.Image19.Left:=Form1.Image19.left-15; end;
    18 : begin Form1.Image20.Top:=Form1.Image20.Top-15;
              Form1.Image20.Left:=Form1.Image20.left-15; end;
    19 : begin Form1.Image16.Top:=Form1.Image16.Top-15;
              Form1.Image16.Left:=Form1.Image16.left-15; end;
    20 : begin Form1.Image15.Top:=Form1.Image15.Top-15;
              Form1.Image15.Left:=Form1.Image15.left-15; end; 
     
    end;
    end;
     
    procedure TForm2.Button2Click(Sender: TObject);
    begin
    case unite of
    1 :  Form1.Image11.Top:=Form1.Image11.Top-15;
     
    2 :  Form1.Image2.Top:=Form1.Image2.Top-15;
     
    3 :  Form1.Image3.Top:=Form1.Image3.Top-15;
     
    4 :  Form1.Image4.Top:=Form1.Image4.Top-15;
     
    5 :  Form1.Image6.Top:=Form1.Image6.Top-15;
     
    6 :  Form1.Image5.Top:=Form1.Image5.Top-15;
     
    7 :  Form1.Image8.Top:=Form1.Image8.Top-15;
     
    8 :  Form1.Image7.Top:=Form1.Image7.Top-15;
     
     9 :  Form1.Image12.Top:=Form1.Image12.Top-15;
     
    10 :  Form1.Image14.Top:=Form1.Image14.Top-15;
     
    11 :  Form1.Image13.Top:=Form1.Image13.Top-15;
     
     
     12 :  Form1.Image18.Top:=Form1.Image18.Top-15;
     
    13 :  Form1.Image21.Top:=Form1.Image21.Top-15;
     
     14 :  Form1.Image10.Top:=Form1.Image10.Top-15;
     
     15 :  Form1.Image9.Top:=Form1.Image9.Top-15;
     
    16 :  Form1.Image17.Top:=Form1.Image17.Top-15;
     
     
    17 :  Form1.Image19.Top:=Form1.Image19.Top-15;
     
    18 :  Form1.Image20.Top:=Form1.Image20.Top-15;
     
    19 :  Form1.Image16.Top:=Form1.Image16.Top-15;
     
    20 :  Form1.Image15.Top:=Form1.Image15.Top-15;
     
    end;
    end;
     
     
    procedure TForm2.Button3Click(Sender: TObject);
    begin
    case unite of
    1 : begin Form1.Image11.Top:=Form1.Image11.Top-15;
              Form1.Image11.Left:=Form1.Image11.left+15; end;
    2 : begin Form1.Image2.Top:=Form1.Image2.Top-15;
              Form1.Image2.Left:=Form1.Image2.left+15; end;
    3 : begin Form1.Image3.Top:=Form1.Image3.Top-15;
              Form1.Image3.Left:=Form1.Image3.left+15; end;
    4 : begin Form1.Image4.Top:=Form1.Image4.Top-15;
              Form1.Image4.Left:=Form1.Image4.left+15; end;
    5 : begin Form1.Image6.Top:=Form1.Image6.Top-15;
              Form1.Image6.Left:=Form1.Image6.left+15; end;
    6 : begin Form1.Image5.Top:=Form1.Image5.Top-15;
              Form1.Image5.Left:=Form1.Image5.left+15; end;
    7 : begin Form1.Image8.Top:=Form1.Image8.Top-15;
              Form1.Image8.Left:=Form1.Image8.left+15; end;
    8 : begin Form1.Image7.Top:=Form1.Image7.Top-15;
              Form1.Image7.Left:=Form1.Image7.left+15; end;
     9 : begin Form1.Image12.Top:=Form1.Image12.Top-15;
              Form1.Image12.Left:=Form1.Image12.left+15; end;
    10 : begin Form1.Image14.Top:=Form1.Image14.Top-15;
              Form1.Image14.Left:=Form1.Image14.left+15; end;
    11 : begin Form1.Image13.Top:=Form1.Image13.Top-15;
              Form1.Image13.Left:=Form1.Image13.left+15; end;
     
     12 : begin Form1.Image18.Top:=Form1.Image18.Top-15;
              Form1.Image18.Left:=Form1.Image18.left+15; end;
    13 : begin Form1.Image21.Top:=Form1.Image21.Top-15;
              Form1.Image21.Left:=Form1.Image21.left+15; end;
     14 : begin Form1.Image10.Top:=Form1.Image10.Top-15;
              Form1.Image10.Left:=Form1.Image10.left+15; end;
     15 : begin Form1.Image9.Top:=Form1.Image9.Top-15;
              Form1.Image9.Left:=Form1.Image9.left+15; end;
    16 : begin Form1.Image17.Top:=Form1.Image17.Top-15;
              Form1.Image17.Left:=Form1.Image17.left+15; end;
     
    17 : begin Form1.Image19.Top:=Form1.Image19.Top-15;
              Form1.Image19.Left:=Form1.Image19.left+15; end;
    18 : begin Form1.Image20.Top:=Form1.Image20.Top-15;
              Form1.Image20.Left:=Form1.Image20.left+15; end;
    19 : begin Form1.Image16.Top:=Form1.Image16.Top-15;
              Form1.Image16.Left:=Form1.Image16.left+15; end;
    20 : begin Form1.Image15.Top:=Form1.Image15.Top-15;
              Form1.Image15.Left:=Form1.Image15.left+15; end;
    end;
    end;
     
    procedure TForm2.Button4Click(Sender: TObject);
    begin
    case unite of
    1 : begin
              Form1.Image11.Left:=Form1.Image11.left-15; end;
    2 : begin
              Form1.Image2.Left:=Form1.Image2.left-15; end;
    3 : begin
              Form1.Image3.Left:=Form1.Image3.left-15; end;
    4 : begin
              Form1.Image4.Left:=Form1.Image4.left-15; end;
    5 : begin
              Form1.Image6.Left:=Form1.Image6.left-15; end;
    6 : begin
              Form1.Image5.Left:=Form1.Image5.left-15; end;
    7 : begin
              Form1.Image8.Left:=Form1.Image8.left-15; end;
    8 : begin
              Form1.Image7.Left:=Form1.Image7.left-15; end;
     9 : begin
              Form1.Image12.Left:=Form1.Image12.left-15; end;
    10 : begin
              Form1.Image14.Left:=Form1.Image14.left-15; end;
    11 : begin
              Form1.Image13.Left:=Form1.Image13.left-15; end;
     
     12 : begin
              Form1.Image18.Left:=Form1.Image18.left-15; end;
    13 : begin
              Form1.Image21.Left:=Form1.Image21.left-15; end;
     14 : begin
              Form1.Image10.Left:=Form1.Image10.left-15; end;
     15 : begin
              Form1.Image9.Left:=Form1.Image9.left-15; end;
    16 : begin
              Form1.Image17.Left:=Form1.Image17.left-15; end;
     
    17 : begin
              Form1.Image19.Left:=Form1.Image19.left-15; end;
    18 : begin
              Form1.Image20.Left:=Form1.Image20.left-15; end;
    19 : begin
              Form1.Image16.Left:=Form1.Image16.left-15; end;
    20 : begin 
              Form1.Image15.Left:=Form1.Image15.left-15; end;
    end;
    end;
     
    procedure TForm2.Button8Click(Sender: TObject);
    begin
    case unite of
    1 : begin
              Form1.Image11.Left:=Form1.Image11.left+15; end;
    2 : begin
              Form1.Image2.Left:=Form1.Image2.left+15; end;
    3 : begin
              Form1.Image3.Left:=Form1.Image3.left+15; end;
    4 : begin
              Form1.Image4.Left:=Form1.Image4.left+15; end;
    5 : begin
              Form1.Image6.Left:=Form1.Image6.left+15; end;
    6 : begin
              Form1.Image5.Left:=Form1.Image5.left+15; end;
    7 : begin
              Form1.Image8.Left:=Form1.Image8.left+15; end;
    8 : begin
              Form1.Image7.Left:=Form1.Image7.left+15; end;
     9 : begin
              Form1.Image12.Left:=Form1.Image12.left+15; end;
    10 : begin
              Form1.Image14.Left:=Form1.Image14.left+15; end;
    11 : begin
              Form1.Image13.Left:=Form1.Image13.left+15; end;
     
     12 : begin
              Form1.Image18.Left:=Form1.Image18.left+15; end;
    13 : begin
              Form1.Image21.Left:=Form1.Image21.left+15; end;
     14 : begin
              Form1.Image10.Left:=Form1.Image10.left+15; end;
     15 : begin
              Form1.Image9.Left:=Form1.Image9.left+15; end;
    16 : begin
              Form1.Image17.Left:=Form1.Image17.left+15; end;
     
    17 : begin
              Form1.Image19.Left:=Form1.Image19.left+15; end;
    18 : begin
              Form1.Image20.Left:=Form1.Image20.left+15; end;
    19 : begin
              Form1.Image16.Left:=Form1.Image16.left+15; end;
    20 : begin 
              Form1.Image15.Left:=Form1.Image15.left+15; end;
    end;
    end;
     
    procedure TForm2.Button6Click(Sender: TObject);
    begin
    case unite of
    1 : Form1.Image11.Top:=Form1.Image11.Top+15;
     
    2 :  Form1.Image2.Top:=Form1.Image2.Top+15;
     
    3 :  Form1.Image3.Top:=Form1.Image3.Top+15;
     
    4 :  Form1.Image4.Top:=Form1.Image4.Top+15;
     
    5 :  Form1.Image6.Top:=Form1.Image6.Top+15;
     
    6 :  Form1.Image5.Top:=Form1.Image5.Top+15;
     
    7 :  Form1.Image8.Top:=Form1.Image8.Top+15;
     
    8 :  Form1.Image7.Top:=Form1.Image7.Top+15;
     
     9 :  Form1.Image12.Top:=Form1.Image12.Top+15;
     
    10 :  Form1.Image14.Top:=Form1.Image14.Top+15;
     
    11 :  Form1.Image13.Top:=Form1.Image13.Top+15;
     
     
     12 :  Form1.Image18.Top:=Form1.Image18.Top+15;
     
    13 :  Form1.Image21.Top:=Form1.Image21.Top+15;
     
     14 :  Form1.Image10.Top:=Form1.Image10.Top+15;
     
     15 :  Form1.Image9.Top:=Form1.Image9.Top+15;
     
    16 :  Form1.Image17.Top:=Form1.Image17.Top+15;
     
     
    17 :  Form1.Image19.Top:=Form1.Image19.Top+15;
     
    18 :  Form1.Image20.Top:=Form1.Image20.Top+15;
     
    19 :  Form1.Image16.Top:=Form1.Image16.Top+15;
     
    20 :  Form1.Image15.Top:=Form1.Image15.Top+15;
    end;
    end;
     
    procedure TForm2.Button7Click(Sender: TObject);
    begin
    case unite of
    1 : begin Form1.Image11.Top:=Form1.Image11.Top+15;
              Form1.Image11.Left:=Form1.Image11.left+15; end;
    2 : begin Form1.Image2.Top:=Form1.Image2.Top+15;
              Form1.Image2.Left:=Form1.Image2.left+15; end;
    3 : begin Form1.Image3.Top:=Form1.Image3.Top+15;
              Form1.Image3.Left:=Form1.Image3.left+15; end;
    4 : begin Form1.Image4.Top:=Form1.Image4.Top+15;
              Form1.Image4.Left:=Form1.Image4.left+15; end;
    5 : begin Form1.Image6.Top:=Form1.Image6.Top+15;
              Form1.Image6.Left:=Form1.Image6.left+15; end;
    6 : begin Form1.Image5.Top:=Form1.Image5.Top+15;
              Form1.Image5.Left:=Form1.Image5.left+15; end;
    7 : begin Form1.Image8.Top:=Form1.Image8.Top+15;
              Form1.Image8.Left:=Form1.Image8.left+15; end;
    8 : begin Form1.Image7.Top:=Form1.Image7.Top+15;
              Form1.Image7.Left:=Form1.Image7.left+15; end;
     9 : begin Form1.Image12.Top:=Form1.Image12.Top+15;
              Form1.Image12.Left:=Form1.Image12.left+15; end;
    10 : begin Form1.Image14.Top:=Form1.Image14.Top+15;
              Form1.Image14.Left:=Form1.Image14.left+15; end;
    11 : begin Form1.Image13.Top:=Form1.Image13.Top+15;
              Form1.Image13.Left:=Form1.Image13.left+15; end;
     
     12 : begin Form1.Image18.Top:=Form1.Image18.Top+15;
              Form1.Image18.Left:=Form1.Image18.left+15; end;
    13 : begin Form1.Image21.Top:=Form1.Image21.Top+15;
              Form1.Image21.Left:=Form1.Image21.left+15; end;
     14 : begin Form1.Image10.Top:=Form1.Image10.Top+15;
              Form1.Image10.Left:=Form1.Image10.left+15; end;
     15 : begin Form1.Image9.Top:=Form1.Image9.Top+15;
              Form1.Image9.Left:=Form1.Image9.left+15; end;
    16 : begin Form1.Image17.Top:=Form1.Image17.Top+15;
              Form1.Image17.Left:=Form1.Image17.left+15; end;
     
    17 : begin Form1.Image19.Top:=Form1.Image19.Top+15;
              Form1.Image19.Left:=Form1.Image19.left+15; end;
    18 : begin Form1.Image20.Top:=Form1.Image20.Top+15;
              Form1.Image20.Left:=Form1.Image20.left+15; end;
    19 : begin Form1.Image16.Top:=Form1.Image16.Top+15;
              Form1.Image16.Left:=Form1.Image16.left+15; end;
    20 : begin Form1.Image15.Top:=Form1.Image15.Top+15;
              Form1.Image15.Left:=Form1.Image15.left+15; end;
    end;
    end;
     
    procedure TForm2.Button5Click(Sender: TObject);
    begin
     case unite of
    1 : begin Form1.Image11.Top:=Form1.Image11.Top+15;
              Form1.Image11.Left:=Form1.Image11.left-15; end;
    2 : begin Form1.Image2.Top:=Form1.Image2.Top+15;
              Form1.Image2.Left:=Form1.Image2.left-15; end;
    3 : begin Form1.Image3.Top:=Form1.Image3.Top+15;
              Form1.Image3.Left:=Form1.Image3.left-15; end;
    4 : begin Form1.Image4.Top:=Form1.Image4.Top+15;
              Form1.Image4.Left:=Form1.Image4.left-15; end;
    5 : begin Form1.Image6.Top:=Form1.Image6.Top+15;
              Form1.Image6.Left:=Form1.Image6.left-15; end;
    6 : begin Form1.Image5.Top:=Form1.Image5.Top+15;
              Form1.Image5.Left:=Form1.Image5.left-15; end;
    7 : begin Form1.Image8.Top:=Form1.Image8.Top+15;
              Form1.Image8.Left:=Form1.Image8.left-15; end;
    8 : begin Form1.Image7.Top:=Form1.Image7.Top+15;
              Form1.Image7.Left:=Form1.Image7.left-15; end;
     9 : begin Form1.Image12.Top:=Form1.Image12.Top+15;
              Form1.Image12.Left:=Form1.Image12.left-15; end;
    10 : begin Form1.Image14.Top:=Form1.Image14.Top+15;
              Form1.Image14.Left:=Form1.Image14.left-15; end;
    11 : begin Form1.Image13.Top:=Form1.Image13.Top+15;
              Form1.Image13.Left:=Form1.Image13.left-15; end;
     
     12 : begin Form1.Image18.Top:=Form1.Image18.Top+15;
              Form1.Image18.Left:=Form1.Image18.left-15; end;
    13 : begin Form1.Image21.Top:=Form1.Image21.Top+15;
              Form1.Image21.Left:=Form1.Image21.left-15; end;
     14 : begin Form1.Image10.Top:=Form1.Image10.Top+15;
              Form1.Image10.Left:=Form1.Image10.left-15; end;
     15 : begin Form1.Image9.Top:=Form1.Image9.Top+15;
              Form1.Image9.Left:=Form1.Image9.left-15; end;
    16 : begin Form1.Image17.Top:=Form1.Image17.Top+15;
              Form1.Image17.Left:=Form1.Image17.left-15; end;
     
    17 : begin Form1.Image19.Top:=Form1.Image19.Top+15;
              Form1.Image19.Left:=Form1.Image19.left-15; end;
    18 : begin Form1.Image20.Top:=Form1.Image20.Top+15;
              Form1.Image20.Left:=Form1.Image20.left-15; end;
    19 : begin Form1.Image16.Top:=Form1.Image16.Top+15;
              Form1.Image16.Left:=Form1.Image16.left-15; end;
    20 : begin Form1.Image15.Top:=Form1.Image15.Top+15;
              Form1.Image15.Left:=Form1.Image15.left-15; end;
    end;
    end;
     
     
    end.
    Comment faire pour que losqu'on passe sur une TImage (vide), il se passe quelque chose.
    Ais-je été assez clair
    merci

  2. #2
    Membre expert
    Avatar de TicTacToe
    Inscrit en
    Septembre 2005
    Messages
    1 940
    Détails du profil
    Informations personnelles :
    Âge : 51

    Informations forums :
    Inscription : Septembre 2005
    Messages : 1 940
    Points : 3 575
    Points
    3 575
    Par défaut


    Je pense que tu débutes en programmation.

    1. C'est un peu trop long à lire et pas clair

    2. Tu as du remarquer que tu as beaucoup de code qui se ressemble, il est donc impératif de synthétiser tout ca avec des tableaux, des listes des fonctions travaillant sur un elts de ta liste etc...
    Il faut faire une liste d'image, une liste de boutons, etc...
    La, au MOINDRE changement de traitement sur un element, tout le code est a refaire !

    3. Ensuite, je crois que ta question est pas clair

    Bon courage !
    Section Delphi
    La mine d'or: La FAQ, les Sources

    Un développement compliqué paraitra simple pour l'utilisateur, frustrant non ?
    Notre revanche ? l'inverse est aussi vrai ;-)

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut jeu en delphi
    En fait, je cherche à faire un jeu sur plateau. J'arrive à faire déplacer les unités mais ce que je n'arrive pas à faire c'est de limiter les déplacements en fonction du terrain.
    Sinon, si quelqu'un peut me montrer comment améliorer mon code, je sui preneur !!!
    Je débute en effet et ai soif d'apprendre pendnat ces vacances.
    merci à vous pour votre aide

  4. #4
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    Bonjour,

    Pour illlustrer l'utilisation des tableaux sur la premiere procédure :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    unit Unit2; 
     
    interface 
     
    uses 
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
      Dialogs, StdCtrls, ExtCtrls; 
     
    type 
      TForm2 = class(TForm) 
        Panel1: TPanel; 
        Button1: TButton; 
        Button2: TButton; 
        ...
        procedure Button1Click(Sender: TObject); 
        ....
      private 
        { Déclarations privées } 
      ImageArray : array [0..20] of Timage ;
      public 
        { Déclarations publiques } 
      end; 
     
    var 
      Form2: TForm2; 
     
    implementation 
     
    uses Unit1; 
     
    {$R *.dfm} 
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    ImageArray[1]:=Form1.image1 ;
    ImageArray[2]:=Form1.image2 ;
    ...
    end ;
     
     
    procedure TForm2.Button1Click(Sender: TObject); 
    begin 
    ImageArray[unite].Top:=ImageArray[unite].Top; 
    ImageArray[unite].Left:=ImageArray[unite].left-15; 
    end;
    " Le croquemitaine ! Aaaaaah ! Où ça ? " ©Homer Simpson

  5. #5
    Expert éminent
    Avatar de smyley
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    6 270
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 6 270
    Points : 8 344
    Points
    8 344
    Par défaut

    Nommer plus explicitement des composants ( "Button1,2,..." à banir )


    chercher du coté des tableaux pour tes images :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Images : array of TImage;
    ou encore

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    procadure Form1.MoveUp(Index : Integer);
    var
     Pic : TImage;
    begin
     Pic := TImage(Self.FindComponent('Image' + IntToStr(Index)));
     Pic.Top := Pic.Top+15;
     ...
    end;

  6. #6
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    En fait, je ne sait pas bien me servir des tableaux. Je vais essayer.
    Je vous tiens au courant.
    Merci beaucoup

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    Mais comment faire pour que quand on clique sur un TImage, on puisse ensuite le controler avec le clavier numérique ? Puis le déplacer de 15 dans la direction souhaitée ?
    J'ai imprimé vos exemples mais ça reste encore un peu abstrait
    merci de votre patience

  8. #8
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    C'est bon, j'ai trouvé comment déplacer les unités selon un tableau.
    Mais maintenant, à voter avis, comment peut-on faire un système de tours (joueurs qui jouent à tour de rôle). Egalement, comment faire pour que certaines zones soient interdites ou limitent les déplacements ( par exemple 2 déplacements aui lieu de 3)
    merci

  9. #9
    Membre confirmé

    Inscrit en
    Novembre 2002
    Messages
    743
    Détails du profil
    Informations forums :
    Inscription : Novembre 2002
    Messages : 743
    Points : 500
    Points
    500
    Par défaut
    salut

    un exemple de deplacement de tes images dans les 8 directions avec le clavier (fleche) ou pave numerique.

    Cliquer dessus pour en selectionner une et utiliser les touche curseur.

    mettre le procedure :
    procedure TForm1.CaptureControl(Sender: TObject; Button: TMouseButton;
    Dans chaque OnMouseDown de tes images.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
     
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons, ExtCtrls;
     
    type
      TForm1 = class(TForm)
        Image1: TImage;
        Image2: TImage;
     
        procedure CaptureControl(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
        procedure FormKeyUp(Sender: TObject; var Key: Word;
          Shift: TShiftState);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
     
    implementation
    Var Hd:integer;
        ImageActive:Timage;
    {$R *.dfm}
     
    procedure TForm1.CaptureControl(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
        if (sender is Timage) then ImageActive:=(sender as Timage);
    end;
     
    procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    var Delta:integer;
    begin
        Form1.KeyPreview:=true;
        delta:=15;
        if Key in [36,38,33] then ImageActive.top:=ImageActive.top-delta;
        if Key in[35,40,34] then ImageActive.top:=ImageActive.top+delta;
        if Key in[36,37,35] then ImageActive.left:=ImageActive.left-delta;
        if Key in[33,39,34] then ImageActive.left:=ImageActive.left+delta;
    end;
     
    end.
    Bye et bon code...

    Ce n'est pas tant l'aide de nos amis qui nous aide , mais notre confiance dans cette aide .

  10. #10
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    Je sui désolé mais ce code ne marche pas. Je l'ai entré tel quel mais quand on clique sur l'unité, elle ne répond pas au clavier...

  11. #11
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Salut, essaies le code de peticoucou31 modifié comme ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    unit Unit1;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;
     
    type
      TForm1 = class(TForm)
        Image1: TImage;
        Image2: TImage;
        procedure ImageClick(Sender: TObject);
        procedure FormKeyUp(Sender: TObject; var Key: Word;
          Shift: TShiftState);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
      end;
     
    var
      Form1: TForm1;
      Hd:integer;
      ImageActive:Timage;
    implementation
     
    {$R *.dfm}
     
    procedure TForm1.ImageClick(Sender: TObject);
    begin
      if (sender is Timage) then ImageActive:=(sender as Timage);
    end;
     
    procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    var Delta:integer;
    begin
        Form1.KeyPreview:=true;
        delta:=15;
        if Key in [36,38,33] then ImageActive.top:=ImageActive.top-delta;
        if Key in[35,40,34] then ImageActive.top:=ImageActive.top+delta;
        if Key in[36,37,35] then ImageActive.left:=ImageActive.left-delta;
        if Key in[33,39,34] then ImageActive.left:=ImageActive.left+delta;
    end;
     
    end.
    n'oublies pas de lier les OnClick de Image1 et Image2 à la méthode ImageClick(...); et le OnKeyUp de ta fiche à la méthode FormKeyUp(..);, sinon ça ne marchera pas...

    Bon dev
    Bidouilleuse Delphi

  12. #12
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    Mais comment lier les onclick ) image clic. Sous onclic, j'ai des informations (quand on clique s'affiche le nom et l'état des unités).
    Egalement, je n'ai pas de onkeyup ?
    merci

  13. #13
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    J'ai trouvé seul entre temps !!!
    merci de voitre aide
    mais il me reste une question :
    comment faire que les uniéts aient un certain nombre de déplacements donné ? Et que ce nombre varie en fonction du terrain ?
    Enfin, comment faire que durant le tour des rouges, seules les unités rouges bougent?
    merci

  14. #14
    Membre éprouvé Avatar de Caine
    Inscrit en
    Mai 2004
    Messages
    1 028
    Détails du profil
    Informations personnelles :
    Âge : 51

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 028
    Points : 1 122
    Points
    1 122
    Par défaut
    Salut,

    Tu devrais réfléchir à toutes ces questions en terme d'algorithme et les implémenter ensuite. Tu gagnerais du temps, crois-en mon expérience.

    Quand tu marches dans un rue goudronnée, tu avances plus vite que dans un marécage, non?

    Inspires toi de la réalité.

    Donc, oui le type du terrain influence la vitesse. A moins que ton choix soit de ne pas rendre cet aspect réaliste. Tu n'as pas d'obligation (a moins de bosser chez blizard pour Wow ).

    Tu as maintenant plusieurs choix pour l'implémenter:

    Une classe terrain qui renvoie par une propriété un modificateur de vitesse.

    Une procédure qui calcule la vitesse d'un élément en fonction du terrain ...

  15. #15
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    Dernière question : comment limiter les déplacements de toutes les unités à 5 mouvements (5 touches pressées).
    merci

  16. #16
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Toutes les questions que tu te poses sur la façon dont tu va gérer les différentes parties de ton jeu, c'est à toi de les résoudre.

    Le langage de programmation que tu utilises te proposes différentes "briques" pour atteindre ton but, autres que les objets "graphiques" que tu trouve dans ta palette de composant. Ce sont ces dernières que tu dois maitriser et assembler entre elles, car se sont ces dernières qui te permettront d'aboutir à un produit fini :
    - des variables (globales ou locales), de différents types (integer, boolean, string, etc...), qui te servent à stocker des valeurs, à compter, etc...
    - des opérations (+, - , *, /)
    - des structures (tableaux, enregistrements)

    bref nous ne pouvons hélas que te guider sur des techniques particulières (comme déplacer un Timage, savoir sur quelle touche on a appuyé) , pas sur la base même du langage (il y a des tutoriels pour ça !).
    Comprend bien qu'on ne peut pas (temps, disponibilité,etc..) te lâcher un algorithme représentant l'ensemble de ton programme en claquant des doigts et qui dépasserait surement les deux pages.

    Ton problême est méthodologique.
    Donc, coté méthode, n'essaies surtout pas de répondre à toutes tes questions en même temps, tu n'y arriveras pas.
    Ecris les d'abord sur le papier ce que tu souhaites obtenir, puis essaies d'y aller pas à pas, de scinder chaque problème en plusieurs sous-problême très souvent plus faciles à résoudre. Il y a certes un effort à fournir, mais le jeu en vaut la chandelle, crois moi.

    Essaies aussi de t'inspirer de codes sources de petits jeux simples que tu peux glaner ça et là sur internet (je suis sur que tu en trouvera). En essayant de comprendre ceci, peut-être en retireras tu quelques techniques qui te seront utiles pour ton programme. C'est souvent en "copiant" que l'on apprend.

    Sinon, je te donne un exemple en réponse à ta dernière question :
    comment limiter les déplacements de toutes les unités à 5 mouvements (5 touches pressées). ?
    Tu vas comprendre au combien il est fastidieux de devoir te répondre...
    Soit on te répond :
    tu prends une variable entière que tu initialise à 5 pour chacune de tes unités, puis tu la décrémente à chaque fois que l'unité est déplacée en appuyant sur une touche. Si ta variable deviens inférieure à zéro, après la décrémentation, tu interdit le déplacement et voilà !
    Tu as compris ?
    Oui : alors tu peux très bien y arriver tout seul...
    Non : alors il va falloir (sans te vexer, hein, on est tous passés par là ) ouvrir un tutoriel sur l'apprentissage du langage Delphi (pour avoir les bases).

    Il faut que tu saches, que la réponse our chacun de nous qui essayons de t'aider admet une solution absolument triviale et simplissime à mettre en oeuvre, mais pas forcément à expliquer : Comment peux-tu apprendre à quelqu'un comment conduire une voiture, si il ne sait pas qu'il a un volant à sa disposition pour tourner les roues ???

    Enfin, pour te faire avancer un peu dans ton projet, je t'expose ici la façon dont tu peut t'y prendre, et une réponse beaucoup plus complête à ta question :

    Toutes tes unités (leurs différentes caractéristiques (Nbre de déplacements, TImage qui lui correspond, Force d'attaque)
    sont représentées par un enregistrement (record) que l'on appelera TUnite par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    type
      TUnite=record
          SonNom:string;
          ForceAttaque:integer;
          Defense:integer;
          Mobilité:integer;
          Image:Timage;
       end;
    Comme tu as plusieurs unités, il te faudra faire un tableau :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    const 
      JoueurRouge=0;
      JoueurBleu=1;
      NbreDUnites=10;
    LesUnites=array[JoueurRouge..JoueurBleu,0...NbreDUnites-1] of TUnite;
    Comme ça, toutes les infos qui caractérisent tes unités sont ordonnées et bien rangés dans deset deviennent facilement accessibles pour être consultées ou modifiées dans ton code.

    Ensuite on par sur la structure globale de ton jeu :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Debut du Jeu
      1) Initialisation du terrain, des images
      2) Qui commence ? Si Joueur 2 alors Aller en 5
      3) Tour du Joueur 1 (Joueur Rouge)
      4) Joueur 1 à gagné ? Oui --> aller en 7
      5) Tour du Joueur 2 (Joueur Rouge)
      6) Joueur 2 à gagné ? Oui --> aller en 7  Non--> aller en 3 
      7) Affiche qui a gagné
      8) Une autre partie ? Oui --> aller en 1
    Fin du Jeu
    Puis on affine (quelques exemples liés à ta question) :

    1) Initialisation du terrain, des images
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
     
    ...
     
    procedure TForm1.ImageClick(Sender: TObject);
    begin
      if (sender is Timage) then ImageActive:=(sender as Timage);
    end;
     
    ...
     
    procedure TForm1.Initialisations;
    var i:integer;
    begin
      ...
        //Le Chef
        LesUnites[JoueurRouge,0].SonNom:='Le Chef';
        LesUnites[JoueurRouge,0].Attaque:=8;
        LesUnites[JoueurRouge,0].Defense:=8;
        LesUnites[JoueurRouge,0].Image:=TImage.create(self);
        LesUnites[JoueurRouge,0].Image.Picture.LoadFromFile('Chef.bmp');
        LesUnites[JoueurRouge,0].Image.parent:=self; //self est égal à Form1
        LesUnites[JoueurRouge,0].Image.tag:=0; 
        LesUnites[JoueurRouge,0].Image.OnClick:=ImageClick;
       //Le Canon
        LesUnites[JoueurRouge,1].SonNom:='Le Canon';
        LesUnites[JoueurRouge,1].Attaque:=10;
        LesUnites[JoueurRouge,1].Defense:=2;
        LesUnites[JoueurRouge,1].Image:=TImage.create(self);
        LesUnites[JoueurRouge,1].Image.Picture.LoadFromFile('canon.bmp');
        LesUnites[JoueurRouge,1].Image.parent:=self; //self est égal à Form1
        LesUnites[JoueurRouge,1].Image.tag:=1; 
        LesUnites[JoueurRouge,1].Image.OnClick:=ImageClick;
        //Les soldats de base
         for i:=2  to NbreDUnites-1 do
        begin
          LesUnites[JoueurRouge,i].SonNom:='Un Soldat';
          LesUnites[JoueurRouge,i].Attaque:=5;
          LesUnites[JoueurRouge,i].Defense:=5;
          LesUnites[JoueurRouge,i].Image:=TImage.create(self);
          LesUnites[JoueurRouge,i].Image.Picture.LoadFromFile('soldat.bmp');
          LesUnites[JoueurRouge,i].Image.parent:=self; 
          LesUnites[JoueurRouge,i].Image.tag:=i; 
          LesUnites[JoueurRouge,i].Image.OnClick:=ImageClick;
       end;
      ...
    end;
    3) Tour du Joueur 1
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    //pour chaque unité, on leur met un déplacement de 5 touches
    procedure InitTourJoueur1;
    var i:integer;
    begin
       for i:=0  to NbreDUnites do
         LesUnites[JoueurRouge,i].Mobilite:=5;
    end;
     
    //le Joueur Appuie sur une touche
    procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    var Delta:integer;
    begin
        //Si l'unité à encore le droit de se déplacer...
        if LesUnites&#91;JoueurRouge,ImageActive.tag&#93;.Mobilite<>0 
        then begin
           Form1.KeyPreview&#58;=true;
           delta&#58;=15; //sera en fait dépendant du terrain sur lequel se trouve l'unité &#40;ici on a mis 15&#41;
          if Key in &#91;36,38,33&#93; then ImageActive.top&#58;=ImageActive.top-delta;
          if Key in&#91;35,40,34&#93; then ImageActive.top&#58;=ImageActive.top+delta;
          if Key in&#91;36,37,35&#93; then ImageActive.left&#58;=ImageActive.left-delta;
          if Key in&#91;33,39,34&#93; then ImageActive.left&#58;=ImageActive.left+delta;
          //l'unité vient d'ètre déplacée en appuyant sur une touche
          //Sa mobilité doit donc être réduite de 1
          dec&#40;LesUnites&#91;JoueurRouge,ImageActive.tag&#93;.Mobilite&#41;;
      end;
    end;
    Voilà, maintenant c'est à toi de tout mettre dans l'ordre et d'adapter selon ton besoin.

    Je te suggère de faire aussi un tableau pour le terrain, qui te donnera la valeur delta, en fonction de la position (Left,top) des images.

    Bon courage et bon dev
    Bidouilleuse Delphi

  17. #17
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    Bonjour,

    Il suffit de remettre au début de chaque tour (changement de joueur) un compteur de mouvements à 0, et de l'incrémenter à chaque appui de touche (ou d'afficher un message d'erreur lorsque le compteur dépasse le max -5-).
    " Le croquemitaine ! Aaaaaah ! Où ça ? " ©Homer Simpson

  18. #18
    Candidat au Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 34
    Points : 4
    Points
    4
    Par défaut
    J'ai un autre problème que je n'arrive pas à résoudre, même dans les tutoriaux :
    comment faire pour que les tarrains limitent delta ?
    je pensais au code suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    if &#40;Imagearray&#91; unite&#93;.Top=Form1.Image25.Top&#41; and &#40;Imagearray&#91; unite&#93;.left=Form1.Image25.left&#41; then
    Form2.Label1.Caption&#58;='rivière';
    Mais ça ne parche pas
    que faire
    merci

  19. #19
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    Bonjour,

    Ton code devrait marcher, il y a un autre problème.
    Toutefois, tu devrais créer un tableau de type de cases (array of string) en parallèle avec le tableau des images :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    ...
    ImageTypeArray&#91;25&#93;&#58;='Rivière' ;
    ...
    if ImageTypearray&#91;unite&#93;='Rivière' then Form2.Label1.Caption&#58;=ImageTypearray&#91;unite&#93;
    " Le croquemitaine ! Aaaaaah ! Où ça ? " ©Homer Simpson

  20. #20
    Expert éminent
    Avatar de smyley
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    6 270
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 6 270
    Points : 8 344
    Points
    8 344
    Par défaut
    hum, un tableau d'int serai plus pratique, pour éviter les fautes de frappes
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    const ROUTE &#58; Integer = 1;
    const RIVIERE &#58; Integer = 2;
    const PRAIRIE &#58; Integer = 3;
    const MER &#58; Integer = 4;
    ...
    ImageTypeArray&#91;25&#93;&#58;=RIVIERE;
    ...
    case ImageTypearray&#91;unite&#93; of
     ROUTE&#58;
      begin end;
     RIVIERE&#58;
      begin end;
     MER&#58; 
       begin end;
     ....
    end;

Discussions similaires

  1. Jeu sur Delphi
    Par afaf06 dans le forum Langage
    Réponses: 8
    Dernier message: 08/05/2008, 18h51
  2. Projet de jeu ( style Ogame, Travian ) En Delphi
    Par jfdeterme dans le forum Projets
    Réponses: 41
    Dernier message: 25/02/2008, 17h32
  3. [Delphi] projet de jeu tactic/infiltration en 2D
    Par Darkyl dans le forum Projets
    Réponses: 17
    Dernier message: 17/07/2006, 17h13
  4. Jeu en delphi
    Par Darkyl dans le forum Développement 2D, 3D et Jeux
    Réponses: 1
    Dernier message: 05/04/2006, 00h04
  5. Cherche Composant pour développer un jeu sous DELPHI 6 ?
    Par baltagi dans le forum Composants VCL
    Réponses: 1
    Dernier message: 26/11/2005, 13h25

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo