better makefile with platforms

This commit is contained in:
Vincent-FK
2021-06-04 16:45:48 +02:00
parent 150cf58be2
commit 9f5cd6c745
9 changed files with 72 additions and 361 deletions

View File

@@ -30,12 +30,12 @@ t_game game_new(int nb_joueur, int niveau, int mode, int kill_bomb) {
FILE *level;
if (mode==1){
if (nb_joueur==1)
level=fopen("data/level1.lvl","r");
level=fopen(SRC_LEVELS_1_PLAYER,"r");
else
level=fopen("data/level13.lvl","r");
level=fopen(SRC_LEVELS_2_PLAYERS,"r");
}
else{
level=fopen("data/niveaux.lvl","r");
level=fopen(SRC_LEVELS_EDITOR,"r");
}
the_game.map = map_load_dynamic(level,niveau,nb_joueur);
the_game.player1 = player_init(2,1,1,1);

View File

@@ -47,11 +47,15 @@ int input_update(t_game game, int nb_joueur) {
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
#ifdef FUNKEY
case SDLK_q:
#endif //FUNKEY
return 2;
case SDLK_UP:
#ifdef FUNKEY
case SDLK_u:
#endif //FUNKEY
player_set_current_way(player1, UP);
player_move(player1, map);
if (player_win(player1)==1){
@@ -60,7 +64,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_DOWN:
#ifdef FUNKEY
case SDLK_d:
#endif //FUNKEY
player_set_current_way(player1, DOWN);
player_move(player1, map);
if (player_win(player1)==1){
@@ -69,7 +75,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_RIGHT:
#ifdef FUNKEY
case SDLK_r:
#endif //FUNKEY
player_set_current_way(player1, RIGHT);
player_move(player1, map);
if (player_win(player1)==1){
@@ -78,7 +86,9 @@ int input_update(t_game game, int nb_joueur) {
break;
case SDLK_LEFT:
#ifdef FUNKEY
case SDLK_l:
#endif //FUNKEY
player_set_current_way(player1, LEFT);
player_move(player1, map);
if (player_win(player1)==1){
@@ -89,8 +99,10 @@ int input_update(t_game game, int nb_joueur) {
//sert <20> poser une bombe pour le joueur 1
case SDLK_END: //cette touche sert pour les ordinateurs portables qui n'ont pas forc<72>ment la touce 0 <20> c<>t<EFBFBD> des fl<66>ches directionnelles)
case SDLK_KP0:
#ifdef FUNKEY
case SDLK_a:
case SDLK_b:
#endif //FUNKEY
x= player_get_x(player1);
y= player_get_y(player1);
@@ -102,7 +114,7 @@ int input_update(t_game game, int nb_joueur) {
}
break;
/*
#ifndef FUNKEY
// touches du joueur 2:
case SDLK_e:
if (nb_joueur == 2){
@@ -154,7 +166,7 @@ int input_update(t_game game, int nb_joueur) {
}
}
break;
*/
#endif // not defined (FUNKEY)
default: break;
}

View File

@@ -27,44 +27,46 @@ SDL_Surface *load_image(const char *filename) {
return img;
}
/// Nearest neighboor optimized with possible out of screen coordinates (for cropping)
void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *virtual_screen, SDL_Surface *hardware_screen, int new_w, int new_h){
int w1=virtual_screen->w;
//int h1=virtual_screen->h;
int w2=new_w;
int h2=new_h;
int x_ratio = (int)((virtual_screen->w<<16)/w2);
int y_ratio = (int)((virtual_screen->h<<16)/h2);
int x2, y2 ;
#if defined(HW_SCREEN_RESIZE) && defined(HW_SCREEN_HEIGHT) && defined(HW_SCREEN_WIDTH)
/// Nearest neighboor optimized with possible out of screen coordinates (for cropping)
void flip_NNOptimized_AllowOutOfScreen(SDL_Surface *virtual_screen, SDL_Surface *hardware_screen, int new_w, int new_h){
int w1=virtual_screen->w;
//int h1=virtual_screen->h;
int w2=new_w;
int h2=new_h;
int x_ratio = (int)((virtual_screen->w<<16)/w2);
int y_ratio = (int)((virtual_screen->h<<16)/h2);
int x2, y2 ;
/// --- Compute padding for centering when out of bounds ---
int y_padding = (HW_SCREEN_HEIGHT-new_h)/2;
int x_padding = 0;
if(w2>HW_SCREEN_WIDTH){
x_padding = (w2-HW_SCREEN_WIDTH)/2 + 1;
}
int x_padding_ratio = x_padding*w1/w2;
//printf("virtual_screen->h=%d, h2=%d\n", virtual_screen->h, h2);
for (int i=0;i<h2;i++)
{
if(i>=HW_SCREEN_HEIGHT){
continue;
/// --- Compute padding for centering when out of bounds ---
int y_padding = (HW_SCREEN_HEIGHT-new_h)/2;
int x_padding = 0;
if(w2>HW_SCREEN_WIDTH){
x_padding = (w2-HW_SCREEN_WIDTH)/2 + 1;
}
int x_padding_ratio = x_padding*w1/w2;
//printf("virtual_screen->h=%d, h2=%d\n", virtual_screen->h, h2);
uint16_t* t = (uint16_t*)(hardware_screen->pixels+((i+y_padding)* ((w2>HW_SCREEN_WIDTH)?HW_SCREEN_WIDTH:w2) )*sizeof(uint16_t));
y2 = ((i*y_ratio)>>16);
uint16_t* p = (uint16_t*)(virtual_screen->pixels + (y2*w1 + x_padding_ratio) *sizeof(uint16_t));
int rat = 0;
for (int j=0;j<w2;j++)
for (int i=0;i<h2;i++)
{
if(j>=HW_SCREEN_WIDTH){
if(i>=HW_SCREEN_HEIGHT){
continue;
}
x2 = (rat>>16);
*t++ = p[x2];
rat += x_ratio;
//printf("y=%d, x=%d, y2=%d, x2=%d, (y2*virtual_screen->w)+x2=%d\n", i, j, y2, x2, (y2*virtual_screen->w)+x2);
uint16_t* t = (uint16_t*)(hardware_screen->pixels+((i+y_padding)* ((w2>HW_SCREEN_WIDTH)?HW_SCREEN_WIDTH:w2) )*sizeof(uint16_t));
y2 = ((i*y_ratio)>>16);
uint16_t* p = (uint16_t*)(virtual_screen->pixels + (y2*w1 + x_padding_ratio) *sizeof(uint16_t));
int rat = 0;
for (int j=0;j<w2;j++)
{
if(j>=HW_SCREEN_WIDTH){
continue;
}
x2 = (rat>>16);
*t++ = p[x2];
rat += x_ratio;
//printf("y=%d, x=%d, y2=%d, x2=%d, (y2*virtual_screen->w)+x2=%d\n", i, j, y2, x2, (y2*virtual_screen->w)+x2);
}
}
}
}
#endif

View File

@@ -374,8 +374,9 @@ int editeur_choix_niveau(SDL_Surface *screen){
int are_you_sure(SDL_Surface *screen){
#warning Voluntary Bypass FunKey
#ifdef FUNKEY
return 1;
#endif //FUNKEY
#ifdef HW_SCREEN_RESIZE