vmap works now! I also translated all the comments to english.
This commit is contained in:
parent
f57183357a
commit
a26d25e498
|
@ -32,7 +32,7 @@ drawn at (padx, pady), and vplayer and vitem use some variables that are updated
|
|||
when calling vmap.
|
||||
*/
|
||||
|
||||
void vmap(int padx, int pady, int w, int h, int sx, int sy, MMap *map);
|
||||
void vmap(int sx, int sy, MMap *map);
|
||||
|
||||
/* void vplayer(MMap *map, unsigned char **player_sprites, int anim_frame);
|
||||
|
||||
|
|
|
@ -2,60 +2,62 @@
|
|||
#include "../../../include/microfx/ext/img.h"
|
||||
#include "../../../include/microfx/microfx.h"
|
||||
|
||||
void vmap(int padx, int pady, int w, int h, int sx, int sy, MMap *map) {
|
||||
void vmap(int sx, int sy, MMap *map) {
|
||||
/* Dessine la map à l'écran. */
|
||||
/* x et y contiendront la position à laquelle je suis dans la boucle. */
|
||||
int padx = map->padx, pady = map->pady;
|
||||
int w = map->sw, h = map->sh;
|
||||
/* x and y will contain the position in the loop. */
|
||||
int x, y;
|
||||
/* Le nombre de tuiles sur x avant le bout de carte qu'on voit est dans tx,
|
||||
pareil pour y. */
|
||||
int tx = sx/map->tw, ty = sy/map->th;
|
||||
/* mx contient le nombre de pixels qui seront cachés sur x, pareil pour
|
||||
y. */
|
||||
int mx = sx-tx*map->tw, my = sy-ty*map->th;
|
||||
/* dw et dh contiennent le nombre de tuiles à dessiner sur x et y. */
|
||||
/* The positions where we start drawing the tiles will be in tx and ty. */
|
||||
int tx, ty;
|
||||
/* mx and my will contain how many pixels will be hidden on x and on y. */
|
||||
int mx, my;
|
||||
/* dw and dh contain the amount of tiles that will be drawn on x and on y. */
|
||||
int dw = w/map->tw+1, dh = h/map->th+1;
|
||||
/* mw et mh contiennent la largeur et la hauteur de la map. */
|
||||
/* mw and mh will contain the height and the width of the map. */
|
||||
int mw = map->w*map->tw, mh = map->h*map->th;
|
||||
/* tile contient la tuile à dessiner */
|
||||
/* tile contains the tile to draw. */
|
||||
unsigned char tile;
|
||||
/* J'ajuste sx. */
|
||||
/* Fix sx. */
|
||||
if(sx<w/2){
|
||||
/* Si je ne peux pas centrer le joueur car je suis trop proche du bord
|
||||
gauche de la map. */
|
||||
/* If I can't center the player because I'm near the left border of the
|
||||
map. */
|
||||
map->px = sx;
|
||||
sx = 0;
|
||||
}else if(sx+w/2>mw){
|
||||
/* Si je ne peux pas centrer le joueur car je suis trop proche du bord
|
||||
droit de la map. */
|
||||
/* If I can't center the player because I'm near the right border of the
|
||||
map. */
|
||||
map->px = sx-(mw-w/2);
|
||||
sx = mw-w/2;
|
||||
}else{
|
||||
/* Sinon je peux centrer le joueur. */
|
||||
/* I can center the player. */
|
||||
sx = sx-w/2;
|
||||
map->px = w/2;
|
||||
}
|
||||
/* J'ajuste sy. */
|
||||
/* Fix sy. */
|
||||
if(sy<h/2){
|
||||
/* Si je ne peux pas centrer le joueur car je suis trop proche du haut
|
||||
de la map. */
|
||||
/* If I can't center the player because I'm near the top border of the
|
||||
map. */
|
||||
map->py = sy;
|
||||
sy = 0;
|
||||
}else if(sy+h/2>mh){
|
||||
/* Si je ne peux pas centrer le joueur car je suis trop proche du bas de
|
||||
la map. */
|
||||
/* If I can't center the player because I'm near the bottom border of
|
||||
the map. */
|
||||
map->py = sy-(mh-h/2);
|
||||
sy = mh-h/2;
|
||||
}else{
|
||||
/* Sinon je peux centrer le joueur. */
|
||||
/* I can center the player. */
|
||||
sy = sy-h/2;
|
||||
map->py = h/2;
|
||||
}
|
||||
tx = sx/map->tw;
|
||||
ty = sy/map->th;
|
||||
mx = sx-tx*map->tw;
|
||||
my = sy-ty*map->th;
|
||||
for(y=0;y<dh;y++){
|
||||
for(x=0;x<dw;x++){
|
||||
/* Je récupère la tuile dans map et je la dessine si tx+x est plus
|
||||
petit que la largeur de la map. */
|
||||
/* I get the tile number if his position is inside the map unsigned
|
||||
char*. Then I draw it. */
|
||||
if(tx+x>=0 && tx+x < map->w && ty+y>=0 && ty+y < map->h){
|
||||
tile = map->map[(ty+y)*map->w+tx+x];
|
||||
if(tile > 0){
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,8 @@
|
|||
#ifndef HELP_H
|
||||
#define HELP_H
|
||||
|
||||
/* TODO: Explain how to write a config.txt file. */
|
||||
|
||||
const char help[] = "mapconv - Microfx map creator\n\n"
|
||||
"This little tool makes it easier to create maps for the Microfx gametools ext."
|
||||
"\n"
|
||||
|
|
|
@ -129,6 +129,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
fseek(fp_map, -2L, SEEK_CUR);
|
||||
fputs("};", fp_map);
|
||||
a=get_value_from_name(T_STRING, "mapname", tokens, out);
|
||||
i=get_value_from_name(T_STRING, "tileset_name", tokens, out);
|
||||
tw=get_value_from_name(T_INT, "tilewidth", tokens, out);
|
||||
th=get_value_from_name(T_INT, "tileheight", tokens, out);
|
||||
|
|
Loading…
Reference in New Issue