top of page

Retro frontón para NDS usando PALib

  • Foto del escritor: Samir Ramirez
    Samir Ramirez
  • 10 may 2009
  • 2 Min. de lectura

Usando PALib para programar la Nintendo DS, he realizado este “frontón retro” usando caracteres ASCII. El código fuente del programa es el siguiente:

// Includes #include // Include for PA_Lib #include “explosion.h” // incluimos el fichero explosion.raw para el sonido #include “zat.h” #include “alarma.h” #include “dragon.h”

// Function: main() int main(int argc, char ** argv) { PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL PA_InitText(1, 2); // Tell it to put text on screen 1, background number 2 PA_InitText(0, 2); //PA_InitSound(); //Inicializa el sonido

AS_Init(AS_MODE_SURROUND | AS_MODE_16CH ); AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND);

int i; s16 posx=1; s16 posy=11; u32 pierdetiempo=60000; s16 puntos=0; u32 bolax = PA_RandMinMax(15,28); u32 bolay = PA_RandMinMax(7,18); s16 velx=1; s16 vely=1;

void comienzo() {

PA_OutputSimpleText(1, posx, posy, ” “); PA_OutputSimpleText(1, posx, posy-1, ” “); PA_OutputSimpleText(1, posx, posy+1, ” “); PA_OutputSimpleText(1, bolax, bolay, ” “);

posx=1; posy=11; pierdetiempo=60000; puntos=0; bolax = PA_RandMinMax(15,28); bolay = PA_RandMinMax(7,18); PA_OutputSimpleText(1, bolax, bolay, “O”);

PA_OutputSimpleText(1, posx, posy, “#”); PA_OutputSimpleText(1, posx, posy-1, “#”); PA_OutputSimpleText(1, posx, posy+1, “#”); PA_OutputSimpleText(0,10,12,” “); PA_OutputSimpleText(0,1,13,” “); PA_OutputText(1, 0, 0, “Puntos: %d “, puntos);

PA_PlaySimpleSound(dragon); }

void fin() { PA_PlaySimpleSound(alarma); PA_OutputSimpleText(1, bolax, bolay, ” “); PA_OutputSimpleText(1, posx, posy, “+”); PA_OutputSimpleText(1, posx, posy-1, “+”); PA_OutputSimpleText(1, posx, posy+1, “+”); bolax=bolax+velx; bolay=bolay+vely; PA_OutputSimpleText(1, bolax, bolay, “*”); while (Stylus.Held == 0) { PA_OutputSimpleText(0,10,12,”*** FIN ***”); PA_OutputSimpleText(0,1,13,”Pulsa la pantalla para empezar”);

}

comienzo();

}

PA_OutputText(1, 0, 0, “Puntos: %d “, puntos);

PA_OutputSimpleText(1, 0, 2, “+——–RAULTECNOLOGIA——–+”); PA_OutputSimpleText(1, 0, 23, “+——–RAULTECNOLOGIA——–+”);

for (i = 3; i 4) { if(Pad.Held.Up)

{ PA_OutputSimpleText(1, posx, posy, ” “); PA_OutputSimpleText(1, posx, posy-1, ” “); PA_OutputSimpleText(1, posx, posy+1, ” “); posy-=1;

PA_OutputSimpleText(1, posx, posy, “#”); PA_OutputSimpleText(1, posx, posy-1, “#”); PA_OutputSimpleText(1, posx, posy+1, “#”);

} }

if (posy < 21) { if(Pad.Held.Down)

{ PA_OutputSimpleText(1, posx, posy, ” “); PA_OutputSimpleText(1, posx, posy-1, ” “); PA_OutputSimpleText(1, posx, posy+1, ” “); posy+=1; PA_OutputSimpleText(1, posx, posy, “#”); PA_OutputSimpleText(1, posx, posy-1, “#”); PA_OutputSimpleText(1, posx, posy+1, “#”); } }

if(bolax == 30) { velx=-velx; }

if (bolay == 3) { vely=-vely; } if (bolay == 22) { vely=-vely; }

if (bolax == 2) { if (((posy-bolay)*(posy-bolay)) < 4) { puntos=puntos+1; velx=-velx; PA_PlaySimpleSound(explosion); PA_OutputText(1, 0, 0, “Puntos: %d “, puntos); pierdetiempo=pierdetiempo/1.1; } else fin(); }

PA_OutputSimpleText(1, bolax, bolay, ” “); bolax=bolax+velx; bolay=bolay+vely; for (i = 1; i < pierdetiempo; i++){ PA_OutputSimpleText(1, bolax, bolay, “O”); }

}

return 0; } // End of main()

Entradas recientes

Ver todo
Videojuegos con Tululoo GameMaker

Una explicación algo más detallada está en el blog que tenemos sobre GameMaker, del que Tululoo hereda varios elementos. #tululoo

 
 
 

Comments


3025674909|

©2020 por SM-MANUFACTURING. Creada con Wix.com

bottom of page