Buenas AmakaSt :)
He querido volcar un ejemplo de matamarcianos simple antiguo, pero no he conseguido que me funcionara. Me devuelve los siguientes fallos al compilar:
10 fuente=load_fnt("fuente1.fnt"); -- VARIABLE NO DEFINIDA!
11 put_screen(0,load_png("fondo.png")); -- ESPERANDO [)]
33 graph=load_png("fondo_carcel.png"); -- VARIABLE NO DEFINIDA!
39 graph=load_png("fondo_win.png"); -- VARIABLE NO DEFINIDA!
51 graph=load_png("fabra.png"); -- VARIABLE NO DEFINIDA!
58 if(key(_esc)) exit(0); end -- NÚMERO DE PARÁMETROS INCORRECTO
70 graph=load_png("fabra_carcel.png"); -- VARIABLE NO DEFINIDA!
83 graph=load_png("dinero.png"); -- VARIABLE NO DEFINIDA!
103 graph=load_png("juez.png"); -- VARIABLE NO DEFINIDA!
127 graph=load_png("barra.png"); -- VARIABLE NO DEFINIDA!
141 graph=load_png("cara.png"); -- VARIABLE NO DEFINIDA!
203 graph=load_png("maletin.png"); -- VARIABLE NO DEFINIDA!
219 graph=load_png("vida.png"); -- VARIABLE NO DEFINIDA!
Este es el código:
Program programa;
global
puntos=50000;
vidas=4;
dineros=3;
fuente;
dificultad;
Begin
set_mode(800,600);
fuente=load_fnt("fuente1.fnt");
put_screen(0,load_png("fondo.png"));
write(fuente,0,0,0,"Euros:");
write_int(fuente,100,0,0,offset puntos);
bueno();
barravida();
vida();
loop
malo();
if(rand(0,10)==0) maletin(); end
if(vidas<4)
if(rand(0,20)==0) vida(); end
end
if(dificultad>180) dificultad=190; end
if(vidas==0 or dificultad>179) break; end
frame(4000-dificultad*20);
end
frame(2000);
x=400;
y=300;
z=-3;
delete_Text(all_text);
if(vidas==0)
graph=load_png("fondo_carcel.png");
from alpha=0 to 255 step 5; frame; end
let_me_alone();
while(!key(_enter)) frame; end
end
if(dificultad>179)
graph=load_png("fondo_win.png");
from alpha=0 to 255 step 5; frame; end
let_me_alone();
while(!key(_enter)) frame; end
end
End
Process bueno();
private
pulsando_disparo;
invencible=72;
Begin
graph=load_png("fabra.png");
x=400;
y=500;
from alpha=0 to 128 step 5; frame; end
loop
if(invencible>0) invencible--; alpha=128; else alpha=255; end
if(not mouse.left) pulsando_disparo=0; end
if(key(_esc)) exit(0); end
x=mouse.x;
if(mouse.left and pulsando_disparo==0)
disparo();
pulsando_disparo=1;
end
if(collision(type malo) and invencible==0)
vidas--;
break;
end
frame;
end
graph=load_png("fabra_carcel.png");
from alpha=255 to 0 step -5; frame; end
frame(2000);
if(vidas!=0) bueno(); end
End
process disparo();
Begin
if(dineros==0) return; end
if(puntos==0) return; end
puntos-=1000;
dineros--;
graph=load_png("dinero.png");
x=father.x;
y=father.y-55;
z=1;
loop
y-=10;
angle+=5000;
frame;
if(y<0)
break;
end
end
dineros++;
end
process malo();
private
inc_x;
inc_y;
Begin
graph=load_png("juez.png");
y=-50;
x=rand(0,800);
size=rand(40,80);
inc_y=rand(5,7);
inc_x=rand(-4,4);
loop
if(collision(type disparo))
alpha=128;
while(y>-50) y-=10; frame; end
dificultad++;
break;
end
if(y>680)
break;
end
x+=inc_x;
y+=inc_y;
frame;
end
End
process barravida();
begin
graph=load_png("barra.png");
x=400;
y=50;
barravida2();
z=-1;
loop
frame;
end
end
process barravida2();
private
vidantes=4;
begin
graph=load_png("cara.png");
x=400;
y=50;
z=-2;
loop
if(vidantes!=vidas)
if(vidantes<vidas) // as konsegio 1a birra
switch(vidas)
case 2:
from x=400+150 to 400 step -5; frame; end
end
case 3:
from x=400 to 400-150 step -5; frame; end
end
case 4:
from x=400-150 to 400-300 step -5; frame; end
end
end
else
switch(vidas)
case 0:
from x=400+150 to 400+300 step 5; frame; end
end
case 1:
from x=400 to 400+150 step 5; frame; end
end
case 2:
from x=400-150 to 400 step 5; frame; end
end
case 3:
from x=400-300 to 400-150 step 5; frame; end
end
end
end
end
switch(vidas)
case 0:
x=400+300;
end
case 1:
x=400+150;
end
case 2:
x=400;
end
case 3:
x=400-150;
end
case 4:
x=400-300;
end
end
vidantes=vidas;
frame;
end
end
process maletin();
begin
graph=load_png("maletin.png");
x=rand(0,800);
y=-60;
loop
y+=7;
if(collision(type bueno))
puntos+=5000;
return;
end
frame;
end
end
process vida();
begin
graph=load_png("vida.png");
x=rand(0,800);
y=-60;
loop
y+=7;
if(vidas>3) break; end
if(collision(type disparo))
alpha=128;
from size=100 to 0 step -5; angle+=10000; frame; end
break;
end
if(collision(type bueno))
vidas+=1;
return;
end
frame;
end
end
¿Qué crees que puede estar fallando? Gracias!
Buenas panreyes,
Cambia los nombres de las funciones de carga de imagen: load_png() por load_image()
Y de fuentes: load_fnt() por load_font()
Y ya solo faltaría exit(0) por exit("", 0)
load_image() soporta png, bmp, gif, svg, jpg y map
load_font() soporta ttf, otf y fnt
Y así deberían de desaparecer, al menos, esos errores. :)
Aquí el cambio:Program programa;
global
puntos=50000;
vidas=4;
dineros=3;
fuente;
dificultad;
Begin
set_mode(800,600);
fuente=load_font("fuente1.fnt");
put_screen(0,load_image("fondo.png"));
write(fuente,0,0,0,"Euros:");
write_int(fuente,100,0,0,offset puntos);
bueno();
barravida();
vida();
loop
malo();
if(rand(0,10)==0) maletin(); end
if(vidas<4)
if(rand(0,20)==0) vida(); end
end
if(dificultad>180) dificultad=190; end
if(vidas==0 or dificultad>179) break; end
frame(4000-dificultad*20);
end
frame(2000);
x=400;
y=300;
z=-3;
delete_Text(all_text);
if(vidas==0)
graph=load_image("fondo_carcel.png");
from alpha=0 to 255 step 5; frame; end
let_me_alone();
while(!key(_enter)) frame; end
end
if(dificultad>179)
graph=load_image("fondo_win.png");
from alpha=0 to 255 step 5; frame; end
let_me_alone();
while(!key(_enter)) frame; end
end
End
Process bueno();
private
pulsando_disparo;
invencible=72;
Begin
graph=load_image("fabra.png");
x=400;
y=500;
from alpha=0 to 128 step 5; frame; end
loop
if(invencible>0) invencible--; alpha=128; else alpha=255; end
if(not mouse.left) pulsando_disparo=0; end
if(key(_esc)) exit("", 0); end
x=mouse.x;
if(mouse.left and pulsando_disparo==0)
disparo();
pulsando_disparo=1;
end
if(collision(type malo) and invencible==0)
vidas--;
break;
end
frame;
end
graph=load_image("fabra_carcel.png");
from alpha=255 to 0 step -5; frame; end
frame(2000);
if(vidas!=0) bueno(); end
End
process disparo();
Begin
if(dineros==0) return; end
if(puntos==0) return; end
puntos-=1000;
dineros--;
graph=load_image("dinero.png");
x=father.x;
y=father.y-55;
z=1;
loop
y-=10;
angle+=5000;
frame;
if(y<0)
break;
end
end
dineros++;
end
process malo();
private
inc_x;
inc_y;
Begin
graph=load_image("juez.png");
y=-50;
x=rand(0,800);
size=rand(40,80);
inc_y=rand(5,7);
inc_x=rand(-4,4);
loop
if(collision(type disparo))
alpha=128;
while(y>-50) y-=10; frame; end
dificultad++;
break;
end
if(y>680)
break;
end
x+=inc_x;
y+=inc_y;
frame;
end
End
process barravida();
begin
graph=load_image("barra.png");
x=400;
y=50;
barravida2();
z=-1;
loop
frame;
end
end
process barravida2();
private
vidantes=4;
begin
graph=load_image("cara.png");
x=400;
y=50;
z=-2;
loop
if(vidantes!=vidas)
if(vidantes<vidas) // as konsegio 1a birra
switch(vidas)
case 2:
from x=400+150 to 400 step -5; frame; end
end
case 3:
from x=400 to 400-150 step -5; frame; end
end
case 4:
from x=400-150 to 400-300 step -5; frame; end
end
end
else
switch(vidas)
case 0:
from x=400+150 to 400+300 step 5; frame; end
end
case 1:
from x=400 to 400+150 step 5; frame; end
end
case 2:
from x=400-150 to 400 step 5; frame; end
end
case 3:
from x=400-300 to 400-150 step 5; frame; end
end
end
end
end
switch(vidas)
case 0:
x=400+300;
end
case 1:
x=400+150;
end
case 2:
x=400;
end
case 3:
x=400-150;
end
case 4:
x=400-300;
end
end
vidantes=vidas;
frame;
end
end
process maletin();
begin
graph=load_image("maletin.png");
x=rand(0,800);
y=-60;
loop
y+=7;
if(collision(type bueno))
puntos+=5000;
return;
end
frame;
end
end
process vida();
begin
graph=load_image("vida.png");
x=rand(0,800);
y=-60;
loop
y+=7;
if(vidas>3) break; end
if(collision(type disparo))
alpha=128;
from size=100 to 0 step -5; angle+=10000; frame; end
break;
end
if(collision(type bueno))
vidas+=1;
return;
end
frame;
end
end
Un saludo.
Me gusta esa actualización de los nombres de las funciones :)
En PixTudio tenemos image_load para PNG, JPG, MAP y WEBP.
Luego para los FNT tenemos fnt_load, pero los TTF los cargamos con ttf_load.
Creo que te copiaré ese load_font, aunque a nuestra manera (font_load)
Es mucho mejor así, es más limpio que tener una lista de funciones para cada formato. :)
También para audio y video: load_sound() y load_video();
En PixTudio:
video_load (sólo Theora por ahora)
sound_load (wav, mp3 y ogg)
Me gusta eso de que el lenguaje siga pareciéndose lo más posible, aún teniendo el orden de las palabras invertido :)