Joc funcional, rebot dels ORNIs no original
This commit is contained in:
@@ -183,6 +183,7 @@ byte llig(word x, word y) {
|
||||
case 6: return (virt[y*80+(x>>3)] & 0x02) >> 1; break;
|
||||
case 7: return virt[y*80+(x>>3)] & 0x01; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void posavga(word x, word y, byte color) {
|
||||
@@ -256,7 +257,7 @@ boolean linea(word x1, word y1, word x2, word y2, word color) {
|
||||
integer xs = x2-x1, ys = y2-y1;
|
||||
|
||||
integer xm = sign(xs), ym = sign(ys);
|
||||
integer xs = fabs(xs), ys = fabs(ys);
|
||||
xs = fabs(xs); ys = fabs(ys);
|
||||
if (llig(x,y)==1) col++;
|
||||
posa(x,y,color);
|
||||
|
||||
@@ -317,18 +318,23 @@ void rota_pol(poligon pol, real angul, byte color) {
|
||||
|
||||
void mou_orni(poligon &orni) {
|
||||
orni.angle = orni.angle/*+(random(256)/512)*(random(3)-1)*/;
|
||||
real dy = round(orni.velocitat*sin(orni.angle-pi/2))+orni.centre.y;
|
||||
real dx = round(orni.velocitat*cos(orni.angle-pi/2))+orni.centre.x;
|
||||
real dy = round(orni.velocitat*sin(orni.angle-pi/2.0))+orni.centre.y;
|
||||
real dx = round(orni.velocitat*cos(orni.angle-pi/2.0))+orni.centre.x;
|
||||
if ((dy>marge_dalt) && (dy<marge_baix)) {
|
||||
orni.centre.y = round(dy);
|
||||
} else {
|
||||
orni.angle = orni.angle+(random(256)/512)*(random(3)-1);
|
||||
// NOTA3: No he pogut reproduir el moviment dels ORNIs amb el codi que hi havia en l'original. Si el fique talqual no va be.
|
||||
// (els ORNIs se queden atascats a les vores). El codi original es la linea comentada despres de la actual. Seguiré investigant...
|
||||
orni.angle = orni.angle+(pi*(random(200)/100));
|
||||
//orni.angle = orni.angle+(random(256)/512)*(random(3)-1);
|
||||
}
|
||||
|
||||
if ((dx>marge_esq) && (dx<marge_dret)) {
|
||||
orni.centre.x = round(dx);
|
||||
} else {
|
||||
orni.angle = orni.angle+(random(256)/512)*(random(3)-1);
|
||||
// vore NOTA3
|
||||
orni.angle = orni.angle+(pi*(random(200)/100));
|
||||
//orni.angle = orni.angle+(random(256)/512)*(random(3)-1);
|
||||
}
|
||||
orni.rotacio = orni.rotacio+orni.drotacio;
|
||||
}
|
||||
@@ -395,7 +401,7 @@ void tocado() {
|
||||
if (itocado>250) itocado=0;
|
||||
}
|
||||
|
||||
int main(int argc, char argv[]) {
|
||||
int main(int argc, char *argv[]) {
|
||||
randomize();
|
||||
//getmem(virt,38400); virt es un array estatic, no fa falta reservar memòria
|
||||
itocado = 0;
|
||||
@@ -413,22 +419,22 @@ int main(int argc, char argv[]) {
|
||||
do {
|
||||
clsvirt();
|
||||
|
||||
if (teclapuls(KEYarrowright)) nau.angle += 0.157079632;
|
||||
if (teclapuls(KEYarrowleft)) nau.angle -= 0.157079632;
|
||||
if (teclapuls(KEYarrowup)) {
|
||||
if (teclapuls(keyArrowRight)) nau.angle += 0.157079632;
|
||||
if (teclapuls(keyArrowLeft)) nau.angle -= 0.157079632;
|
||||
if (teclapuls(keyArrowUp)) {
|
||||
if (nau.velocitat<velocitat_max) nau.velocitat += 0.2;
|
||||
}
|
||||
if (teclapuls(KEYspace) && (!bales[1].esta)) {
|
||||
bales[1].esta = true;
|
||||
bales[1].centre.x = nau.centre.x;
|
||||
bales[1].centre.y = nau.centre.y;
|
||||
bales[1].n = 2;
|
||||
bales[1].velocitat = 7;
|
||||
bales[1].ipuntx[1].r = 10;
|
||||
bales[1].ipuntx[1].angle = pi/2+nau.angle;
|
||||
bales[1].ipuntx[2].r = 20;
|
||||
bales[1].ipuntx[2].angle = pi/2+nau.angle;
|
||||
bales[1].angle = nau.angle;
|
||||
}
|
||||
if (teclapuls(keySpace) && (!bales[1].esta)) {
|
||||
bales[1].esta = true;
|
||||
bales[1].centre.x = nau.centre.x;
|
||||
bales[1].centre.y = nau.centre.y;
|
||||
bales[1].n = 2;
|
||||
bales[1].velocitat = 7;
|
||||
bales[1].ipuntx[1].r = 10;
|
||||
bales[1].ipuntx[1].angle = pi/2+nau.angle;
|
||||
bales[1].ipuntx[2].r = 20;
|
||||
bales[1].ipuntx[2].angle = pi/2+nau.angle;
|
||||
bales[1].angle = nau.angle;
|
||||
}
|
||||
word dy = round(nau.velocitat*sin(nau.angle-pi/2))+nau.centre.y;
|
||||
word dx = round(nau.velocitat*cos(nau.angle-pi/2))+nau.centre.x;
|
||||
@@ -461,14 +467,16 @@ int main(int argc, char argv[]) {
|
||||
mou_bales(bales[1]);
|
||||
rota_pol(bales[1],0,1);
|
||||
}
|
||||
waitretrace();
|
||||
// fiquem "volca" i "waitretrace" al reves, ja que waitretrace fa tota la faena de enviar-ho a sdl
|
||||
volca();
|
||||
waitretrace();
|
||||
|
||||
/* if aux=1 then begin {gotoxy(0,0);write('tocado')tocado;delay(200);end;*/
|
||||
gotoxy(50,24);
|
||||
write("¸ Visente i Sergi");
|
||||
gotoxy(50,25);
|
||||
write("áETA 2.2 2/6/99");
|
||||
} while (!teclapuls(keyesc));
|
||||
} while (!teclapuls(keyEsc) && !shouldexit() ); // afegim el shouldexit, ja que si tanquen la finestra, deuriem eixir
|
||||
desinstalarkb();
|
||||
ang = 0;
|
||||
do {
|
||||
@@ -476,7 +484,7 @@ int main(int argc, char argv[]) {
|
||||
rota_pol(pol,ang,0);
|
||||
ang += 0.031415;
|
||||
rota_pol(pol,ang,1);
|
||||
} while (!keypressed());
|
||||
} while (!keypressed() && !shouldexit() );
|
||||
text();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user