Downloader iv
Utente Attivo
- Messaggi
- 39
- Reazioni
- 0
- Punteggio
- 26
Questa dovrebbe essere una base per un gioco in 2d tipo picchiaduro.
Cosa c'è che non và?
#include"allegro.h"
BITMAP *buf, sprite1, sprite2, sfondo;
int x, y, xcat, ycat, vita, vitacat, vittoria;
int a= x-xcat;
PALETTE colori;
void doppiobuffering()
{
blit(buf, screen, 0, 0, 0, 0, 1024, 768);
clear(buf);
}
void sprite1()
{
draw_sprite(buf, sprite1, x, y);
}
void sprite2()
{
draw_sprite(buf, sprite2, xcat, ycat);
}
void movimento sprite1()
{
if (key![KEY_LEFT]) x = x - 2;
if (x<=0) x = 0;
if (key![KEY_RIGHT]) x = x + 2;
if (x>=1024) x = 1024;
if (key![KEY_UP]) y = y - 20;
if (y>=) y = 700;
}
void movimento sprite 2()
{
if (key![KEY_4]) xcat = xcat - 2;
if (xcat<=0) xcat = 0;
if (key![KEY_6]) xcat = xcat + 2;
if (xcat>=1024) xcat = 1024;
if (key![KEY_8]) ycat = ycat - 2;
if (ycat<=0) ycat = 0;
if (key![KEY_2]) ycat = ycat + 2;
if (xcat>=768) xcat = 768;
}
void partita()
{
if (vita == 0)
vittoria=1
elseif (vitacat==0)
vittoria=2
}
float valore_assoluto(float a){
if(a<0) return -a;
return a;
}
void combattimento()
{
if (key![KEY_Q] & a<10)
vita = vita -1
}
int main()
{
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0);
buf = create_bitmap(1024, 768);
sfondo=load_bitmap("sfondo.bmp", colori);
sprite1=load_bitmap("sprite 1.bmp", colori);
sprite2=load_bitmap("sprite 2.bmp", colori);
clear(buf);
while (vittoria == 0) {
partita()
doppiobuffering();
sprite1();
sprite2();
movimento sprite1();
movimento sprite2();
partita();
combattimento();
}
destroy_bitmap(buf, sprite1, sprite2, sfondo);
}
END_OF_MAIN ();
La parte colorata è da rivedere cioè nn è finita.Vorrei fare andare nella funzione void combattimento direttamente il valore assoluto di a cioè (xcat-x).
Qualcuno mi dà qualche consiglio?
Cosa c'è che non và?
#include"allegro.h"
BITMAP *buf, sprite1, sprite2, sfondo;
int x, y, xcat, ycat, vita, vitacat, vittoria;
int a= x-xcat;
PALETTE colori;
void doppiobuffering()
{
blit(buf, screen, 0, 0, 0, 0, 1024, 768);
clear(buf);
}
void sprite1()
{
draw_sprite(buf, sprite1, x, y);
}
void sprite2()
{
draw_sprite(buf, sprite2, xcat, ycat);
}
void movimento sprite1()
{
if (key![KEY_LEFT]) x = x - 2;
if (x<=0) x = 0;
if (key![KEY_RIGHT]) x = x + 2;
if (x>=1024) x = 1024;
if (key![KEY_UP]) y = y - 20;
if (y>=) y = 700;
}
void movimento sprite 2()
{
if (key![KEY_4]) xcat = xcat - 2;
if (xcat<=0) xcat = 0;
if (key![KEY_6]) xcat = xcat + 2;
if (xcat>=1024) xcat = 1024;
if (key![KEY_8]) ycat = ycat - 2;
if (ycat<=0) ycat = 0;
if (key![KEY_2]) ycat = ycat + 2;
if (xcat>=768) xcat = 768;
}
void partita()
{
if (vita == 0)
vittoria=1
elseif (vitacat==0)
vittoria=2
}
float valore_assoluto(float a){
if(a<0) return -a;
return a;
}
void combattimento()
{
if (key![KEY_Q] & a<10)
vita = vita -1
}
int main()
{
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0);
buf = create_bitmap(1024, 768);
sfondo=load_bitmap("sfondo.bmp", colori);
sprite1=load_bitmap("sprite 1.bmp", colori);
sprite2=load_bitmap("sprite 2.bmp", colori);
clear(buf);
while (vittoria == 0) {
partita()
doppiobuffering();
sprite1();
sprite2();
movimento sprite1();
movimento sprite2();
partita();
combattimento();
}
destroy_bitmap(buf, sprite1, sprite2, sfondo);
}
END_OF_MAIN ();
La parte colorata è da rivedere cioè nn è finita.Vorrei fare andare nella funzione void combattimento direttamente il valore assoluto di a cioè (xcat-x).
Qualcuno mi dà qualche consiglio?