Ping Pong DS
Hola, no sabia si poner este tema en NDS o aca pero bueno, me decidi por ponerlo aca  encontre por ahi una web que indica como crear juegos de NDS, se hacen con C o C++ y es bastante complicado hacerlos pero yo logre hacer un ping pong que pueden bajar aca. bueno en realidad esta medio trucho porque el enemigo siempre devuelve la pelota, no pude hacer una IA media para el enemigo, solo me salian o demasiado faciles o imposibles u_u asi que la gracia es rebotar la pelota 10 veces seguidas para ganar, si se te "cae" pierdes los puntos y el enemigo gana 1, pero el solo necesita 3 para ganar...
bueno, si quieren(y si no es considerado spam)les pongo la web, o solo busquenla en google, no tardaran mucho en encontrarla. y yo uso una libreria que hace las cosas bastante mas facil para hacer estos juegos que se llama PALib (busquenla tambien si quieren)
y para terminar les dejo el codigo del ping pong:
Código:
#include <PA9.h>
#include "gfx/all_gfx.h"
#include "gfx/all_gfx.c"
s32 x=131;
s32 xc=10;
s32 xx=131;
s32 yy=191;
s32 sp=3;
s32 xspeed=-3;
s32 yspeed=+3;
u8 puntosp=0;
u8 puntosc=0;
void iniciar_escritura(s32 screen,s32 depth,s32 r,s32 g,s32 b);
int main(int argc, char ** argv)
{
PA_Init();
PA_InitVBL();
PA_DualLoadSpritePal(0,(void*)pong_Pal);
PA_DualCreateSprite(0,(void*)pelota_Sprite,OBJ_SIZE_8X8,1,0,131,191);
PA_CreateSprite(0,1,(void*)pong_Sprite,OBJ_SIZE_32X8,1,0,131,180);
PA_CreateSprite(1,1,(void*)pong_Sprite,OBJ_SIZE_32X8,1,0,131,10);
while(!Stylus.Held)
{
iniciar_escritura(0,0,0,31,31);
PA_OutputSimpleText(0,0,0,"Ping Pong DS por Wadk. Toca la pantalla para continuar");
PA_WaitForVBL();
}
PA_OutputSimpleText(0,0,0," ");
PA_WaitForVBL();
while (1)
{
//-Pelota
xx+=xspeed;
yy+=yspeed;
if (PA_Distance(0,yy,0,420)<18+sp)
{
if(xx>x-16)
{
if(xx<x+16)
{
yspeed=-sp;
puntosp+=1;
}
}
}
if (PA_Distance(0,yy,0,0)<18+sp)
{
if(xx>xc-16)
{
if(xx<xc+16)
{
yspeed=sp;
}
}
}
if(xx>=255)
{
xspeed=-sp;
}
if(xx<0)
{
xspeed=sp;
}
if(yy>430)
{
puntosp=0;
puntosc+=1;
yy=231;
xx=131;
}
PA_DualSetSpriteXY(0,xx,yy);
//-Barra Jugador
if (Stylus.Held)
{
x=Stylus.X;
PA_SetSpriteXY(0,1,x-16,180);
}
//-Barra CPU
if(xc<xx)
{
xc+=4;
}
else
if(xc>xx)
{
xc-=4;
}
PA_SetSpriteXY(1,1,xc-16,10);
//-Texto
{
iniciar_escritura(1,0,31,31,31);
PA_OutputText(1,0,0,"Player:%d CPU:%d",puntosp,puntosc);
while(puntosp==10)
{
PA_SetSpriteXY(1,1,0,-8);
PA_SetSpriteXY(0,1,0,-8);
PA_DualSetSpriteXY(0,0,-8);
PA_OutputSimpleText(1,0,0," Ha ganado el jugador");
}
while(puntosc==3)
{
PA_SetSpriteXY(1,1,0,-8);
PA_SetSpriteXY(0,1,0,-8);
PA_DualSetSpriteXY(0,0,-8);
PA_OutputSimpleText(1,0,0," Ha ganado la CPU");
}
}
PA_CheckLid();
PA_WaitForVBL();
}
return 0;
}
void iniciar_escritura(screen,depth,r,g,b)
{
PA_InitText(screen,depth);
PA_SetTextCol(screen,r,g,b);
}
EDIT: me olvide decir que el juego que puse lo pueden jugar en emulador o en DS si lo meten en una flash card o como se llamen
Última edición por Wadk; 12-Jan-2008 a las 20:54
|