Teleporter first shot

This commit is contained in:
KikooDX 2020-05-14 17:23:09 +02:00
parent ab26a6dc41
commit 228c2560ce
15 changed files with 43 additions and 7 deletions

BIN
JTMM.g3a

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

View File

@ -1,6 +1,6 @@
void draw_player(int x, int y);
void draw_level(char level[], unsigned int step, char polarity, int *start_x,
int *start_y);
int *start_y, int tp_positions[]);
void erase_tile(int x, int y, char level[]);
void draw_timer(unsigned int step); //coucou Lephé'
void just_breathe();

View File

@ -20,7 +20,9 @@ extern image_t img_red_dot; //off red bloc texture, 16x16
extern image_t img_exit; //exit texture, 16x16
extern image_t img_water; //water texture, 16x16
extern image_t img_semi_solid; //semi solid texture, 16x16
//animated textures
extern image_t img_teleporter_0; //teleporter 0 texture, 16x16
extern image_t img_teleporter_1; //teleporter 1 texture, 16x16
//animated textures (elevator)
extern image_t img_elevator1, img_elevator2, img_elevator3, img_elevator4;
extern image_t img_elevator5, img_elevator6, img_elevator7, img_elevator8;
extern image_t img_elevator9, img_elevator10, img_elevator11, img_elevator12;
@ -37,7 +39,7 @@ void draw_player(int x, int y)
}
void draw_level(char level[], unsigned int step, char polarity, int *start_x,
int *start_y)
int *start_y, int tp_positions[])
{
dclear(BG_COLOR);
unsigned int i = 0;
@ -88,6 +90,16 @@ int *start_y)
case 'w': //water
dimage(x + DRAW_OFFSET_X, y + DRAW_OFFSET_Y, &img_water);
break;
case 't': //teleporter 0
dimage(x + DRAW_OFFSET_X, y + DRAW_OFFSET_Y, &img_teleporter_0);
tp_positions[0] = x + 2;
tp_positions[1] = y + 2;
break;
case 'T': //teleporter 1
dimage(x + DRAW_OFFSET_X, y + DRAW_OFFSET_Y, &img_teleporter_1);
tp_positions[2] = x + 2;
tp_positions[3] = y + 2;
break;
}
x += 16;
if (x == 16*LEVEL_WIDTH)

View File

@ -18,7 +18,7 @@
#define GRAV 0.4
#define JUMP_SCALE 8
#define JUMP_REDUCTION -0.41
#define DRAW_LEVEL() draw_level(level, step, polarity, &start_x, &start_y)
#define DRAW_LEVEL() draw_level(level, step, polarity, &start_x, &start_y, tp_positions)
void dupdate(); //gint function
//test if jump pressed
@ -57,6 +57,8 @@ int main(void)
char enable_up_key = 0;
char game_loop = 1;
char exit_buffer = 0;
char tp_buffer = 0;
int tp_positions[4] = { 0, 0, 0, 0 };
set_level(level_id, level);
DRAW_LEVEL();
player_x = start_x;
@ -199,6 +201,26 @@ int main(void)
}
}
}
//teleporter
if (collide(player_x, player_y, level, 't'))
{
if (!tp_buffer)
{
player_x = tp_positions[2];
player_y = tp_positions[3];
}
tp_buffer = 1;
}
else if (collide(player_x, player_y, level, 'T'))
{
if (!tp_buffer)
{
player_x = tp_positions[0];
player_y = tp_positions[1];
}
tp_buffer = 1;
}
else tp_buffer = 0;
//spike collision and death
if (collide_spike(player_x, player_y, level))
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

View File

@ -1 +1 @@
0000000000000000000000000000000000000000000000000000000.....rr..........000000000.....rr..........000000000.....rr..........000000000.....rr..........000000000..E..rr..........00000000011111111bbbb.....00000000000000000bbbb1111100000000.............0000000000000.............0000000000000.........11110000000000000..S......0000000000000000011111111100000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000.....rr..........000000000.....rr..........000000000.....rr..........000000000.....rr..........000000000..E..rr.......t..00000000011111111bbbb.....00000000000000000bbbb1111100000000.............0000000000000.............0000000000000.....T...11110000000000000..S......0000000000000000011111111100000000000000000000000000000000000000000

View File

@ -1 +1 @@
000000000000000000000000000000000000000000000000000000......................0000......................0000..//..//..//..//..//..0000......................0000......................0000..//..//..//..//..//..0000......................0000......................0000..//..//..//..//..//..0000......................0000.S..................E.000011111111111111111111110000000000000000000000000000
000000000000000000000000000000000000000000000000000000...................T..0000......................0000..//..//..//..//..//..0000......................0000......................0000..//..//..//..//..//..0000......................0000......................0000..//..//..//..//..//..0000...t..................0000.S..................E.000011111111111111111111110000000000000000000000000000

View File

@ -10,9 +10,11 @@ tiles = {
love.graphics.newImage(img_path.."water.png"),
love.graphics.newImage(img_path.."bouncer.png"),
love.graphics.newImage(img_path.."semi_solid.png"),
love.graphics.newImage(img_path.."teleporter_0.png"),
love.graphics.newImage(img_path.."teleporter_1.png"),
love.graphics.newImage(img_path.."spawn.png"),
love.graphics.newImage(img_path.."exit.png"),
}
tiles_char = { '0', '1', 'r', 'b', 'v', '^', 'w', '*', '/', 'S', 'E' }
tiles_char = { '0', '1', 'r', 'b', 'v', '^', 'w', '*', '/', 't', 'T' ,'S', 'E' }
selected_tile = 1