i fucking hate programming

This commit is contained in:
Masséna Fezard | Nounouille 2021-04-19 14:48:36 +02:00
parent e7b3b4a805
commit e6b6e43d27
10 changed files with 80 additions and 41 deletions

View File

@ -38,9 +38,9 @@ target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
target_link_libraries(myaddin Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET myaddin OUTPUT "ZkuwL.g1a"
NAME "ZkuwL" ICON assets-fx/icon.png)
generate_g1a(TARGET myaddin OUTPUT "ZkwuL.g1a"
NAME "ZkwuL" ICON assets-fx/icon.png)
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "ZkuwL.g3a"
NAME "ZkuwL" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
generate_g3a(TARGET myaddin OUTPUT "ZkwuL.g3a"
NAME "ZkwuL" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif()

View File

@ -5,3 +5,7 @@
ZkwuL is a game made with [gint](https://gitea.planet-casio.com/Lephenixnoir/gint)
It's a remake of my [first game](https://massena.itch.io/zkwul-the-game) made with GameMaker Studio 2
# Softwares used
I use [SLE](https://sr.ht/~kikoodx/sle/) and [kble2lua](https://gitea.planet-casio.com/KikooDX/kble2lua)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 177 B

View File

@ -1,5 +1,6 @@
#pragma once
#define LEVEL_NB 2
#define LEVEL_SIZE 16
#define TILE_SIZE 12
@ -17,7 +18,7 @@ typedef struct Player {
/* used for tiles */
typedef int tile_t;
Vec2 search(tile_t x, tile_t level[16][16]);
int collide_pixel(Vec2 pos, tile_t obj, tile_t level[16][16]);
int collide(Vec2 pos, int h, tile_t obj, tile_t level[16][16]);
Player level_reset(Player player);
Vec2 search(tile_t x, tile_t level[LEVEL_SIZE][LEVEL_SIZE]);
int collide_pixel(Vec2 pos, tile_t obj, tile_t level[LEVEL_SIZE][LEVEL_SIZE]);
int collide(Vec2 pos, int h, tile_t obj, tile_t level[LEVEL_SIZE][LEVEL_SIZE]);
Player level_reset(Player player, tile_t level[LEVEL_SIZE][LEVEL_SIZE]);

BIN
levels/level1.kble Normal file

Binary file not shown.

BIN
levels/level2.kble Normal file

Binary file not shown.

BIN
levels/tileset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

View File

@ -1,20 +1,41 @@
#include "main.h"
const tile_t level[16][16] = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 3, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 0, 0, 1},
{1, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 1},
{1, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 3, 0, 0, 0, 0, 1, 0, 0, 0,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 2,
2, 0, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 0, 2,
2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 0, 2,
2, 0, 2, 2, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 0, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 0, 0, 0, 0, 0, 2, 2, 0, 2, 0, 0, 2, 2, 0, 2,
2, 0, 4, 0, 4, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2,
2, 0, 0, 4, 0, 0, 2, 2, 0, 2, 0, 0, 2, 2, 0, 2,
2, 0, 4, 0, 4, 0, 0, 2, 0, 2, 0, 0, 2, 0, 0, 2,
2, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2,
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
2, 0, 1, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 2,
2, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 4, 0, 0, 0, 2,
2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2
}
};

View File

@ -50,7 +50,8 @@ int collide(Vec2 pos, int h, tile_t obj, tile_t level[LEVEL_SIZE][LEVEL_SIZE]) {
return 0;
}
Player level_reset(Player player) {
Player level_reset(Player player, tile_t level[LEVEL_SIZE][LEVEL_SIZE]) {
player.spawn = search(1, level);
player.pos = player.spawn;
return player;
}
@ -61,18 +62,19 @@ int main(void) {
extern bopti_image_t img_spike;
extern bopti_image_t img_end;
extern tile_t level[LEVEL_SIZE][LEVEL_SIZE];
extern tile_t level[LEVEL_NB][LEVEL_SIZE][LEVEL_SIZE];
int running = 1;
int timer = 0; /* lol */
int lvl = 0;
/* player */
Player player = {
.pos = {0, 0},
.spawn = {0, 0}
};
player.spawn = search(2, level);
player = level_reset(player);
player = level_reset(player, level[lvl]);
/* main loop */
while(running) {
@ -82,20 +84,21 @@ int main(void) {
/* drawing the level */
for(int m = 0; m < LEVEL_SIZE; ++m) {
for(int n = 0; n < LEVEL_SIZE; ++n) {
switch(level[n][m]) {
case 1:
switch(level[lvl][n][m]) {
case 2:
/* walls */
dimage(m * TILE_SIZE, n * TILE_SIZE, &img_wall);
break;
case 3:
/* spikes */
dimage(m * TILE_SIZE, n * TILE_SIZE, &img_spike);
break;
case 4:
/* end ring */
dsubimage(m * TILE_SIZE, n * TILE_SIZE, &img_end,
((timer / 30) % 4) * 12, 0, 12, 12, 0);
break;
case 4:
/* spikes */
dimage(m * TILE_SIZE, n * TILE_SIZE, &img_spike);
break;
}
}
}
@ -112,23 +115,33 @@ int main(void) {
clearevents();
/* trying to move the player >w< */
if(!collide((Vec2){player.pos.x + mov.x, player.pos.y}, 0, 1, level)) {
if(!collide((Vec2){player.pos.x + mov.x, player.pos.y}, 1, 2, level[lvl])) {
player.pos.x += mov.x;
}
if(!collide((Vec2){player.pos.x, player.pos.y + mov.y}, 0, 1, level)) {
if(!collide((Vec2){player.pos.x, player.pos.y + mov.y}, 1, 2, level[lvl])) {
player.pos.y += mov.y;
}
/* d i e */
if(collide(player.pos, 2, 3, level)) {
player = level_reset(player);
if(collide(player.pos, 2, 4, level[lvl])) {
player = level_reset(player, level[lvl]);
}
if(keydown(KEY_EXIT) || collide(player.pos, 0, 4, level)) {
if(keydown(KEY_EXIT)) {
running = 0;
}
if(collide(player.pos, 0, 3, level[lvl])) {
if(lvl != LEVEL_NB - 1) {
player = level_reset(player, level[lvl]);
++lvl;
}
else {
running = 0;
}
}
++timer; /* lol^2 */
}