sprites etc

This commit is contained in:
whaffman 2025-05-27 15:36:25 +02:00
parent 354d882ae7
commit b626712e51
17 changed files with 49 additions and 32 deletions

BIN
assets/accu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
assets/bricks1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
assets/bricks2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/paving1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -31,7 +31,7 @@ void main()
case 1: texColor = texture(Texture1, TexCoord); break;
case 2: texColor = texture(Texture2, TexCoord); break;
case 3: texColor = texture(Texture3, TexCoord); break;
default: texColor = vec4(1.0, 0.0, 0.0, 1.0); break;
default: texColor = vec4(0.0, 0.0, 0.0, 0.0); break;
}
if (TexIndex == 1) {

BIN
assets/stonewall1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
assets/stonewall256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

BIN
assets/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
assets/tiles1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
assets/tiles2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/tiles256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

BIN
assets/tiles3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/tiles4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/15 15:46:08 by qmennen #+# #+# */
/* Updated: 2025/05/25 21:02:05 by whaffman ######## odam.nl */
/* Updated: 2025/05/27 15:32:27 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -79,10 +79,26 @@ void draw_battery(mlx_image_t *img, float battery)
void handle_battery(t_game *game)
{
static mlx_image_t *bat_img = NULL;
game->player->battery -= game->screen->mlx->delta_time / 50;
if (game->player->battery < 0)
game->player->battery = 0.001f;
if (game->player->battery < 0.20)
{
//if (bat_img == NULL)
bat_img = mlx_put_string(
game->screen->mlx, "Battery LOW!", 960, 512);
}
else
{
if (bat_img != NULL)
{
mlx_delete_image(game->screen->mlx, bat_img);
bat_img = NULL;
}
}
draw_battery(game->screen->minimap, game->player->battery);
}
void handle_record(t_game *game)

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/05/08 12:23:17 by qmennen #+# #+# */
/* Updated: 2025/05/23 15:12:57 by whaffman ######## odam.nl */
/* Updated: 2025/05/26 12:53:24 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -17,7 +17,7 @@ static void get_start_end(t_game *game,
{
double sprite_scale;
sprite_scale = 16.0 / sprite->dist;
sprite_scale = game->screen->height / sprite->dist / sprite->texture->height;
start->x = 0.5 * (game->screen->width * (1.0 + sprite->cam_frac)
- sprite->texture->width / sprite->n_frames * sprite_scale);
start->y = 0.5 * (game->screen->height

View File

@ -6,7 +6,7 @@
/* By: whaffman <whaffman@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/04/22 17:08:26 by qmennen #+# #+# */
/* Updated: 2025/05/25 13:41:32 by whaffman ######## odam.nl */
/* Updated: 2025/05/26 12:30:34 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
@ -18,17 +18,17 @@ t_sprite make_sprite(mlx_texture_t *texture, double x, double y, int collectible
ft_memset(&sprite, 0, sizeof(t_sprite));
sprite.texture = texture;
if (sprite.texture->width % 64 != 0)
{
ft_putstr_fd("Error: Texture width is not a multiple of 64\n", 2);
exit(EXIT_FAILURE);
}
if (sprite.texture->height != 64)
{
ft_putstr_fd("Error: Texture height must be 64\n", 2);
exit(EXIT_FAILURE);
}
sprite.n_frames = sprite.texture->width / 64;
// if (sprite.texture->width % 64 != 0)
// {
// ft_putstr_fd("Error: Texture width is not a multiple of 64\n", 2);
// exit(EXIT_FAILURE);
// }
// if (sprite.texture->height != 64)
// {
// ft_putstr_fd("Error: Texture height must be 64\n", 2);
// exit(EXIT_FAILURE);
// }
sprite.n_frames = sprite.texture->width / sprite.texture->height;
sprite.pos.x = x;
sprite.pos.y = y;
sprite.visible = 1;

View File

@ -1,10 +1,10 @@
NO ./assets/bricks_cyan_x64.png
NO ./assets/tiles256.png
WE ./assets/bricks_green_x64.png
WE ./assets/bricks2.png
SO ./assets/bricks_orange_x64.png
SO ./assets/stonewall256.png
EA ./assets/bricksx64.png
F 90,30,30
@ -12,28 +12,29 @@ F 90,30,30
C 100,100,200
FT ./assets/floor.png
FT ./assets/tiles3.png
CT ./assets/ceiling64x64.png
-s a ./assets/lamp.png
-c b ./assets/battery.png
-c b ./assets/accu.png
-s p ./assets/plant.png
-s m ./assets/broken_mirror.png
-s t ./assets/test.png
1111111 111 1111 111111 1111111111 111111
1000001110111001 100001 1000000001 10001
1001000000000001 100001 100000110111100011
10b0001110000001110011111111 110000001000000001
1000001 1000100a000010000001 100000001000000001
100m00111000100000b00000000111110p00000100p00m001
10b0000000001111111111100000000000111111000000001
1000000W00001 1000011111111 1000001001
10010000000b0001 100001 100000110111100011
10b0001110000001110011111111 1100b0001000000001
1000001 1000100a000010000001 10000000100b000001
100m00111000100000b00000b00111110p00000100p00m001
10b000bb00001111111111100000000000111111000000001
1000t0bW00001 1000011111111 1000001001
10p0011111001 111111100001 1111111111110001
100001 1001 1p00000000011111111000010111 10b01
111111 1001 1000001000000000001000000101 100001
1001 10000p1111111111111000010001 10000m1
111111 1001 10000010000000000010b0000101 100001
1b01 10000p1111111111111000010001 10b00m1
1001 100000000000000000000111b001 100001
1001 1b00000000000p00000011 11111 100001
1001 1b000000b0000p00000011 11111 100001
10011111111100111111111111111111001110001
1000000000000000000000b000000000000000001
111111b0111111101100111100011101011111111