add ennemi support

dev
Milang 3 years ago
parent af29ac6970
commit ddef97b66b
  1. BIN
      SuperCbr.g1a
  2. BIN
      assets-fx/bin/lvl_1_2.png
  3. 30
      levelconverter/levelconv.py
  4. 39
      src/level.c

Binary file not shown.

Binary file not shown.

@ -38,7 +38,7 @@ def write_char(val):
# Load image
filename = input("File name ?\n> ")
img = Image.open(filename)
print("Converting " + filename + " to assets-fx/" + filename + " //size =", img.size)
print("Converting..." + filename + ", size =", img.size)
#rough binary
# code = str().encode('latin1')
@ -46,12 +46,6 @@ code = write_char(int(img.size[0]))
code += write_char(int(img.size[1]))
nombre_ennemis=0
ennemis = "\nennemi_t ennemies0[]={"
# Balayage des pixels : passe pour dessiner les murs
pixels = img.load()
for x in range(0,img.size[0]):
for i in range(0, img.size[1]):
@ -86,20 +80,22 @@ for x in range(0,img.size[0]):
elif color_compare(pixels[x,y], tuyau_milieu):
code += write_char(9)
elif color_compare(pixels[x,y], drapeau):
code += write_char(10) # temporary code+= "{END_LEVEL,0x1102},"
else:
code += write_char(0)
#code += str(pixels[x,y])
code += write_char(10)
elif color_compare(pixels[x,y], goomba):
code += write_char(11)
if color_compare(pixels[x,y], goomba):
nombre_ennemis += 1
ennemis += "\n GOOMBA(" + str(8*x) + ", " + str(8*i) + ", -1),"
elif color_compare(pixels[x,y], koopa_vert):
ennemis += "\n KOOPA_V(" + str(8*x) + ", " + str(8*i) + ", -1),"
code += write_char(12)
elif color_compare(pixels[x,y], koopa_rouge):
ennemis += "\n KOOPA_R(" + str(8*x) + ", " + str(8*i) + ", -1),"
ennemis += "\n};\nennemis_global_size=" + str(nombre_ennemis) + ";\ninit_ennemies(ennemies0);\n"
code += write_char(13)
else:
code += write_char(0)
f = open("../assets-fx/bin/lvl_"+filename, 'wb')
f.write(code)

@ -23,12 +23,15 @@
#define PACKED_BOX_COIN 5
#define PACKED_BOX_CHAMPI 6
#define PACKED_BETON 7
#define PACKED_TUYAU_BOUT 8
#define PACKED_TUYAU_MIDDLE 9
#define PACKED_FLAG 10
#define PACKED_GOOMBA 11
#define PACKED_KOOPA_VERT 12
#define PACKED_KOOPA_ROUGE 13
void malloc_error()
{
extern image_t img_ram;
@ -89,6 +92,11 @@ static void unpack_level(packed_level_t * p)
int sx=0, sy=p->height; // Mario start coords
ll_sendp(LEVEL_INFO, "\n[i]Converting...", w,h);
ennemi_t ennemis[20]={0};
int nombre_ennemis=0;
for (unsigned int x=0; x<w; x++)
{
for (unsigned int y=0; y<h; y++)
@ -260,16 +268,39 @@ static void unpack_level(packed_level_t * p)
cell = t;
}
ll_sendp(LEVEL_INFO, "\n[i]Converted cell %d,%d\n {%d,%p}\n[i]Writing cell...", x,y, cell.type, cell.data);
cell_set(c,w,h,x,y,cell);
ll_sendp(LEVEL_INFO, "\n[i]Wrote cell", x,y, cell.type, cell.data);
if (contents==PACKED_GOOMBA)
{
ennemi_t e=GOOMBA(8*x,8*y,-1);
ennemis[nombre_ennemis]=e;
nombre_ennemis++;
}
else if (contents==PACKED_KOOPA_VERT)
{
ennemi_t e=KOOPA_V(8*x,8*y,-1);
ennemis[nombre_ennemis]=e;
nombre_ennemis++;
}
else if (contents==PACKED_KOOPA_ROUGE)
{
ennemi_t e=KOOPA_R(8*x,8*y,-1);
ennemis[nombre_ennemis]=e;
nombre_ennemis++;
}
}
}
ll_sendp(LEVEL_INFO, "\n[i]Converted!\n[i]Sending to level zone...", w,h);
world_set(w, h, sx, sy, c);
ll_sendp(LEVEL_INFO, "\n[i]Achieved unpacking", w,h);
free(c);
init_ennemi(ennemis, nombre_ennemis);
}
void set_level(int w, int l)
@ -300,7 +331,7 @@ void set_level(int w, int l)
plateforme_t plateforme0[]=
{
PLATEFORME_MOVING_H(8*144,6*8+7,32,1,8*142,8*150)
PLATEFORME_MOVING_H(8*144,6*8+5,32,1,8*142,8*150)
};
init_plateformes(plateforme0,sizeof(plateforme0)/sizeof(plateforme_t));
}

Loading…
Cancel
Save