Vous n'êtes pas identifié.
Mais pkoi ce prog deconne?Le sprite ne s affiche qu a moitié!!
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <bios.h>
unsigned char ktrascii[59][5][3] =
{
0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, //_ -> 32 (00)
0,1,0, 0,1,0, 0,1,0, 0,0,0, 0,1,0, //! -> 33 (01)
1,0,1, 1,0,1, 0,0,0, 0,0,0, 0,0,0, //" -> 34 (02)
1,0,1, 1,1,1, 1,0,1, 1,1,1, 1,0,1, //# -> 35 (03)
1,1,1, 1,1,0, 1,1,1, 0,1,1, 1,1,1, //$ -> 36 (04)
1,0,0, 0,0,1, 0,1,0, 1,0,0, 0,0,1, //% -> 37 (05)
0,1,0, 1,0,1, 0,1,1, 1,0,1, 0,1,1, //& -> 38 (06)
1,1,0, 1,1,0, 0,0,0, 0,0,0, 0,0,0, //ø -> 39 (07)
0,0,1, 0,1,0, 0,1,0, 0,1,0, 0,0,1, //( -> 40 (0
1,0,0, 0,1,0, 0,1,0, 0,1,0, 1,0,0, //) -> 41 (09)
1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1, //* -> 42 (10)
0,0,0, 0,1,0, 1,1,1, 0,1,0, 0,0,0, //+ -> 43 (11)
0,0,0, 0,0,0, 0,0,0, 0,1,0, 1,0,0, //, -> 44 (12)
0,0,0, 0,0,0, 1,1,1, 0,0,0, 0,0,0, //- -> 45 (13)
0,0,0, 0,0,0, 0,0,0, 0,0,0, 1,0,0, //. -> 46 (14)
0,0,1, 0,1,0, 0,1,0, 0,1,0, 1,0,0, /// -> 47 (15)
1,1,1, 1,0,1, 1,0,1, 1,0,1, 1,1,1, //0 -> 48 (16)
0,1,0, 1,1,0, 0,1,0, 0,1,0, 1,1,1, //1 -> 49 (17)
1,1,1, 0,0,1, 1,1,1, 1,0,0, 1,1,1, //2 -> 50 (1
1,1,1, 0,0,1, 1,1,1, 0,0,1, 1,1,1, //3 -> 51 (19)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1,1,1, //J -> 74 (42)
1,0,1, 1,1,0, 1,0,0, 1,1,0, 1,0,1, //K -> 75 (43)
1,0,0, 1,0,0, 1,0,0, 1,0,0, 1,1,1, //L -> 76 (44)
1,0,1, 1,1,1, 1,0,1, 1,0,1, 1,0,1, //M -> 77 (45)
1,0,1, 1,1,1, 1,1,1, 1,0,1, 1,0,1, //N -> 78 (46)
0,1,0, 1,0,1, 1,0,1, 1,0,1, 0,1,0, //O -> 79 (47)
1,1,0, 1,0,1, 1,1,0, 1,0,0, 1,0,0, //P -> 80 (4
0,1,0, 1,0,1, 1,0,1, 0,1,0, 0,0,1, //Q -> 81 (49)
1,1,0, 1,0,1, 1,1,0, 1,1,0, 1,0,1, //R -> 82 (50)
1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1, //S -> 83 (51)
1,1,1, 0,1,0, 0,1,0, 0,1,0, 0,1,0, //T -> 84 (52)
1,0,1, 1,0,1, 1,0,1, 1,0,1, 1,1,1, //U -> 85 (53)
1,0,1, 1,0,1, 1,0,1, 1,0,1, 0,1,0, //V -> 86 (54)
1,0,1, 1,0,1, 1,0,1, 1,1,1, 1,0,1, //W -> 87 (55)
1,0,1, 1,0,1, 0,1,0, 1,0,1, 1,0,1, //X -> 88 (56)
1,0,1, 1,0,1, 0,1,0, 0,1,0, 1,0,0, //Y -> 89 (57)
1,1,1, 0,0,1, 0,1,0, 1,0,0, 1,1,1 //Z -> 90 (5
};
/*inverse les couleurs (duobab)*/
void inv_pixel (unsigned short int x, unsigned short int y)
{
asm push ax;
asm push cx;
asm push dx;
asm mov cx,x;
asm mov dx,y;
asm mov ax,0x1A20;
asm mov es,ax;
asm mov si,0x003f;
asm sub si,dx;
asm sub cx,0x80;
asm not cx;
asm push cx;
asm and cl,0xf8;
asm shl cx,0x03;
asm add si,cx;
asm pop cx;
asm and cl,0x07;
asm mov al,es:[si];
asm ror al,cl;
asm not al;
asm and al,1;
asm mov ah,0xfe;
asm rol ah,cl;
asm and es:[si],ah;
asm mov ah,al;
asm rol ah,cl;
asm or es:[si],ah;
asm pop dx;
asm pop cx;
asm pop ax;
};
char avion[1][8][21] = {
0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,
0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,
0,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,
0,0,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,1,1,1,1,
0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
};
void drawavion(unsigned char x, unsigned char y, unsigned char nb)
{int C,D;
for(C=0;C<8;C++){
for(D=0;D<21;D++){
if(avion[nb][D][C]==1) inv_pixel(x + C,y + D);}}};
int main()
{
clrscr();
drawavion(10,10,0);
getch();
return(0);
}
Hors ligne
CA Y ESTT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 8O 8O
Mon 1er prog en c qui marche!!!yaaaaaahaaaouuuuuu!!!c est bon, g tt corrigé.
Par contre, la vitesse de deplact est trop rapide...Y a pas un moyen de diminiuer??ou alors ce sera automatik si j agrandis mon prog???
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <bios.h>
unsigned char ktrascii[59][5][3] =
{
0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, //_ -> 32 (00)
0,1,0, 0,1,0, 0,1,0, 0,0,0, 0,1,0, //! -> 33 (01)
1,0,1, 1,0,1, 0,0,0, 0,0,0, 0,0,0, //" -> 34 (02)
1,0,1, 1,1,1, 1,0,1, 1,1,1, 1,0,1, //# -> 35 (03)
1,1,1, 1,1,0, 1,1,1, 0,1,1, 1,1,1, //$ -> 36 (04)
1,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, 1,0,0, //; -> 59 (27)
0,0,1, 0,1,1, 1,1,1, 0,1,1, 0,0,1, //< -> 60 (2
0,0,0, 1,1,1, 0,0,0, 1,1,1, 0,0,0, //= -> 61 (29)
1,0,0, 1,1,0, 1,1,1, 1,1,0, 1,0,0, //> -> 62 (30)
0,1,0, 1,0,1, 0,0,1, 0,1,0, 0,1,0, //? -> 63 (31)
1,1,1, 0,0,1, 1,1,1, 1,0,1, 1,1,1, //@ -> 64 (32)
0,1,0, 1,0,1, 1,0,1, 1,1,1, 1,0,1, //A -> 65 (33)
1,1,0, 1,0,1, 1,1,0, 1,0,1, 1,1,0, //B -> 66 (34)
0,1,1, 1,0,0, 1,0,0, 1,0,0, 0,1,1, //C -> 67 (35)
1,1,0, 1,0,1, 1,0,1, 1,0,1, 1,1,0, //D -> 68 (36)
1,1,1, 1,0,0, 1,1,0, 1,0,0, 1,1,1, //E -> 69 (37)
1,1,1, 1,0,0, 1,1,0, 1,0,0, 1,0,0, //F -> 70 (3
1,1,1, 1,0,0, 1,1,1, 1,0,1, 1,1,1, //G -> 71 (39)
1,0,1, 1,0,1, 1,1,1, 1,0,1, 1,0,1, //H -> 72 (40)
1,1,1, 0,1,0, 0,1,0, 0,1,0, 1,1,1, //I -> 73 (41)
1,1,1, 0,0,1, 0,0,1, 1,0,1, 1,1,1, //J -> 74 (42)
1,0,1, 1,1,0, 1,0,0, 1,1,0, 1,0,1, //K -> 75 (43)
1,0,0, 1,0,0, 1,0,0, 1,0,0, 1,1,1, //L -> 76 (44)
1,0,1, 1,1,1, 1,0,1, 1,0,1, 1,0,1, //M -> 77 (45)
1,0,1, 1,1,1, 1,1,1, 1,0,1, 1,0,1, //N -> 78 (46)
0,1,0, 1,0,1, 1,0,1, 1,0,1, 0,1,0, //O -> 79 (47)
1,1,0, 1,0,1, 1,1,0, 1,0,0, 1,0,0, //P -> 80 (4
0,1,0, 1,0,1, 1,0,1, 0,1,0, 0,0,1, //Q -> 81 (49)
1,1,0, 1,0,1, 1,1,0, 1,1,0, 1,0,1, //R -> 82 (50)
1,1,1, 1,0,0, 1,1,1, 0,0,1, 1,1,1, //S -> 83 (51)
1,1,1, 0,1,0, 0,1,0, 0,1,0, 0,1,0, //T -> 84 (52)
1,0,1, 1,0,1, 1,0,1, 1,0,1, 1,1,1, //U -> 85 (53)
1,0,1, 1,0,1, 1,0,1, 1,0,1, 0,1,0, //V -> 86 (54)
1,0,1, 1,0,1, 1,0,1, 1,1,1, 1,0,1, //W -> 87 (55)
1,0,1, 1,0,1, 0,1,0, 1,0,1, 1,0,1, //X -> 88 (56)
1,0,1, 1,0,1, 0,1,0, 0,1,0, 1,0,0, //Y -> 89 (57)
1,1,1, 0,0,1, 0,1,0, 1,0,0, 1,1,1 //Z -> 90 (5
};
/*inverse les couleurs (duobab)*/
void inv_pixel (unsigned short int x, unsigned short int y)
{
asm push ax;
asm push cx;
asm push dx;
asm mov cx,x;
asm mov dx,y;
asm mov ax,0x1A20;
asm mov es,ax;
asm mov si,0x003f;
asm sub si,dx;
asm sub cx,0x80;
asm not cx;
asm push cx;
asm and cl,0xf8;
asm shl cx,0x03;
asm add si,cx;
asm pop cx;
asm and cl,0x07;
asm mov al,es:[si];
asm ror al,cl;
asm not al;
asm and al,1;
asm mov ah,0xfe;
asm rol ah,cl;
asm and es:[si],ah;
asm mov ah,al;
asm rol ah,cl;
asm or es:[si],ah;
asm pop dx;
asm pop cx;
asm pop ax;
};
char avion[1][8][21] = {
0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,
1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,
0,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,
0,1,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,
0,0,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,1,1,1,1,
0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,
0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,
};
void drawavion(unsigned char x, unsigned char y, unsigned char nb)
{int C,D;
for(C=0;C<21;C++){
for(D=0;D<8;D++){
if(avion[nb][D][C]==1) inv_pixel(x + C,y + D);}}};
int main()
{
int a=0;int b=0;int key,exe=0x1c,gauche=0x4b,droite=0x4d,haut=0x48,bas=0x50;
key=0;
clrscr();
dess:
key=peekb(0x40,0XAF);
if(key==droite){drawavion(a,b,0);if(a+3<125){a=a+3;}drawavion(a,b,0);};
if(key==gauche){drawavion(a,b,0);if(a-2>0){a=a-3;}drawavion(a,b,0);};
if(key==haut){drawavion(a,b,0);if(b-2>0){b=b-2;}drawavion(a,b,0);};
if(key==bas){drawavion(a,b,0);if(b+2<49){b=b+2;}drawavion(a,b,0);};
if(key==exe){return(0)};
goto dess;
}
Hors ligne
Mes amis, 7 soiree a ete une soiree miracle pour moi.Mon prog se porte a merveille.
petite question:
Jai besoin de faire evoluer sur un background un e sprite.Bon, le probleme, c est que je veux que le sprite soit en avant plan, qu il n i,verse pas les couleurs en passant sur le fond.Ca me mene donc a:
void drawavion(unsigned char x, unsigned char y, unsigned char nb)
{int C,D;
for(C=0;C<21;C++){
for(D=0;D<8;D++){
if(avion[nb][D][C]==1) aff_pixel(x + C,y + D);}}};
au lieu de:
void drawavion(unsigned char x, unsigned char y, unsigned char nb)
{int C,D;
for(C=0;C<21;C++){
for(D=0;D<8;D++){
if(avion[nb][D][C]==1) inv_pixel(x + C,y + D);}}};
mais malheureusement, le aff_pixel m oblige a effacer l ecran a chaque fois que le sprite bouge!!C est lent et moche!!Comment dois je faire?
Hors ligne
issue de Graphics.h
void white_pixel(int X,int Y) //Affiche un pixel blanc
{
asm {
mov cx,X
mov dx,Y
mov si,0x003f
sub si,dx
sub cx,0x80
not cx
push cx
and cl,0xf8
shl cx,0x03
add si,cx
pop cx
and cl,0x07
mov bl,0xFF
db 0x0F,0x12,0x0C3 //clr1 bl,cl (specifique au nec v20/30)
and es:[si],bl
}
}
Hors ligne
Encore mieux:
passe en CB (C3*3), t'affiches ton arrière plan sur 0x1AA0 et tu affiches ton avion sur 0x1A20 ET 0x1AA0 pour le voir en noir. Comme ça t'as le fond entièrement en gris et l'avion en noir!
Hors ligne
je deviens fou quand j'entends parler du mode DB 8O :tourne: :fou:
le mode FB marche nikel et encore merci Casiomax pour ton aide HO combien précieuse.
Hors ligne
Passke je me sui ô mal KC les couilles a le faire ce put1 de tableau alors j'aime bien k'on sache ke C moâ ki l'a fait et me mettre dans les crédits des jeux ki l'utilise...
Mode DB = mode FB, non ?
Hors ligne