Pardon un oublie de ma part voici en gros à quoi ressemble mon programme Merci toute les sugestions sont les bienvenues.
#include <dos.h> #include <conio.h> #include <string.h> #include <stdio.h> #include <ctype.h>
#define Largeur_X 32 #define Hauteur_Y 32 #define Carte_X 64 #define Carte_Y 64
unsigned char* realscreen=(unsigned char*)(0xA0000000L); unsigned char* fakescreen=new unsigned char[64000L]; unsigned char Carte[Carte_X][Carte_Y];
struct Sprite { char* Graph; int X; int Y; };
Sprite Scroll[65]; Sprite Monde; Sprite Tiles; char* Bitmap;
void ModeVGA() { _AX=0x13; geninterrupt(0x10); }
void GenPAL(unsigned char Index,unsigned char R,unsigned char G,unsigned char B) { outportb(0x3C8,Index); outportb(0x3C9,R); outportb(0x3C9,G); outportb(0x3C9,B); }
void Pict(unsigned char* Fichier,unsigned char* Ecran) { unsigned char Pal[768L]; unsigned Point; unsigned Boucle=0; int N; FILE* Coord; Coord=fopen(Fichier,"rb"); fseek(Coord,-768L,SEEK_END); fread(Pal,768L,1L,Coord); for (int X=0;X<256;X++) GenPAL(X,Pal[X*3]>>2,Pal[X*3+1]>>2,Pal[X*3+2]>>2); fseek(Coord,128L,SEEK_SET); do { Point=fgetc(Coord); if(( Point & 0xC0)==0xC0) { N=Point & 0X3F; Point=fgetc(Coord); for (int X=0;X<N;X++) Ecran[Boucle++]=Point; }else Ecran[Boucle++]=Point; }while(Boucle<64000L); }
void Maps() { FILE *F; F=fopen("Plan.map", "rb"); for(int X=0;X<Carte_X;X++) for(int Y=0;Y<Carte_Y;Y++) Carte[Y][X]=fgetc(F); }
void Lir(int VX,int VY,int Largeur,int Hauteur,Sprite* Scroll) { Scroll->Graph=new char[Largeur*Hauteur]; for (int X=0;X<Largeur;X++) for (int Y=0;Y<Hauteur;Y++) Scroll->Graph[Y*Largeur+X]=Bitmap[(VY+Y)*Largeur+VX+X]; }
void Put(int VX,int VY,Sprite* Scroll) { unsigned char Neutre; for (int X=0;X<Largeur_X;X++) for (int Y=0;Y<Hauteur_Y;Y++) { Neutre=Scroll->Graph[Y*Largeur_X+X];
if (Neutre) fakescreen[(VY+Y)*320+VX+X]=Neutre; } }
void main() { ModeVGA(); int Exit=0; int Touche;
Bitmap=new char[64000L];
Maps(); Pict("Brique.pcx",Bitmap); for (int X=0;X<10;X++) for (int Y=0;Y<6;Y++) Lir((Largeur_X*X),(Hauteur_Y*Y),Largeur_X,Hauteur_Y,&Scroll[Y*10+X]);
Pict("Fond.pcx",Bitmap); do { if (kbhit()) { Touche=toupper(getch()); if (Touche==77) { Monde.X++; } if (Touche==75) { Monde.X--; } if (Touche==27) { Exit=6; } } memcpy(fakescreen,Bitmap,64000L); unsigned char TileX = Monde.X/Largeur_X; unsigned char TileY = Monde.Y/Hauteur_Y; short Xoff = Monde.X-TileX*Largeur_X; short Yoff = Monde.Y-TileY*Hauteur_Y; for (int X=0;X<10;X++) for (int Y=0;Y<6 ;Y++) Put((Largeur_X*X-Xoff),(Hauteur_Y*Y-Yoff),&Scroll[Carte[TileX+X][TileY+Y]]); memcpy(realscreen,fakescreen,64000L); }while(Exit<5); }
|