Burbruee
Member
Hello,
Last night I started work on (sort of) a remake of the old Amiga P.D game Platman in Fenix.
I'm still new to Fenix and programming, and I used a platform example written in spanish by shaggylish to start building from. Although my Spanish isn't great, I think I understand all the comments and variable names.
So anyway, the solution I came up with for changing from one room to the other was by using the hardness map and painting a different color over the so called exit, then another color on the other side to be able to travel back and forth between two rooms.
It works, but might not be the best way since I use one color for each door and can be hard to keep track on. Also you COULD run out of colors, but I doubt it would happen since I'm doing 16-bits.
Anyway, moving from one room to the other either by moving left or right works fine. But there are cases where you need to enter a room by falling into it (I'm remaking all of the original levels) and that's where I'm having problems. Although I paint a line in a color like I would when changing rooms horizontally, it won't detect it when moving vertically. Most likely the condition where I put the if part is wrong, which is why I request a little help to figure this one out.
Here's the part that works (changing rooms horizontally)
CODE
IF (vel_x > 0)
FOR(incremento=0;incremento<vel_x;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x+10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END;
IF (color == rgb(0,0,255))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 15;
y = 116;
END;
IF (color == rgb(0,0,240))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 11, 0, 0, 0);
mapa_dureza = 12;
x = 15;
y = 448;
END;
x++;
END;
ELSE
FOR(incremento=0;incremento>vel_x;incremento--)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x-10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END
IF (color == rgb(0,255,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 7, 0, 0, 0);
mapa_dureza = 8;
x = 622;
y = 118;
END;
IF (color == rgb(0,240,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 623;
y = 432;
END;
x--;
END
END
The fpg_niveles is the fpg where I have all the graphics for the levels/rooms. Two of each, one normal, one hardness map.
So generally, the method I use for the illusion of going from one room to another is to do a new start_scroll and give it a new value for the background graphic to use (the new room) then I change mapa_dureza as well (this is the hardness map, and also a value from the fpg file), lastly I alter the x and y values.
Now, for the vertical movement:
CODE
//Tecla y gravedad se inicializa
IF(key(_x) AND estado_y <> SALTANDO)
gravedad = -limite_gravedad;
estado_y = SALTANDO;
play_wav(snd_salto, 0);
END
//Gravedad va cambiando en cada frame
IF (gravedad < limite_gravedad)
gravedad++;
END
/*Se averigua si está tocando el suelo cuando esté bajando
sino, nunca dejaría de tocar el suelo*/
color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0) AND gravedad>0)
gravedad = 0;
estado_y = PARADO;
ELSE
estado_y = SALTANDO;
END
IF(gravedad>0)
FOR(incremento=1;incremento<gravedad;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0))
BREAK;
END;
y++;
END
ELSE
y+=gravedad;
END
I haven't translated the spanish variables, yet. But most of them are easy to figure out, such as gravedad = gravity, limited by limite_gravedad. This is defined earlier in the player process and controls how high the character can jump. The constants PARADO, SALTANDO and also ANDANDO has to do with the character animation and whether he is standing or jumping etc.
Either way, with the horizontal stuff I could just add my simple code to the right (incremento++ FOR part) or left (incremento-- FOR part)
This doesn't work so easy for the vertical movement, I've tried to put my code in different places but he just keeps falling forever and does not change to the new room.
I was hoping I could get some help figuring this one out as I don't know what needs to be done.
Thanks.
Last night I started work on (sort of) a remake of the old Amiga P.D game Platman in Fenix.
I'm still new to Fenix and programming, and I used a platform example written in spanish by shaggylish to start building from. Although my Spanish isn't great, I think I understand all the comments and variable names.
So anyway, the solution I came up with for changing from one room to the other was by using the hardness map and painting a different color over the so called exit, then another color on the other side to be able to travel back and forth between two rooms.
It works, but might not be the best way since I use one color for each door and can be hard to keep track on. Also you COULD run out of colors, but I doubt it would happen since I'm doing 16-bits.
Anyway, moving from one room to the other either by moving left or right works fine. But there are cases where you need to enter a room by falling into it (I'm remaking all of the original levels) and that's where I'm having problems. Although I paint a line in a color like I would when changing rooms horizontally, it won't detect it when moving vertically. Most likely the condition where I put the if part is wrong, which is why I request a little help to figure this one out.
Here's the part that works (changing rooms horizontally)
CODE
IF (vel_x > 0)
FOR(incremento=0;incremento<vel_x;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x+10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END;
IF (color == rgb(0,0,255))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 15;
y = 116;
END;
IF (color == rgb(0,0,240))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 11, 0, 0, 0);
mapa_dureza = 12;
x = 15;
y = 448;
END;
x++;
END;
ELSE
FOR(incremento=0;incremento>vel_x;incremento--)
color = map_get_pixel(fpg_niveles,mapa_dureza,(x-10),(y-1));
IF (color == rgb(255,0,0))
BREAK;
estado_x = PARADO;
vel_x = 0;
END
IF (color == rgb(0,255,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 7, 0, 0, 0);
mapa_dureza = 8;
x = 622;
y = 118;
END;
IF (color == rgb(0,240,0))
//BREAK;
start_scroll(id_scroll, fpg_niveles, 9, 0, 0, 0);
mapa_dureza = 10;
x = 623;
y = 432;
END;
x--;
END
END
The fpg_niveles is the fpg where I have all the graphics for the levels/rooms. Two of each, one normal, one hardness map.
So generally, the method I use for the illusion of going from one room to another is to do a new start_scroll and give it a new value for the background graphic to use (the new room) then I change mapa_dureza as well (this is the hardness map, and also a value from the fpg file), lastly I alter the x and y values.
Now, for the vertical movement:
CODE
//Tecla y gravedad se inicializa
IF(key(_x) AND estado_y <> SALTANDO)
gravedad = -limite_gravedad;
estado_y = SALTANDO;
play_wav(snd_salto, 0);
END
//Gravedad va cambiando en cada frame
IF (gravedad < limite_gravedad)
gravedad++;
END
/*Se averigua si está tocando el suelo cuando esté bajando
sino, nunca dejaría de tocar el suelo*/
color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0) AND gravedad>0)
gravedad = 0;
estado_y = PARADO;
ELSE
estado_y = SALTANDO;
END
IF(gravedad>0)
FOR(incremento=1;incremento<gravedad;incremento++)
color = map_get_pixel(fpg_niveles,mapa_dureza,x,y);
IF (color == rgb(255,0,0))
BREAK;
END;
y++;
END
ELSE
y+=gravedad;
END
I haven't translated the spanish variables, yet. But most of them are easy to figure out, such as gravedad = gravity, limited by limite_gravedad. This is defined earlier in the player process and controls how high the character can jump. The constants PARADO, SALTANDO and also ANDANDO has to do with the character animation and whether he is standing or jumping etc.
Either way, with the horizontal stuff I could just add my simple code to the right (incremento++ FOR part) or left (incremento-- FOR part)
This doesn't work so easy for the vertical movement, I've tried to put my code in different places but he just keeps falling forever and does not change to the new room.
I was hoping I could get some help figuring this one out as I don't know what needs to be done.
Thanks.