Accueil > > > JEUX DÉMO D'AVION AVEC DIRECTX (DIRECTDRAW 2D)
JEUX DÉMO D'AVION AVEC DIRECTX (DIRECTDRAW 2D)
Information sur la source
Description
Ce programme permet d'approfondir vos connaissances sur
DirectX (DirectDraw 2D) avec un petit jeux sympa.
logiciel : Borland C++ Bulder V4
Source
- #include <vcl.h>
- #include <ddraw.h>
- #include <mmsystem.h>
-
- #include "Main.h"
- #include "ddutil.h"
- #include "Unit2.h"
-
- #pragma hdrstop
- #pragma resource "*.dfm"
-
- TForm1 *Form1;
- char szBackground[] = "C6401000"; // BMP
- int ty=0;
- int x=100; int y=300; // cordoné de l'avion
- int times = 0; // times du reacteur de l'avion
- int arme=1; int NbrArme=1; // arme désactivé
- int AvionTouche=0;
- AnsiString s; int ligne=0; int colone=1; // cordoné du decor
- int k=0; int tmp=0;
-
- int level=0;
-
- int etoile0=0; // etoile lente
- int etoile1=0; // etoile rapide
-
- //////////////////////////////////////////////////////
-
- int avion=0; // Avion enemi
- int ViteseAvonEnemi=0; // Vitese Avon Enemi
- int tempnb1=0; // type avion 1
- int tempnb2=0; // type avion 2
- int tempnb3=0; // type avion 3
- int tempnb4=0; // type avion 4
- int AvionTouchenb1=0; // Avion Touché nb1
- int AvionTouchenb2=0; // Avion Touché nb2
- int AvionTouchenb3=0; // Avion Touché nb3
- int AvionTouchenb4=0; // Avion Touché nb4
- int NbrLigne=0;
- AnsiString lpo; int sui=0;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
- {
- Timer1->Enabled = false;
- Form2 = new TForm2(Application);
- Form2->ShowModal();
- Start();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Start()
- {
-
- HRESULT res = DirectDrawCreate(NULL, &pDD, NULL);
- pDD->SetCooperativeLevel(Handle,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
-
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX;
-
- ddsd.dwBackBufferCount = 1;
- pDD->SetDisplayMode(640,480, 16);
- pDD->CreateSurface(&ddsd, &pDDSPrim, NULL);
-
- ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
- pDDSPrim->GetAttachedSurface(&ddscaps, &pDDSSec);
-
- pDDPal = DDLoadPalette(pDD, szBackground);
-
- pDDSImage = DDLoadBitmap(pDD, szBackground, 0, 0);
- DDSetColorKey(pDDSImage,RGB(0,0,0)); // Couleur de transparence
-
- pDDSPrim->Flip( NULL, 0 );
-
- MediaPlayer1->Play();
-
- Timer1->Enabled = true;
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- int max=56;
- ///////// level ////////////
- if ((k>=(max*43)) && (level==0)) {k=0;level=1;}
- if ((k>=(max*43)) && (level==1)) {k=0;level=2;}
- if ((k>=(max*43)) && (level==2)) {k=0;level=3;}
- if ((k>=(max*43)) && (level==3)) {k=0;level=4;}
- if ((k>=(max*43)) && (level==4)) {Close();}
-
- if ((k==0) && (level==0)) {Memo1->Lines->LoadFromFile("Level0.txt");
- Memo2->Lines->LoadFromFile("Avion.txt");}
- if ((k==0) && (level==1)) {Memo1->Lines->LoadFromFile("Level1.txt");
- Memo2->Lines->LoadFromFile("Avion.txt"); }
- if ((k==0) && (level==2)) {Memo1->Lines->LoadFromFile("Level2.txt");
- Memo2->Lines->LoadFromFile("Avion.txt"); }
- if ((k==0) && (level==3)) {Memo1->Lines->LoadFromFile("Level3.txt");
- Memo2->Lines->LoadFromFile("Avion.txt"); }
- if ((k==0) && (level==4)) {Memo1->Lines->LoadFromFile("Level4.txt");
- Memo2->Lines->LoadFromFile("Avion.txt"); }
-
- ///////////////////////////////
- k=k+tmp+12;
-
- ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
- pDDSPrim->GetAttachedSurface(&ddscaps, &pDDSSec);
- rc.left=0; rc.top=0; rc.right=640; rc.bottom=480;
- pDDSSec->BltFast(0,0,pDDSImage,&rc,DDBLTFAST_NOCOLORKEY);
-
- ////////////// etoiles ///////////
- rc.left=1; rc.top=955; rc.right=298; rc.bottom=997;
- for (int t=0; t<8; t++) {
- pDDSSec->BltFast(0, 43+43*2*t+etoile0-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- pDDSSec->BltFast(100,43*2*t+etoile0-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
- etoile0++; if (etoile0>=300) {etoile0=43;}
- for (int t=0; t<8; t++) {
- pDDSSec->BltFast(20 ,43+43*2*t+etoile1-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- pDDSSec->BltFast(120,43*2*t+etoile1-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
- etoile1=etoile1+5; if (etoile1>=300) {etoile1=43;}
-
- //////////////////////////////
-
- for (ligne=0; ligne<max; ligne++) {
- for (colone=1; colone<11; colone++) {
- s = Memo1->Lines->Strings[ligne];
- char c = s[colone];
-
- //////// détect les obstacles
- if ((c != char ('0')) &&
- ((y-35 <= ligne*42+k-(max*42)) && (y+18 >= ligne*42+k-(max*42)) ) &&
- ((x-25 <= colone*42-42) && (x+25 >= colone*42-42)))
-
- {char const *Path = "Alert.wav"; avion=1;
- sndPlaySound(Path, SND_ASYNC | SND_FILENAME); }
-
- if (c == char ('0')) {rc.left=1+43*4; rc.top=482 ; rc.right=43*4; rc.bottom=524; }
- if (c == char ('1')) {rc.left=1+43*10; rc.top=482 ; rc.right=43+43*10; rc.bottom=524; }
- if (c == char ('2')) {rc.left=1+43*11; rc.top=482 ; rc.right=43+43*11; rc.bottom=524; }
- if (c == char ('3')) {rc.left=1+43*12; rc.top=482 ; rc.right=43+43*12; rc.bottom=524; }
- if (c == char ('4')) {rc.left=1+43*13; rc.top=482 ; rc.right=43+43*13; rc.bottom=524; }
- if (c == char ('5')) {rc.left=1+43*10; rc.top=482+43*1; rc.right=43+43*10; rc.bottom=524+43*1;}
- if (c == char ('6')) {rc.left=1+43*11; rc.top=482+43*1; rc.right=43+43*11; rc.bottom=524+43*1;}
- if (c == char ('7')) {rc.left=1+43*12; rc.top=482+43*1; rc.right=43+43*12; rc.bottom=524+43*1;}
- if (c == char ('8')) {rc.left=1+43*13; rc.top=482+43*1; rc.right=43+43*13; rc.bottom=524+43*1;}
- if (c == char ('9')) {rc.left=1+43*10; rc.top=482+43*2; rc.right=43+43*10; rc.bottom=524+43*2;}
- if (c == char ('A')) {rc.left=1+43*11; rc.top=482+43*2; rc.right=43+43*11; rc.bottom=524+43*2;}
- if (c == char ('B')) {rc.left=1+43*12; rc.top=482+43*2; rc.right=43+43*12; rc.bottom=524+43*2;}
- if (c == char ('C')) {rc.left=1+43*13; rc.top=482+43*2; rc.right=43+43*13; rc.bottom=524+43*2;}
- if (c == char ('D')) {rc.left=1+43*9; rc.top=482+43*0; rc.right=43+43*9; rc.bottom=524+43*0;}
- if (c == char ('E')) {rc.left=1+43*9; rc.top=482+43*1; rc.right=43+43*9; rc.bottom=524+43*1;}
- if (c == char ('F')) {rc.left=1+43*9; rc.top=482+43*2; rc.right=43+43*9; rc.bottom=524+43*2;}
- if (c == char ('G')) {rc.left=1+43*9; rc.top=482+43*3; rc.right=43+43*9; rc.bottom=524+43*3;}
- if (c == char ('H')) {rc.left=1+43*10; rc.top=482+43*3; rc.right=43+43*10; rc.bottom=524+43*3;}
- if (c == char ('I')) {rc.left=1+43*11; rc.top=482+43*3; rc.right=43+43*11; rc.bottom=524+43*3;}
- if (c == char ('J')) {rc.left=1+43*9; rc.top=482+43*4; rc.right=43+43*9; rc.bottom=524+43*4;}
- if (c == char ('K')) {rc.left=1+43*10; rc.top=482+43*4; rc.right=43+43*10; rc.bottom=524+43*4;}
- if (c == char ('L')) {rc.left=1+43*12; rc.top=482+43*3; rc.right=43+43*12; rc.bottom=524+43*3;}
- if (c == char ('M')) {rc.left=1+43*12; rc.top=482+43*4; rc.right=43+43*12; rc.bottom=524+43*4;}
- if (c == char ('N')) {rc.left=1+43*9; rc.top=482+43*5; rc.right=43+43*9; rc.bottom=524+43*5;}
- if (c == char ('O')) {rc.left=1+43*10; rc.top=482+43*5; rc.right=43+43*10; rc.bottom=524+43*5;}
- pDDSSec->BltFast(colone*42-42,ligne*42+k-(max*42),pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
-
- ///////////// avion touché /////////////////////////
- }
- }
-
- times++;
- if (avion==0) {rc.left=1; rc.top=482; rc.right=43; rc.bottom=524;
- pDDSSec->BltFast(x,y,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
- if (avion==1) {rc.left=1+43; rc.top=482; rc.right=43+43; rc.bottom=524;
- pDDSSec->BltFast(x,y,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- AvionTouche++;}
-
- if (54+AvionTouche==231) {AvionTouche=0;} // GameOver
- rc.left=457; rc.top=53; rc.right=474; rc.bottom=57;
- for (int gg=53; gg<=53+AvionTouche; gg++){
- pDDSSec->BltFast(457,gg,pDDSImage,&rc,DDBLTFAST_NOCOLORKEY);}
-
-
- //////// reacteur de l'avion
- if (times >= 0) {
- rc.left=1+43*2; rc.top=482; rc.right=43*3; rc.bottom=524;
- pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- }
-
- if (times >= 5) {
- rc.left=1+43*3; rc.top=482; rc.right=43*4; rc.bottom=524;
- pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- }
-
- if (times >= 10) { times=0;
- rc.left=1+43*2; rc.top=482; rc.right=43*3; rc.bottom=524;
- pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- avion=0;} /////////////////// arme /////////////////
-
- if (arme==0) {
- rc.left=1+43*4; rc.top=482; rc.right=43*5; rc.bottom=524;
- pDDSSec->BltFast(x,y-(43*NbrArme),pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
- NbrArme++;
- if (NbrArme == 2) {char const *Path = "laser.wav";
- sndPlaySound(Path, SND_ASYNC | SND_FILENAME);}
- if (NbrArme == 9) {arme=1; NbrArme=1;}
- }
- ///////////////////////////////
-
- // Avion enemi
-
- for (int NbrLigne=0+sui; NbrLigne<=3+sui;NbrLigne++) {
-
- lpo = Memo2->Lines->Strings[NbrLigne]; //ligne
- Memo3->Lines->Clear();
- Memo3->Lines->Add(lpo);
-
-
- if ( ty == 8*15) {ty=0; } // end
-
- AnsiString e1 (Memo3->Text.c_str()),e2; // Nb graph
- AnsiString e3 (Memo3->Text.c_str()),e4; // xn
- AnsiString e5 (Memo3->Text.c_str()),e6; // yn
-
- e2 = e1.SubString(1,1); int nb = e2.ToInt();
- e4 = e3.SubString(3+ty,3); int xn = e4.ToInt();
- e6 = e5.SubString(7+ty,3); int yn = e6.ToInt();
-
- ViteseAvonEnemi++;
-
- if ((NbrLigne == 0+sui) && (ViteseAvonEnemi>=10)) {ty=ty+8; ViteseAvonEnemi=0;}
-
-
- if ((nb==1) && (AvionTouchenb1==0)) {tempnb1++;
- if (tempnb1 >= 0){rc.left=1; rc.top=482+43*2; rc.right=43; rc.bottom=524+43*2;}
- if (tempnb1 >= 3){rc.left=1+43*1; rc.top=482+43*2; rc.right=43+43*1; rc.bottom=524+43*2;}
- if (tempnb1 >= 6){rc.left=1+43*2; rc.top=482+43*2; rc.right=43+43*2; rc.bottom=524+43*2;}
- if (tempnb1 >= 9){rc.left=1; rc.top=482+43*2; rc.right=43; rc.bottom=524+43*2;
- tempnb1=0;}
- pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
-
- if ((nb==2) && (AvionTouchenb2==0)) {tempnb2++;
- if (tempnb2 >= 0) {rc.left=1; rc.top=482+43*1; rc.right=43; rc.bottom=524+43*1;}
- if (tempnb2 >= 3) {rc.left=1+43*1; rc.top=482+43*1; rc.right=43+43*1; rc.bottom=524+43*1;}
- if (tempnb2 >= 6) {rc.left=1+43*2; rc.top=482+43*1; rc.right=43+43*2; rc.bottom=524+43*1;}
- if (tempnb2 >= 9) {rc.left=1+43*3; rc.top=482+43*1; rc.right=43+43*3; rc.bottom=524+43*1;}
- if (tempnb2 >= 12){rc.left=1; rc.top=482+43*1; rc.right=43; rc.bottom=524+43*1;
- tempnb2=0;}
- pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
-
- if ((nb==3) && (AvionTouchenb3==0)) {tempnb3++;
- if (tempnb3 >= 0) {rc.left=1; rc.top=482+43*3; rc.right=43; rc.bottom=524+43*3;}
- if (tempnb3 >= 4) {rc.left=1+43*1; rc.top=482+43*3; rc.right=43+43*1; rc.bottom=524+43*3;}
- if (tempnb3 >= 16){rc.left=1; rc.top=482+43*3; rc.right=43; rc.bottom=524+43*3;
- tempnb3=0;}
- pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
-
- if ((nb==4) && (AvionTouchenb4==0)) {tempnb4++;
- if (tempnb4 >= 0) {rc.left=1; rc.top=482+43*5; rc.right=43; rc.bottom=524+43*5;}
- if (tempnb4 >= 4) {rc.left=1+43*1; rc.top=482+43*5; rc.right=43+43*1; rc.bottom=524+43*5;}
- if (tempnb4 >= 16){rc.left=1; rc.top=482+43*5; rc.right=43; rc.bottom=524+43*5;
- tempnb4=0;}
- pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
-
- // Avion enemi touché
- if (((x-20 <= xn) && (x+20 >= xn)) && ((y-25 <= yn) && (y+20 >= yn)))
- {
- if ((NbrLigne==0+sui) && (AvionTouchenb1==0)) {AvionTouchenb1=1;avion=1; SonNbr0();}
- if ((NbrLigne==1+sui) && (AvionTouchenb2==0)) {AvionTouchenb2=1;avion=1; SonNbr0();}
- if ((NbrLigne==2+sui) && (AvionTouchenb3==0)) {AvionTouchenb3=1;avion=1; SonNbr0();}
- if ((NbrLigne==3+sui) && (AvionTouchenb4==0)) {AvionTouchenb4=1;avion=1; SonNbr0();}
- }
-
- if (((x-20 <= xn) && (x+20 >= xn)) && ((y-(43*NbrArme)-20 <= yn) && (y-(43*NbrArme)+20 >= yn)))
- {
- if ((NbrLigne==0+sui) && (AvionTouchenb1==0)) {AvionTouchenb1=1; SonNbr0();}
- if ((NbrLigne==1+sui) && (AvionTouchenb2==0)) {AvionTouchenb2=1; SonNbr0();}
- if ((NbrLigne==2+sui) && (AvionTouchenb3==0)) {AvionTouchenb3=1; SonNbr0();}
- if ((NbrLigne==3+sui) && (AvionTouchenb4==0)) {AvionTouchenb4=1; SonNbr0();}
- }
-
- }
-
- if ((sui==0)&&(AvionTouchenb1==1) && (AvionTouchenb2==1) && (AvionTouchenb3==1) && (AvionTouchenb4==1))
- { AvionTouchenb1=0; AvionTouchenb2=0; AvionTouchenb3=0; AvionTouchenb4=0;
- sui=5; }
-
-
- pDDSPrim->Flip( NULL, 0 );
-
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
- {
- if (char(Key) == VK_RIGHT) { x=x+5; }
- if (char(Key) == VK_LEFT) { x=x-5; }
- if (char(Key) == VK_DOWN) { y=y+5; }
- if (char(Key) == VK_UP) { y=y-5; }
- if (char(Key) == ' ') { arme=0; }
-
- // if (char(Key) == '+') { tmp=tmp+1; } // vitesse
- // if (char(Key) == '-') { tmp=tmp-1; }
-
- if (x>=380) {x=380;}
- if (x<=0) {x=0;}
- if (y>=420) {y=420;}
- if (y<=0) {y=0;}
-
- if (char(Key)==(27)) { Close(); } // Echap
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SonNbr0()
- {
- char const *Path = "Protoss Exclamation.wav";
- sndPlaySound(Path, SND_ASYNC | SND_FILENAME);
- }
- //---------------------------------------------------------------------------
#include <vcl.h>
#include <ddraw.h>
#include <mmsystem.h>
#include "Main.h"
#include "ddutil.h"
#include "Unit2.h"
#pragma hdrstop
#pragma resource "*.dfm"
TForm1 *Form1;
char szBackground[] = "C6401000"; // BMP
int ty=0;
int x=100; int y=300; // cordoné de l'avion
int times = 0; // times du reacteur de l'avion
int arme=1; int NbrArme=1; // arme désactivé
int AvionTouche=0;
AnsiString s; int ligne=0; int colone=1; // cordoné du decor
int k=0; int tmp=0;
int level=0;
int etoile0=0; // etoile lente
int etoile1=0; // etoile rapide
//////////////////////////////////////////////////////
int avion=0; // Avion enemi
int ViteseAvonEnemi=0; // Vitese Avon Enemi
int tempnb1=0; // type avion 1
int tempnb2=0; // type avion 2
int tempnb3=0; // type avion 3
int tempnb4=0; // type avion 4
int AvionTouchenb1=0; // Avion Touché nb1
int AvionTouchenb2=0; // Avion Touché nb2
int AvionTouchenb3=0; // Avion Touché nb3
int AvionTouchenb4=0; // Avion Touché nb4
int NbrLigne=0;
AnsiString lpo; int sui=0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
Timer1->Enabled = false;
Form2 = new TForm2(Application);
Form2->ShowModal();
Start();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Start()
{
HRESULT res = DirectDrawCreate(NULL, &pDD, NULL);
pDD->SetCooperativeLevel(Handle,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
pDD->SetDisplayMode(640,480, 16);
pDD->CreateSurface(&ddsd, &pDDSPrim, NULL);
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
pDDSPrim->GetAttachedSurface(&ddscaps, &pDDSSec);
pDDPal = DDLoadPalette(pDD, szBackground);
pDDSImage = DDLoadBitmap(pDD, szBackground, 0, 0);
DDSetColorKey(pDDSImage,RGB(0,0,0)); // Couleur de transparence
pDDSPrim->Flip( NULL, 0 );
MediaPlayer1->Play();
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
int max=56;
///////// level ////////////
if ((k>=(max*43)) && (level==0)) {k=0;level=1;}
if ((k>=(max*43)) && (level==1)) {k=0;level=2;}
if ((k>=(max*43)) && (level==2)) {k=0;level=3;}
if ((k>=(max*43)) && (level==3)) {k=0;level=4;}
if ((k>=(max*43)) && (level==4)) {Close();}
if ((k==0) && (level==0)) {Memo1->Lines->LoadFromFile("Level0.txt");
Memo2->Lines->LoadFromFile("Avion.txt");}
if ((k==0) && (level==1)) {Memo1->Lines->LoadFromFile("Level1.txt");
Memo2->Lines->LoadFromFile("Avion.txt"); }
if ((k==0) && (level==2)) {Memo1->Lines->LoadFromFile("Level2.txt");
Memo2->Lines->LoadFromFile("Avion.txt"); }
if ((k==0) && (level==3)) {Memo1->Lines->LoadFromFile("Level3.txt");
Memo2->Lines->LoadFromFile("Avion.txt"); }
if ((k==0) && (level==4)) {Memo1->Lines->LoadFromFile("Level4.txt");
Memo2->Lines->LoadFromFile("Avion.txt"); }
///////////////////////////////
k=k+tmp+12;
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
pDDSPrim->GetAttachedSurface(&ddscaps, &pDDSSec);
rc.left=0; rc.top=0; rc.right=640; rc.bottom=480;
pDDSSec->BltFast(0,0,pDDSImage,&rc,DDBLTFAST_NOCOLORKEY);
////////////// etoiles ///////////
rc.left=1; rc.top=955; rc.right=298; rc.bottom=997;
for (int t=0; t<8; t++) {
pDDSSec->BltFast(0, 43+43*2*t+etoile0-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
pDDSSec->BltFast(100,43*2*t+etoile0-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
etoile0++; if (etoile0>=300) {etoile0=43;}
for (int t=0; t<8; t++) {
pDDSSec->BltFast(20 ,43+43*2*t+etoile1-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
pDDSSec->BltFast(120,43*2*t+etoile1-300,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
etoile1=etoile1+5; if (etoile1>=300) {etoile1=43;}
//////////////////////////////
for (ligne=0; ligne<max; ligne++) {
for (colone=1; colone<11; colone++) {
s = Memo1->Lines->Strings[ligne];
char c = s[colone];
//////// détect les obstacles
if ((c != char ('0')) &&
((y-35 <= ligne*42+k-(max*42)) && (y+18 >= ligne*42+k-(max*42)) ) &&
((x-25 <= colone*42-42) && (x+25 >= colone*42-42)))
{char const *Path = "Alert.wav"; avion=1;
sndPlaySound(Path, SND_ASYNC | SND_FILENAME); }
if (c == char ('0')) {rc.left=1+43*4; rc.top=482 ; rc.right=43*4; rc.bottom=524; }
if (c == char ('1')) {rc.left=1+43*10; rc.top=482 ; rc.right=43+43*10; rc.bottom=524; }
if (c == char ('2')) {rc.left=1+43*11; rc.top=482 ; rc.right=43+43*11; rc.bottom=524; }
if (c == char ('3')) {rc.left=1+43*12; rc.top=482 ; rc.right=43+43*12; rc.bottom=524; }
if (c == char ('4')) {rc.left=1+43*13; rc.top=482 ; rc.right=43+43*13; rc.bottom=524; }
if (c == char ('5')) {rc.left=1+43*10; rc.top=482+43*1; rc.right=43+43*10; rc.bottom=524+43*1;}
if (c == char ('6')) {rc.left=1+43*11; rc.top=482+43*1; rc.right=43+43*11; rc.bottom=524+43*1;}
if (c == char ('7')) {rc.left=1+43*12; rc.top=482+43*1; rc.right=43+43*12; rc.bottom=524+43*1;}
if (c == char ('8')) {rc.left=1+43*13; rc.top=482+43*1; rc.right=43+43*13; rc.bottom=524+43*1;}
if (c == char ('9')) {rc.left=1+43*10; rc.top=482+43*2; rc.right=43+43*10; rc.bottom=524+43*2;}
if (c == char ('A')) {rc.left=1+43*11; rc.top=482+43*2; rc.right=43+43*11; rc.bottom=524+43*2;}
if (c == char ('B')) {rc.left=1+43*12; rc.top=482+43*2; rc.right=43+43*12; rc.bottom=524+43*2;}
if (c == char ('C')) {rc.left=1+43*13; rc.top=482+43*2; rc.right=43+43*13; rc.bottom=524+43*2;}
if (c == char ('D')) {rc.left=1+43*9; rc.top=482+43*0; rc.right=43+43*9; rc.bottom=524+43*0;}
if (c == char ('E')) {rc.left=1+43*9; rc.top=482+43*1; rc.right=43+43*9; rc.bottom=524+43*1;}
if (c == char ('F')) {rc.left=1+43*9; rc.top=482+43*2; rc.right=43+43*9; rc.bottom=524+43*2;}
if (c == char ('G')) {rc.left=1+43*9; rc.top=482+43*3; rc.right=43+43*9; rc.bottom=524+43*3;}
if (c == char ('H')) {rc.left=1+43*10; rc.top=482+43*3; rc.right=43+43*10; rc.bottom=524+43*3;}
if (c == char ('I')) {rc.left=1+43*11; rc.top=482+43*3; rc.right=43+43*11; rc.bottom=524+43*3;}
if (c == char ('J')) {rc.left=1+43*9; rc.top=482+43*4; rc.right=43+43*9; rc.bottom=524+43*4;}
if (c == char ('K')) {rc.left=1+43*10; rc.top=482+43*4; rc.right=43+43*10; rc.bottom=524+43*4;}
if (c == char ('L')) {rc.left=1+43*12; rc.top=482+43*3; rc.right=43+43*12; rc.bottom=524+43*3;}
if (c == char ('M')) {rc.left=1+43*12; rc.top=482+43*4; rc.right=43+43*12; rc.bottom=524+43*4;}
if (c == char ('N')) {rc.left=1+43*9; rc.top=482+43*5; rc.right=43+43*9; rc.bottom=524+43*5;}
if (c == char ('O')) {rc.left=1+43*10; rc.top=482+43*5; rc.right=43+43*10; rc.bottom=524+43*5;}
pDDSSec->BltFast(colone*42-42,ligne*42+k-(max*42),pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
///////////// avion touché /////////////////////////
}
}
times++;
if (avion==0) {rc.left=1; rc.top=482; rc.right=43; rc.bottom=524;
pDDSSec->BltFast(x,y,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);}
if (avion==1) {rc.left=1+43; rc.top=482; rc.right=43+43; rc.bottom=524;
pDDSSec->BltFast(x,y,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
AvionTouche++;}
if (54+AvionTouche==231) {AvionTouche=0;} // GameOver
rc.left=457; rc.top=53; rc.right=474; rc.bottom=57;
for (int gg=53; gg<=53+AvionTouche; gg++){
pDDSSec->BltFast(457,gg,pDDSImage,&rc,DDBLTFAST_NOCOLORKEY);}
//////// reacteur de l'avion
if (times >= 0) {
rc.left=1+43*2; rc.top=482; rc.right=43*3; rc.bottom=524;
pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
}
if (times >= 5) {
rc.left=1+43*3; rc.top=482; rc.right=43*4; rc.bottom=524;
pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
}
if (times >= 10) { times=0;
rc.left=1+43*2; rc.top=482; rc.right=43*3; rc.bottom=524;
pDDSSec->BltFast(x,y+43,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
avion=0;} /////////////////// arme /////////////////
if (arme==0) {
rc.left=1+43*4; rc.top=482; rc.right=43*5; rc.bottom=524;
pDDSSec->BltFast(x,y-(43*NbrArme),pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY);
NbrArme++;
if (NbrArme == 2) {char const *Path = "laser.wav";
sndPlaySound(Path, SND_ASYNC | SND_FILENAME);}
if (NbrArme == 9) {arme=1; NbrArme=1;}
}
///////////////////////////////
// Avion enemi
for (int NbrLigne=0+sui; NbrLigne<=3+sui;NbrLigne++) {
lpo = Memo2->Lines->Strings[NbrLigne]; //ligne
Memo3->Lines->Clear();
Memo3->Lines->Add(lpo);
if ( ty == 8*15) {ty=0; } // end
AnsiString e1 (Memo3->Text.c_str()),e2; // Nb graph
AnsiString e3 (Memo3->Text.c_str()),e4; // xn
AnsiString e5 (Memo3->Text.c_str()),e6; // yn
e2 = e1.SubString(1,1); int nb = e2.ToInt();
e4 = e3.SubString(3+ty,3); int xn = e4.ToInt();
e6 = e5.SubString(7+ty,3); int yn = e6.ToInt();
ViteseAvonEnemi++;
if ((NbrLigne == 0+sui) && (ViteseAvonEnemi>=10)) {ty=ty+8; ViteseAvonEnemi=0;}
if ((nb==1) && (AvionTouchenb1==0)) {tempnb1++;
if (tempnb1 >= 0){rc.left=1; rc.top=482+43*2; rc.right=43; rc.bottom=524+43*2;}
if (tempnb1 >= 3){rc.left=1+43*1; rc.top=482+43*2; rc.right=43+43*1; rc.bottom=524+43*2;}
if (tempnb1 >= 6){rc.left=1+43*2; rc.top=482+43*2; rc.right=43+43*2; rc.bottom=524+43*2;}
if (tempnb1 >= 9){rc.left=1; rc.top=482+43*2; rc.right=43; rc.bottom=524+43*2;
tempnb1=0;}
pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
if ((nb==2) && (AvionTouchenb2==0)) {tempnb2++;
if (tempnb2 >= 0) {rc.left=1; rc.top=482+43*1; rc.right=43; rc.bottom=524+43*1;}
if (tempnb2 >= 3) {rc.left=1+43*1; rc.top=482+43*1; rc.right=43+43*1; rc.bottom=524+43*1;}
if (tempnb2 >= 6) {rc.left=1+43*2; rc.top=482+43*1; rc.right=43+43*2; rc.bottom=524+43*1;}
if (tempnb2 >= 9) {rc.left=1+43*3; rc.top=482+43*1; rc.right=43+43*3; rc.bottom=524+43*1;}
if (tempnb2 >= 12){rc.left=1; rc.top=482+43*1; rc.right=43; rc.bottom=524+43*1;
tempnb2=0;}
pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
if ((nb==3) && (AvionTouchenb3==0)) {tempnb3++;
if (tempnb3 >= 0) {rc.left=1; rc.top=482+43*3; rc.right=43; rc.bottom=524+43*3;}
if (tempnb3 >= 4) {rc.left=1+43*1; rc.top=482+43*3; rc.right=43+43*1; rc.bottom=524+43*3;}
if (tempnb3 >= 16){rc.left=1; rc.top=482+43*3; rc.right=43; rc.bottom=524+43*3;
tempnb3=0;}
pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
if ((nb==4) && (AvionTouchenb4==0)) {tempnb4++;
if (tempnb4 >= 0) {rc.left=1; rc.top=482+43*5; rc.right=43; rc.bottom=524+43*5;}
if (tempnb4 >= 4) {rc.left=1+43*1; rc.top=482+43*5; rc.right=43+43*1; rc.bottom=524+43*5;}
if (tempnb4 >= 16){rc.left=1; rc.top=482+43*5; rc.right=43; rc.bottom=524+43*5;
tempnb4=0;}
pDDSSec->BltFast(xn,yn,pDDSImage,&rc,DDBLTFAST_SRCCOLORKEY); }
// Avion enemi touché
if (((x-20 <= xn) && (x+20 >= xn)) && ((y-25 <= yn) && (y+20 >= yn)))
{
if ((NbrLigne==0+sui) && (AvionTouchenb1==0)) {AvionTouchenb1=1;avion=1; SonNbr0();}
if ((NbrLigne==1+sui) && (AvionTouchenb2==0)) {AvionTouchenb2=1;avion=1; SonNbr0();}
if ((NbrLigne==2+sui) && (AvionTouchenb3==0)) {AvionTouchenb3=1;avion=1; SonNbr0();}
if ((NbrLigne==3+sui) && (AvionTouchenb4==0)) {AvionTouchenb4=1;avion=1; SonNbr0();}
}
if (((x-20 <= xn) && (x+20 >= xn)) && ((y-(43*NbrArme)-20 <= yn) && (y-(43*NbrArme)+20 >= yn)))
{
if ((NbrLigne==0+sui) && (AvionTouchenb1==0)) {AvionTouchenb1=1; SonNbr0();}
if ((NbrLigne==1+sui) && (AvionTouchenb2==0)) {AvionTouchenb2=1; SonNbr0();}
if ((NbrLigne==2+sui) && (AvionTouchenb3==0)) {AvionTouchenb3=1; SonNbr0();}
if ((NbrLigne==3+sui) && (AvionTouchenb4==0)) {AvionTouchenb4=1; SonNbr0();}
}
}
if ((sui==0)&&(AvionTouchenb1==1) && (AvionTouchenb2==1) && (AvionTouchenb3==1) && (AvionTouchenb4==1))
{ AvionTouchenb1=0; AvionTouchenb2=0; AvionTouchenb3=0; AvionTouchenb4=0;
sui=5; }
pDDSPrim->Flip( NULL, 0 );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
if (char(Key) == VK_RIGHT) { x=x+5; }
if (char(Key) == VK_LEFT) { x=x-5; }
if (char(Key) == VK_DOWN) { y=y+5; }
if (char(Key) == VK_UP) { y=y-5; }
if (char(Key) == ' ') { arme=0; }
// if (char(Key) == '+') { tmp=tmp+1; } // vitesse
// if (char(Key) == '-') { tmp=tmp-1; }
if (x>=380) {x=380;}
if (x<=0) {x=0;}
if (y>=420) {y=420;}
if (y<=0) {y=0;}
if (char(Key)==(27)) { Close(); } // Echap
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SonNbr0()
{
char const *Path = "Protoss Exclamation.wav";
sndPlaySound(Path, SND_ASYNC | SND_FILENAME);
}
//---------------------------------------------------------------------------
Conclusion
Mon soft sera mis à jours , selon les modifications reçu.
pas de bugs connus sur mon PC.
(je cherche des programmes source pour DirectSound 3D, et DirectDraw 3D ( pas openGL, c Nul ) avec DirectX.)
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Jeu de moto en réseau avec DirectX [ par supergrey ]
Le jeu est disponible a cette adresse : http://supergrey.free.fr/TrialtimeBattleNet.exeMais c'est il se joue a deux en réseaux, donc pour le tester il
DIRECTX et interface [ par ELKI ]
je suis en train de concevoir un jeu d'echec et j'aurai voulu savoir comment je pouurai faire pour associer des pièce d'un jeu d'echec avec mon interf
Jeu DirectX [ par Mickylord ]
Bonjour , je vien de commencer a faire mon premier jeu en DirectX , mais j'ai un petit problème : J'aimerai que quand j'appui sur la touche droite ( p
Interfacer 3DSMax avec DirectX ? [ par bubbathemaster ]
Bonjour,Il y a quelques mois je me suis mis à m'interresser en détails à DirectX. Ma première approche a été d'utiliser
Création du jeu DirectX ou/et OpenGL [ par nico1610 ]
Bonjour à tous, je me présente, Je m'appel Nicolas alias "=SG-Pro= ergo" je fais (à ce titre) parti de l'exélente teams Stargate-Pro et nous sommes à
Code d'initialisation de DirectX 9 [ par cathylarainette ]
J'ai telechargé un jeu de motos(SBK08) et tout s'instale sauf directX 9.Je cherche partout comment initialiser directX 9.Mon jeu ne peut pas s'ouvrir.
Création d'un jeu de stratégie en CPP et DIRECTX ! [ par DunËsPIdËr ]
SalUt à tOuS! Nous sommes actuellement 4 programmeurs et 1 infographiste. Nous voulons créer un jeu de stratégie en temps réel sous Win utilisant di
un ptit jeu [ par BLaFarD ]
euh, je viens de me pondre un petit moteur 3d de merde en opengldonc, si qlqun veut me filer des model 3d k'il a fait (sous 3dsmax si possible), bah,
Je cherche des Infos sur DirectX [ par Ares ]
Salut, a tousJe cherche des Infos sur DirectX, si vous avez des truc, site documentation etc. Poster un reponseMerci d'avance
|
Derniers Blogs
TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : CXIMAGERE : CXIMAGE par rt15
Cliquez pour lire la suite par rt15
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|