Bonjour a tous... J'ai commencé la programmation il y a 2 mois sous Borland Develloper Studio 2006. J'ai recemment commencer un projet de jeu:
Il s'agit de 2 tank face a face qui peuvent tirer des balles et il faudrait que qu un une balle touche l'autre tank, celui-ci change d'image. Mais le probleme c'est que je ne vois absolument pas comment faire. Je pense qu il faudrait recuperer la variable de position de la balle. Mais ça je ne c'est pas le faire. Comme ça quand une balle touche l'autre tank l'image de ce tank change. Je vous met a disposition le code source: ( c'est mon premier projet de cette envergure, alors rigoler pas trop )
Si vous voulez je peut mettre le dossier qui contient les image et les autre codes.
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 //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "ufmMainTANK.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == 38) { Image1->Top = Image1->Top -5; Image3->Top = Image3->Top -5; } if (Key == 40) { Image1->Top = Image1->Top +5; Image3->Top = Image3->Top +5; } if (Key == 37) { Image1->Left = Image1->Left -5; Image3->Left = Image3->Left -5; } if (Key == 39) { Image1->Left = Image1->Left +5; Image3->Left = Image3->Left +5; } if (Key == 13) { Timer1->Enabled = true; //balle1 } // joueur 2 if (Key == 87) { Image2->Top = Image2->Top -5; } if (Key == 83) { Image2->Top = Image2->Top +5; } if (Key == 65) { Image2->Left = Image2->Left -5; } if (Key == 68) { Image2->Left = Image2->Left +5; } if (Key == 32) { Timer2->Enabled = true; //balle2 } } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { Image3->Left = Image3->Left +5; Image3->Visible = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::Quitter1Click(TObject *Sender) { Form1->Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer2Timer(TObject *Sender) { Image4->Left = Image4->Left -5; Image4->Visible = true; } //---------------------------------------------------------------------------
Merci d'avance
Partager