Aquí iré poniendo módulos misceláneos que podéis usar en los güegos y que son fácilmente adaptables. Empiezo con dos que uso en Goku Mal (y que, por tanto, son compatibles con los churreras).
Easy Menu
Un sistema sencillo de JUGAR/PASSWORD con passwords fijas. Devuelve un número de nivel de 0 a MAX_LEVELS-1. Si el password se introduce mal también devuelve 0. Usa passwords de 6 caracteres, pero es fácilmente modificable para admitir otras longitudes. La posición del menú también se puede configurar. Todos los defines y textos están al principio:
$this->bbcode_second_pass_code('', '// Easy menu
// First shows PLAY/PASSWORD
// Let's you introduce password.
// Returns level number 0-n
// Passwords are fixed lenght
#define PASSWORD_LENGTH 6
#define MENU_Y 16
#define MENU_X 11
extern unsigned char passwords [0];
#asm
._passwords
defm "TETICA"
defm "PICHON"
defm "CULETE"
defm "BUTACA"
#endasm
unsigned char *clearout = " ";
unsigned char *password = "****** ";
unsigned char which_level (void) {
unsigned char *passpointer = passwords;
print_str (MENU_X, MENU_Y, 7, " PASSWORD ");
print_str (MENU_X, MENU_Y + 1, 7, clearout);
print_str (MENU_X, MENU_Y + 2, 7, clearout);
for (gpit = 0; gpit < PASSWORD_LENGTH; gpit ++) password [gpit] = '.';
password [PASSWORD_LENGTH] = ' ';
gpit = 0;
sp_WaitForNoKey ();
while (1) {
password [gpit] = '*';
print_str (16 - PASSWORD_LENGTH / 2, MENU_Y + 2, 71, password);
sp_UpdateNow ();
do {
gpjt = sp_GetKey ();
} while (!gpjt);
if (gpjt == 12 && gpit > 0) {
password [gpit] = gpit == PASSWORD_LENGTH ? ' ' : '.';
gpit --;
}
if (gpjt == 13) break;
if (gpjt > 'Z') gpjt -= 32;
if (gpjt >= 'A' && gpjt <= 'Z' && gpit < PASSWORD_LENGTH) {
password [gpit] = gpjt;
gpit ++;
}
wyz_play_sound (0);
sp_WaitForNoKey ();
}
sp_WaitForNoKey ();
wyz_stop_sound ();
wyz_play_sound (1);
// Check password
for (gpit = 0; gpit < MAX_LEVELS - 1; gpit ++) {
gpt = 1;
for (gpjt = 0; gpjt < PASSWORD_LENGTH; gpjt ++) {
if (password [gpjt] != (*passpointer++)) gpt = 0;
}
if (gpt) return (1 + gpit);
}
return 0;
}
unsigned char simple_menu (void) {
if (language) {
print_str (MENU_X, MENU_Y, 7, "-= MENU =-");
print_str (MENU_X, MENU_Y + 1, 7, "1 JUGAR ");
} else {
print_str (MENU_X, MENU_Y, 7, "-=SELECT=-");
print_str (MENU_X, MENU_Y + 1, 7, "1 PLAY ");
}
print_str (MENU_X, MENU_Y + 2, 7, "2 PASSWORD");
sp_UpdateNow ();
while (1) {
gpjt = sp_GetKey ();
switch (gpjt) {
case '1':
wyz_stop_sound ();
wyz_play_sound (1);
return 0;
break;
case '2':
wyz_play_sound (0);
return which_level ();
break;
}
}
}
void print_password (unsigned char x, unsigned char y, unsigned char level) {
unsigned char *passpointer = passwords + ((level - 1) * PASSWORD_LENGTH);
for (gpit = 0; gpit < PASSWORD_LENGTH; gpit ++) {
sp_PrintAtInv (y, x ++, 70, (*passpointer ++) - 32);
}
}
')
Módulos miscelaneos
Moderador: na_th_an
Módulos miscelaneos
Como diría Rorshach: "Urm..."
Re: Módulos miscelaneos
Intro
Permite añadir cutscenes con imagenes/textos de forma sencilla. También admite dos lenguajes. Dependiendo del valor de una variable global language, que puede valer 0 o 1, se mostrará un set de textos u otro. Como siempre, toda la configuración se hace con los defines que hay al principio. Los textos usan @ para el salto de linea.
$this->bbcode_second_pass_code('', '// intro.h
// Simple intro/cutscene generator.
// do_intro takes two parameters: first and last intro text portion to show.
// each text portion is a string (@ within a string is a line break) and is
// printed alongside a picture stored in the resource library.
// Text portion N will show picture BASE_PIC_RESOURCE + N.
#define INTRO_X 2 // Top-left X coordinate of text.
#define INTRO_Y 12 // " " Y " " "
#define BASE_PIC_RESOURCE 11 // Pic resources start here
#define INTRO_TEXT_COLOUR 71 // Text colour.
#define SCREEN_WAIT 250 // halts to wait after showing a screen.
#define LANG_TEXT_OFFS 7 // Add to message for second language text.
extern unsigned char intro_text_1 [0];
extern unsigned char intro_text_2 [0];
extern unsigned char intro_text_3 [0];
extern unsigned char intro_text_4 [0];
extern unsigned char intro_text_5 [0];
extern unsigned char intro_text_6 [0];
extern unsigned char intro_text_7 [0];
extern unsigned char intro_text_8 [0];
extern unsigned char intro_text_9 [0];
extern unsigned char intro_text_10 [0];
extern unsigned char intro_text_11 [0];
extern unsigned char intro_text_12 [0];
extern unsigned char intro_text_13 [0];
extern unsigned char intro_text_14 [0];
unsigned char *intro_texts [] = {
intro_text_1, intro_text_2, intro_text_3, intro_text_4,
intro_text_5,
intro_text_6, intro_text_7,
intro_text_8, intro_text_9, intro_text_10, intro_text_11,
intro_text_12,
intro_text_13, intro_text_14
};
#asm
; "----------------------------OOOOOOOOOOOOOOOOOOOOOOOOOOOO----------------------------OOOOOOOOOOOOOOOOOOOOOOOOOOOO"
._intro_text_1
defm "'WILL BUILD A PRETTY LADY!'@SAID ELEUTERIO IN HIS NOOK@AND WITH A GRIN SHADY@AWAITS FOR THE MIX TO COOK"
defb 0
._intro_text_2
defm "BUT AYE! THIS HAS GONE BAD!@'THIS AIN'T A PRETTY LADY'@'THIS IS A 'GOKU BAD'!'@SAID THE MONKEY, SHAKY"
defb 0
._intro_text_3
defm "ANGRY, HE THREW GOKU AWAY,@AND IN A MOUNTAIN OF SOCKS@HE PUT HIM TO LAY@AND FLEW TO THE DOCKS."
defb 0
._intro_text_4
defm "BUT GOKU SOON AWOKE,@AND SWORE LIKE FEY@HE WOULD CHASE THAT BLOKE@AND MAKE HIM PAY!"
defb 0
._intro_text_5
defm "MONKEY CALLS GOKU SCOURED:@'WE COULD MAKE A DEAL:@PICK UP SOME FLOWERS@FOR A LADY IN STILETTO HEELS'"
defb 0
._intro_text_6
defm "'MONKEY, YOU SHALL PAY!'@'WAIT, MEET THIS LADY HERE'@SAID THE MONKEY IN DISARRAY@'I MADE HER FOR YOU, SEE!'"
defb 0
._intro_text_7
defm "'GET OUT OF MY WAY, MAD APE'@SAID GOKU THROWING A PUNCH@AND WITH THE LADY HE ESCAPED@MARRIED AND BRED A BUNCH."
defb 0
._intro_text_8
defm "'ME HARE UNA MUJER ENCUERA'@DIJO ELEUTERIO EL MONO,@Y EN SU LABORATORIO ESPERA@QUE LA MEZCLA ESTE A TONO."
defb 0
._intro_text_9
defm "SIN EMBARGO, ALGO FUE FATAL:@NO SALIO UNA MUJER ENCUERA.@'ME HA SALIDO UN GOKU MAL!'@DIJO EL MONO CON CARRASPERA."
defb 0
._intro_text_10
defm "ENFADADO, AL GOKU DESECHO,@Y EN UN MONTON DE CALCETINES@DE CABEZA LO TIRO...@Y SE FUE A LOS MULTICINES."
defb 0
._intro_text_11
defm "PERO GOKU DESPERTO,@Y JURO QUE SE VENGARIA@DE AQUEL QUE LO ENGENDRO@Y QUE NO LO QUERIA."
defb 0
._intro_text_12
defm "EL MONO LLAMA A GOKU MAL@'TENGO ALGO QUE PROPONERTE:@REUNE UN RAMILLETE FLORAL,@UNA CHICA QUIERE CONOCERTE'"
defb 0
._intro_text_13
defm "'MONO, TENDRAS TU MERECIDO'@'TU NECESITAS NOVIA FORMAL'@CONTESTO EL MONO CONVENCIDO@'HE HECHO UNA MORTICIA MAL'"
defb 0
._intro_text_14
defm "'QUITA, YA NO ME INTERESAS'@DIJO GOKU DANDO UN MANOTAZO@SE MARCHO CON LA TIPA ESA@Y CERRO DANDO UN PORTAZO."
defb 0
#endasm
unsigned char introx, introy, stepbystep, character;
void show_intro_text (unsigned char *s) {
introx = INTRO_X;
introy = INTRO_Y;
stepbystep = 1;
while (*s) {
character = (*s ++);
if (character != '@') sp_PrintAtInv (introy, introx ++, INTRO_TEXT_COLOUR, character - 32);
if (stepbystep) {
#asm
halt
halt
halt
halt
#endasm
sp_UpdateNow ();
#asm
xor a
in a, (254)
cpl
and 31
jr z, _dafuq
#endasm
stepbystep = 0;
#asm
._dafuq
#endasm
}
if (character == '@') {introy += 2; introx = INTRO_X;}
}
if (!stepbystep) sp_UpdateNow ();
}
unsigned char intro_iterator;
void do_intro (unsigned char ini, unsigned char fin) {
unsigned char text_offs = LANG_TEXT_OFFS * language;
for (intro_iterator = ini; intro_iterator <= fin; intro_iterator ++) {
sp_UpdateNow ();
blackout_area ();
get_resource (BASE_PIC_RESOURCE + intro_iterator, 16384);
show_intro_text (intro_texts [intro_iterator + text_offs]);
espera_activa (SCREEN_WAIT);
sp_WaitForNoKey ();
}
blackout_area ();
}
')
Permite añadir cutscenes con imagenes/textos de forma sencilla. También admite dos lenguajes. Dependiendo del valor de una variable global language, que puede valer 0 o 1, se mostrará un set de textos u otro. Como siempre, toda la configuración se hace con los defines que hay al principio. Los textos usan @ para el salto de linea.
$this->bbcode_second_pass_code('', '// intro.h
// Simple intro/cutscene generator.
// do_intro takes two parameters: first and last intro text portion to show.
// each text portion is a string (@ within a string is a line break) and is
// printed alongside a picture stored in the resource library.
// Text portion N will show picture BASE_PIC_RESOURCE + N.
#define INTRO_X 2 // Top-left X coordinate of text.
#define INTRO_Y 12 // " " Y " " "
#define BASE_PIC_RESOURCE 11 // Pic resources start here
#define INTRO_TEXT_COLOUR 71 // Text colour.
#define SCREEN_WAIT 250 // halts to wait after showing a screen.
#define LANG_TEXT_OFFS 7 // Add to message for second language text.
extern unsigned char intro_text_1 [0];
extern unsigned char intro_text_2 [0];
extern unsigned char intro_text_3 [0];
extern unsigned char intro_text_4 [0];
extern unsigned char intro_text_5 [0];
extern unsigned char intro_text_6 [0];
extern unsigned char intro_text_7 [0];
extern unsigned char intro_text_8 [0];
extern unsigned char intro_text_9 [0];
extern unsigned char intro_text_10 [0];
extern unsigned char intro_text_11 [0];
extern unsigned char intro_text_12 [0];
extern unsigned char intro_text_13 [0];
extern unsigned char intro_text_14 [0];
unsigned char *intro_texts [] = {
intro_text_1, intro_text_2, intro_text_3, intro_text_4,
intro_text_5,
intro_text_6, intro_text_7,
intro_text_8, intro_text_9, intro_text_10, intro_text_11,
intro_text_12,
intro_text_13, intro_text_14
};
#asm
; "----------------------------OOOOOOOOOOOOOOOOOOOOOOOOOOOO----------------------------OOOOOOOOOOOOOOOOOOOOOOOOOOOO"
._intro_text_1
defm "'WILL BUILD A PRETTY LADY!'@SAID ELEUTERIO IN HIS NOOK@AND WITH A GRIN SHADY@AWAITS FOR THE MIX TO COOK"
defb 0
._intro_text_2
defm "BUT AYE! THIS HAS GONE BAD!@'THIS AIN'T A PRETTY LADY'@'THIS IS A 'GOKU BAD'!'@SAID THE MONKEY, SHAKY"
defb 0
._intro_text_3
defm "ANGRY, HE THREW GOKU AWAY,@AND IN A MOUNTAIN OF SOCKS@HE PUT HIM TO LAY@AND FLEW TO THE DOCKS."
defb 0
._intro_text_4
defm "BUT GOKU SOON AWOKE,@AND SWORE LIKE FEY@HE WOULD CHASE THAT BLOKE@AND MAKE HIM PAY!"
defb 0
._intro_text_5
defm "MONKEY CALLS GOKU SCOURED:@'WE COULD MAKE A DEAL:@PICK UP SOME FLOWERS@FOR A LADY IN STILETTO HEELS'"
defb 0
._intro_text_6
defm "'MONKEY, YOU SHALL PAY!'@'WAIT, MEET THIS LADY HERE'@SAID THE MONKEY IN DISARRAY@'I MADE HER FOR YOU, SEE!'"
defb 0
._intro_text_7
defm "'GET OUT OF MY WAY, MAD APE'@SAID GOKU THROWING A PUNCH@AND WITH THE LADY HE ESCAPED@MARRIED AND BRED A BUNCH."
defb 0
._intro_text_8
defm "'ME HARE UNA MUJER ENCUERA'@DIJO ELEUTERIO EL MONO,@Y EN SU LABORATORIO ESPERA@QUE LA MEZCLA ESTE A TONO."
defb 0
._intro_text_9
defm "SIN EMBARGO, ALGO FUE FATAL:@NO SALIO UNA MUJER ENCUERA.@'ME HA SALIDO UN GOKU MAL!'@DIJO EL MONO CON CARRASPERA."
defb 0
._intro_text_10
defm "ENFADADO, AL GOKU DESECHO,@Y EN UN MONTON DE CALCETINES@DE CABEZA LO TIRO...@Y SE FUE A LOS MULTICINES."
defb 0
._intro_text_11
defm "PERO GOKU DESPERTO,@Y JURO QUE SE VENGARIA@DE AQUEL QUE LO ENGENDRO@Y QUE NO LO QUERIA."
defb 0
._intro_text_12
defm "EL MONO LLAMA A GOKU MAL@'TENGO ALGO QUE PROPONERTE:@REUNE UN RAMILLETE FLORAL,@UNA CHICA QUIERE CONOCERTE'"
defb 0
._intro_text_13
defm "'MONO, TENDRAS TU MERECIDO'@'TU NECESITAS NOVIA FORMAL'@CONTESTO EL MONO CONVENCIDO@'HE HECHO UNA MORTICIA MAL'"
defb 0
._intro_text_14
defm "'QUITA, YA NO ME INTERESAS'@DIJO GOKU DANDO UN MANOTAZO@SE MARCHO CON LA TIPA ESA@Y CERRO DANDO UN PORTAZO."
defb 0
#endasm
unsigned char introx, introy, stepbystep, character;
void show_intro_text (unsigned char *s) {
introx = INTRO_X;
introy = INTRO_Y;
stepbystep = 1;
while (*s) {
character = (*s ++);
if (character != '@') sp_PrintAtInv (introy, introx ++, INTRO_TEXT_COLOUR, character - 32);
if (stepbystep) {
#asm
halt
halt
halt
halt
#endasm
sp_UpdateNow ();
#asm
xor a
in a, (254)
cpl
and 31
jr z, _dafuq
#endasm
stepbystep = 0;
#asm
._dafuq
#endasm
}
if (character == '@') {introy += 2; introx = INTRO_X;}
}
if (!stepbystep) sp_UpdateNow ();
}
unsigned char intro_iterator;
void do_intro (unsigned char ini, unsigned char fin) {
unsigned char text_offs = LANG_TEXT_OFFS * language;
for (intro_iterator = ini; intro_iterator <= fin; intro_iterator ++) {
sp_UpdateNow ();
blackout_area ();
get_resource (BASE_PIC_RESOURCE + intro_iterator, 16384);
show_intro_text (intro_texts [intro_iterator + text_offs]);
espera_activa (SCREEN_WAIT);
sp_WaitForNoKey ();
}
blackout_area ();
}
')
Como diría Rorshach: "Urm..."
¿Quién está conectado?
Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 7 invitados