Compare commits

...

20 Commits
old ... master

Author SHA1 Message Date
Masséna Fezard | Nounouille 22d03e26b6 cleanup 2022-01-14 22:09:54 +01:00
Masséna Fezard | Nounouille ba3824bac4 oops 2022-01-14 22:06:55 +01:00
Masséna Fezard | Nounouille 10478eb6c5 pew pew 2022-01-14 21:52:46 +01:00
Masséna Fezard | Nounouille d433f8bc2d Scarlet 2022-01-12 16:43:22 +01:00
Masséna Fezard | Nounouille c104870634 player sprite, first shot 2022-01-11 17:37:52 +01:00
Masséna Fezard | Nounouille 1374445716 hook part 5 -- nyooom 2022-01-09 18:56:06 +01:00
Masséna Fezard | Nounouille b793ce4a73 hook part 4 -- ok now it won't work >:o 2022-01-09 17:29:44 +01:00
Masséna Fezard | Nounouille 5a23856a3f FUCK FUCK FUCK FUCK FUCK 2022-01-09 16:53:21 +01:00
Masséna Fezard | Nounouille c4c4f6d760 hook part 3 -- happy ending 2022-01-09 15:17:53 +01:00
Masséna Fezard | Nounouille d553ec9bb1 hook part 2 -- electric boogaloo 2022-01-08 23:37:11 +01:00
Masséna Fezard | Nounouille 9cd2b08884 movement nerf #1 2022-01-08 19:25:47 +01:00
Masséna Fezard | Nounouille 0125a480c0 hook part 1 2022-01-08 19:19:02 +01:00
Masséna Fezard | Nounouille 70f679781c new test map 2022-01-08 15:24:23 +01:00
Masséna Fezard | Nounouille da77b7d1ea nyooom 2021-12-23 19:31:40 +01:00
Masséna Fezard | Nounouille c0dcb5b226 colli*bonk* 2021-12-23 17:43:44 +01:00
Masséna Fezard | Nounouille 1e8f690745 shipost level (100%) 2021-12-23 15:13:06 +01:00
Masséna Fezard | Nounouille c7c961cc60 acceleration and friction 2021-12-23 10:00:55 +01:00
Masséna Fezard | Nounouille e136461f63 new structure 2021-12-22 16:18:06 +01:00
Masséna Fezard | Nounouille c8850ee774 cleanup 2021-12-21 22:25:52 +01:00
Masséna Fezard | Nounouille a910f94023 test 2021-12-21 22:23:52 +01:00
44 changed files with 967 additions and 583 deletions

View File

@ -12,14 +12,21 @@ find_package(Gint 2.1 REQUIRED)
set(SOURCES
src/main.c
src/input.c
src/draw.c
src/player.c
# ...
src/input.c
src/tools.c
src/level.c
src/hook.c
src/bullet.c
)
set(ASSETS_cg
assets-cg/tileset.png
# ...
assets-cg/hooksel.png
assets-cg/scarletR.png
assets-cg/scarletL.png
assets-cg/bullet.png
)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)

View File

@ -1,3 +1,5 @@
# interference
:eyes:
:eyes:
A game for fx-CG 50.

BIN
assets-cg/bullet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -1,4 +1,4 @@
tileset.png:
*.png:
type: bopti-image
name: img_tileset
profile: p4
profile: p8
name_regex: (.*)\.png img_\1

BIN
assets-cg/hooksel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

BIN
assets-cg/missile1.ase Normal file

Binary file not shown.

BIN
assets-cg/missile2.ase Normal file

Binary file not shown.

BIN
assets-cg/scarlet.ase Normal file

Binary file not shown.

BIN
assets-cg/scarlet.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
assets-cg/scarletL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
assets-cg/scarletR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,70 +0,0 @@
return {
version = "1.5",
luaversion = "5.1",
tiledversion = "1.7.2",
orientation = "orthogonal",
renderorder = "right-down",
width = 50,
height = 28,
tilewidth = 8,
tileheight = 8,
nextlayerid = 2,
nextobjectid = 1,
properties = {},
tilesets = {
{
name = "tileset",
firstgid = 1,
filename = "test.tsx"
}
},
layers = {
{
type = "tilelayer",
x = 0,
y = 0,
width = 50,
height = 28,
id = 1,
name = "Calque de Tuiles 1",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
encoding = "lua",
data = {
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 50, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 49, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 14, 14, 14, 14,
26, 26, 26, 26, 26, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 26, 26, 26, 26, 26,
40, 41, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 39, 40,
14, 18, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 13, 14,
14, 18, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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14, 14, 14, 18, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 18, 13, 14, 14, 14, 14, 14, 14, 14
}
}
}
}

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="50" height="28" tilewidth="8" tileheight="8" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="test.tsx"/>
<layer id="1" name="Calque de Tuiles 1" width="50" height="28">
<data encoding="csv">
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,50,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,49,14,14,14,14,14,
14,14,14,14,14,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,14,14,14,14,14,
26,26,26,26,26,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,26,26,26,26,26,
40,41,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,39,40,
14,18,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,13,14,
14,18,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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14,14,18,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,18,13,14,14,14,14,14,14,14
</data>
</layer>
</map>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.5" tiledversion="1.7.2" name="tileset" tilewidth="8" tileheight="8" tilecount="72" columns="12">
<image source="tileset.png" width="96" height="48"/>
</tileset>

View File

@ -1,6 +0,0 @@
{
"maps": [
],
"onlyShowAdjacentMaps": false,
"type": "world"
}

View File

@ -1,56 +0,0 @@
return {
version = "1.5",
luaversion = "5.1",
tiledversion = "1.7.2",
orientation = "orthogonal",
renderorder = "right-down",
width = 25,
height = 14,
tilewidth = 16,
tileheight = 16,
nextlayerid = 2,
nextobjectid = 1,
properties = {},
tilesets = {
{
name = "test",
firstgid = 1,
filename = "test.tsx"
}
},
layers = {
{
type = "tilelayer",
x = 0,
y = 0,
width = 25,
height = 14,
id = 1,
name = "Calque de Tuiles 1",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
encoding = "lua",
data = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
}
}
}

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="25" height="14" tilewidth="16" tileheight="16" infinite="0" nextlayerid="2" nextobjectid="1">
<layer id="1" name="Calque de Tuiles 1" width="25" height="14">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
</map>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -1,3 +0,0 @@
example.png:
type: bopti-image
name: img_example

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

20
include/bullet.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include "type.h"
struct Bullet {
struct Vec2 pos;
int v;
int active;
};
struct Bullet_table {
int n;
struct Bullet *bullets;
};
void bullet_table_init(void);
void bullet_table_update(void);
void bullet_table_draw(int timer);
void bullet_destroy(struct Bullet *bullet);
void bullet_fire(int x, int y, int v);
int bullet_nb(void);

17
include/conf.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#define PLAYER_S 12
#define PLAYER_W 22
#define PLAYER_H 18
#define PLAYER_ACC 1.5
#define PLAYER_FRIC 0.4
#define PLAYER_JUMP 6.5
#define PLAYER_COYOTE 3
#define GRAVITY 0.4
#define TILE_S 8
#define TILESET_W 16
#define TILESET_H 4
#define MAX_BULLETS 64

4
include/draw.h Normal file
View File

@ -0,0 +1,4 @@
#pragma once
#include <gint/display.h>
void draw_rectangle(int c, int x, int y, int w, int h);

17
include/hook.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include "type.h"
#define HOOK_T 9
struct Hook {
struct Vec2 pos;
};
struct Hook_table {
int n;
struct Hook *hooks;
};
void hook_table_init(void);
int hook_nb(void);
struct Vec2 hook_closest(struct Vec2 *pos);

View File

@ -1,18 +1,16 @@
#pragma once
/* FROM FISFOR */
/* use this to get user input, NOT gint/keyboard.h */
/* CODE FROM FISFOR */
typedef enum Key {
K_A,
K_B,
K_X,
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_EXIT,
K_X,
K_Y,
K_COUNT
} Key;
typedef enum KeyState { KS_UP, KS_RELEASE, KS_DOWN, KS_PRESS } KeyState;

17
include/level.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include "type.h"
struct Level {
int w, h, s; /* width, height, size */
tile_t *data;
};
void level_init(void);
void level_draw(void);
tile_t level_get_px(int x, int y);
tile_t level_get_tile(int x, int y);
int level_count(tile_t tile);
int level_search_i(tile_t tile, int occ);
struct Vec2 level_search_s(tile_t tile, int occ);
struct Vec2 level_get_dim(void);

View File

@ -1,39 +1 @@
#pragma once
#define TILE_S 8
#define TILESET_W 12
#define TILESET_H 6
/* Yup, it's exactly the code from frozen frenzy™. */
/* used for tiles */
typedef int tile_t;
/* struct for a pair of int values */
typedef struct Vec2 {
int x, y;
} Vec2;
/* struct for a pair of float values */
typedef struct FVec2 {
float x, y;
} FVec2;
/* struct for player's data */
typedef struct Player {
Vec2 pos;
Vec2 spawn;
FVec2 spd;
} Player;
/* dynamic level data */
typedef struct Level {
int width, height;
tile_t *data;
} Level;
/* struct for rem movement and collision check */
typedef struct Res_Mov {
Player player;
Vec2 moved;
} Res_Mov;

View File

@ -1,18 +1,17 @@
#pragma once
#include "main.h"
#include "type.h"
#define PLAYER_SIZE 12
struct Player {
struct Vec2 pos;
struct FVec2 spd;
struct FVec2 rem;
struct Vec2 spawn;
struct Vec2 hook_pos;
struct Vec2 hook_near;
int jumping, airbreak, hooking, locked, dir;
};
#define PLAYER_ACC 1
#define BASE_FRIC 0.2
#define GRAVITY 0.4
#define JUMP_H 7
#define COYOTE_TIME 3
Player player_reset(Player player, Level level);
Vec2 search(tile_t x, Level level);
int convert_all(tile_t x, tile_t y, Level level);
int collide_pixel(Vec2 pos, tile_t obj, Level level);
int collide(Vec2 pos, int h, tile_t obj, Level level);
Res_Mov move(Player player, Level level);
Player player_reset(Player player, Level level);
void player_init(void);
void player_update(void);
void player_draw(int frame);
struct Vec2 player_get_pos(void);

5
include/tools.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include "type.h"
int sign(int x);
int length(struct Vec2 *a, struct Vec2 *b);

11
include/type.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
typedef int tile_t;
struct Vec2 {
int x, y;
};
struct FVec2 {
float x, y;
};

71
levels/test.lua Normal file
View File

@ -0,0 +1,71 @@
return {
version = "1.5",
luaversion = "5.1",
tiledversion = "1.7.2",
orientation = "orthogonal",
renderorder = "right-down",
width = 50,
height = 28,
tilewidth = 8,
tileheight = 8,
nextlayerid = 2,
nextobjectid = 1,
backgroundcolor = { 0, 0, 0 },
properties = {},
tilesets = {
{
name = "tileset",
firstgid = 1,
filename = "tileset.tsx"
}
},
layers = {
{
type = "tilelayer",
x = 0,
y = 0,
width = 50,
height = 28,
id = 1,
name = "Calque de Tuiles 1",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
encoding = "lua",
data = {
19, 21, 22, 22, 21, 20, 20, 21, 22, 19, 22, 20, 21, 21, 20, 22, 19, 20, 21, 21, 22, 21, 19, 21, 22, 20, 20, 21, 19, 19, 20, 19, 22, 21, 19, 22, 22, 19, 19, 20, 20, 22, 20, 20, 19, 20, 19, 22, 21, 20,
22, 19, 20, 20, 22, 22, 19, 19, 21, 21, 22, 22, 22, 20, 20, 22, 22, 21, 22, 21, 22, 22, 19, 20, 22, 21, 22, 22, 20, 21, 19, 19, 20, 22, 21, 19, 20, 22, 20, 19, 19, 20, 19, 20, 21, 22, 20, 21, 22, 21,
20, 21, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 19, 19,
19, 22, 17, 25, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58, 58, 0, 42, 42, 42, 42, 41, 42, 42, 26, 18, 19, 20,
20, 22, 17, 25, 42, 42, 42, 42, 58, 57, 58, 57, 58, 42, 42, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58, 58, 0, 0, 0, 0, 0, 57, 0, 0, 26, 18, 22, 19,
20, 21, 17, 25, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58, 0, 0, 0, 0, 42, 42, 41, 42, 42, 26, 18, 20, 20,
21, 22, 17, 25, 42, 42, 0, 41, 42, 41, 42, 41, 42, 41, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 41, 42, 41, 42, 42, 41, 42, 41, 42, 42, 41, 42, 41, 0, 0, 0, 0, 0, 57, 0, 0, 26, 18, 21, 21,
19, 22, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 58, 0, 57, 58, 57, 58, 57, 58, 57, 0, 58, 0, 0, 0, 0, 0, 0, 57, 0, 0, 26, 18, 21, 20,
20, 19, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 58, 0, 0, 0, 0, 0, 0, 57, 0, 0, 26, 18, 20, 20,
19, 22, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 22, 19,
22, 21, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, 41, 42, 41, 42, 41, 42, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 22, 21,
19, 21, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 21, 22,
22, 21, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 21, 19,
19, 19, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 21, 21,
20, 20, 35, 44, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 22, 20,
20, 22, 51, 60, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 22, 21,
22, 21, 51, 60, 58, 58, 0, 41, 42, 41, 42, 41, 42, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, 41, 42, 41, 42, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 36, 22, 22,
21, 21, 3, 3, 3, 3, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 52, 22, 20,
22, 19, 19, 4, 4, 4, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 58, 59, 52, 20, 19,
22, 21, 17, 25, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 33, 34, 34, 34, 34, 33, 34, 34, 33, 0, 1, 1, 2, 0, 58, 57, 58, 57, 58, 0, 2, 1, 1, 0, 33, 34, 34, 33, 34, 34, 34, 34, 34, 19, 20,
20, 20, 35, 44, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 49, 50, 50, 50, 50, 49, 58, 58, 57, 0, 41, 27, 17, 2, 3, 3, 3, 3, 3, 2, 18, 27, 41, 0, 57, 58, 58, 49, 50, 50, 50, 50, 18, 19, 21,
20, 21, 51, 60, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 49, 50, 50, 50, 50, 49, 58, 58, 57, 0, 41, 2, 2, 19, 19, 3, 2, 3, 19, 19, 2, 2, 41, 0, 57, 58, 58, 49, 50, 50, 50, 50, 18, 20, 20,
22, 19, 51, 60, 58, 58, 0, 0, 58, 57, 58, 57, 33, 34, 34, 33, 34, 34, 34, 34, 33, 42, 42, 42, 0, 0, 26, 19, 19, 19, 19, 4, 19, 19, 19, 19, 25, 0, 0, 41, 41, 42, 33, 34, 34, 34, 34, 34, 22, 21,
20, 20, 3, 3, 3, 3, 3, 3, 58, 57, 58, 57, 49, 50, 50, 49, 50, 50, 50, 50, 49, 58, 58, 57, 0, 0, 0, 18, 4, 4, 4, 4, 4, 4, 4, 17, 0, 0, 0, 57, 58, 58, 49, 50, 50, 50, 50, 18, 20, 19,
19, 19, 19, 20, 19, 19, 19, 17, 58, 57, 58, 57, 49, 50, 50, 49, 50, 50, 50, 50, 49, 58, 58, 57, 0, 0, 0, 0, 49, 50, 58, 57, 58, 50, 49, 0, 0, 0, 0, 57, 57, 58, 49, 50, 50, 50, 50, 18, 20, 21,
19, 21, 21, 22, 20, 20, 19, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 20, 20,
20, 20, 19, 20, 21, 21, 22, 19, 20, 22, 20, 22, 22, 19, 19, 22, 21, 19, 22, 20, 21, 21, 20, 21, 19, 19, 19, 20, 20, 22, 22, 21, 22, 21, 20, 22, 21, 19, 19, 19, 21, 19, 19, 22, 20, 21, 19, 22, 22, 22,
21, 20, 19, 22, 20, 22, 19, 22, 20, 20, 19, 21, 21, 22, 19, 19, 22, 21, 19, 22, 20, 22, 20, 22, 20, 22, 20, 19, 20, 21, 20, 19, 20, 22, 22, 22, 19, 19, 20, 21, 21, 19, 20, 19, 21, 19, 21, 21, 22, 19
}
}
}
}

39
levels/test.tmx Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.5" tiledversion="1.7.2" orientation="orthogonal" renderorder="right-down" width="50" height="28" tilewidth="8" tileheight="8" infinite="0" backgroundcolor="#000000" nextlayerid="2" nextobjectid="1">
<editorsettings>
<export target="../assets-cg/test.lua" format="lua"/>
</editorsettings>
<tileset firstgid="1" source="tileset.tsx"/>
<layer id="1" name="Calque de Tuiles 1" width="50" height="28">
<data encoding="csv">
19,21,22,22,21,20,20,21,22,19,22,20,21,21,20,22,19,20,21,21,22,21,19,21,22,20,20,21,19,19,20,19,22,21,19,22,22,19,19,20,20,22,20,20,19,20,19,22,21,20,
22,19,20,20,22,22,19,19,21,21,22,22,22,20,20,22,22,21,22,21,22,22,19,20,22,21,22,22,20,21,19,19,20,22,21,19,20,22,20,19,19,20,19,20,21,22,20,21,22,21,
20,21,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,19,19,
19,22,17,25,0,0,0,0,58,57,58,57,58,0,0,0,0,0,0,58,0,0,0,0,0,58,58,57,58,57,58,57,58,57,58,57,58,58,0,42,42,42,42,41,42,42,26,18,19,20,
20,22,17,25,42,42,42,42,58,57,58,57,58,42,42,0,0,0,0,58,0,0,0,0,0,58,58,57,58,57,58,57,58,57,58,57,58,58,0,0,0,0,0,57,0,0,26,18,22,19,
20,21,17,25,0,0,0,0,58,57,58,57,58,0,0,0,0,0,0,41,0,0,0,0,0,0,58,57,58,57,58,57,58,57,58,57,58,0,0,0,0,42,42,41,42,42,26,18,20,20,
21,22,17,25,42,42,0,41,42,41,42,41,42,41,0,0,0,0,0,58,0,0,0,0,0,41,42,41,42,42,41,42,41,42,42,41,42,41,0,0,0,0,0,57,0,0,26,18,21,21,
19,22,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,58,0,0,0,0,0,0,58,0,57,58,57,58,57,58,57,0,58,0,0,0,0,0,0,57,0,0,26,18,21,20,
20,19,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,58,0,0,0,0,0,0,58,58,57,58,57,58,57,58,57,58,58,0,0,0,0,0,0,57,0,0,26,18,20,20,
19,22,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,57,58,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,26,18,22,19,
22,21,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,42,41,42,41,42,41,42,9,0,0,0,0,0,0,0,0,0,0,26,18,22,21,
19,21,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,26,18,21,22,
22,21,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,57,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,0,26,18,21,19,
19,19,17,25,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,26,18,21,21,
20,20,35,44,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,57,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,0,26,18,22,20,
20,22,51,60,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,58,57,58,57,0,0,0,0,0,0,0,0,0,0,0,0,26,18,22,21,
22,21,51,60,58,58,0,41,42,41,42,41,42,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41,42,41,42,41,42,41,0,0,0,0,0,0,0,0,0,0,0,43,36,22,22,
21,21,3,3,3,3,0,0,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,0,0,59,52,22,20,
22,19,19,4,4,4,0,0,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,58,57,58,57,58,0,0,0,0,0,0,0,0,0,0,58,58,59,52,20,19,
22,21,17,25,0,0,0,0,58,57,58,57,58,0,0,33,34,34,34,34,33,34,34,33,0,1,1,2,0,58,57,58,57,58,0,2,1,1,0,33,34,34,33,34,34,34,34,34,19,20,
20,20,35,44,0,0,0,0,58,57,58,57,58,0,0,49,50,50,50,50,49,58,58,57,0,41,27,17,2,3,3,3,3,3,2,18,27,41,0,57,58,58,49,50,50,50,50,18,19,21,
20,21,51,60,0,0,0,0,58,57,58,57,58,0,0,49,50,50,50,50,49,58,58,57,0,41,2,2,19,19,3,2,3,19,19,2,2,41,0,57,58,58,49,50,50,50,50,18,20,20,
22,19,51,60,58,58,0,0,58,57,58,57,33,34,34,33,34,34,34,34,33,42,42,42,0,0,26,19,19,19,19,4,19,19,19,19,25,0,0,41,41,42,33,34,34,34,34,34,22,21,
20,20,3,3,3,3,3,3,58,57,58,57,49,50,50,49,50,50,50,50,49,58,58,57,0,0,0,18,4,4,4,4,4,4,4,17,0,0,0,57,58,58,49,50,50,50,50,18,20,19,
19,19,19,20,19,19,19,17,58,57,58,57,49,50,50,49,50,50,50,50,49,58,58,57,0,0,0,0,49,50,58,57,58,50,49,0,0,0,0,57,57,58,49,50,50,50,50,18,20,21,
19,21,21,22,20,20,19,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,20,20,
20,20,19,20,21,21,22,19,20,22,20,22,22,19,19,22,21,19,22,20,21,21,20,21,19,19,19,20,20,22,22,21,22,21,20,22,21,19,19,19,21,19,19,22,20,21,19,22,22,22,
21,20,19,22,20,22,19,22,20,20,19,21,21,22,19,19,22,21,19,22,20,22,20,22,20,22,20,19,20,21,20,19,20,22,22,22,19,19,20,21,21,19,20,19,21,19,21,21,22,19
</data>
</layer>
</map>

4
levels/tileset.tsx Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.5" tiledversion="1.7.2" name="tileset" tilewidth="8" tileheight="8" tilecount="64" columns="16">
<image source="../assets-cg/tileset.png" width="128" height="32"/>
</tileset>

102
src/bullet.c Normal file
View File

@ -0,0 +1,102 @@
#include "bullet.h"
#include "conf.h"
#include "level.h"
#include <gint/display.h>
#include <stdlib.h>
#include <string.h>
static struct Bullet_table bullet_table;
static void bullet_table_free(void);
static void bullet_update(struct Bullet *bullet);
static void bullet_draw(struct Bullet *bullet, int timer);
extern bopti_image_t img_bullet;
void
bullet_table_init(void)
{
bullet_table_free();
bullet_table.bullets = malloc(MAX_BULLETS * sizeof(struct Bullet));
bullet_table.n = 0;
for (int i = 0; i < MAX_BULLETS; ++i) {
bullet_table.bullets[i].active = 0;
}
}
void
bullet_table_free(void)
{
if (bullet_table.bullets != NULL) {
bullet_table.bullets = NULL;
}
};
void
bullet_fire(int x, int y, int v)
{
for (int i = 0; i < MAX_BULLETS; ++i) {
if (!bullet_table.bullets[i].active) {
bullet_table.bullets[i] = (struct Bullet){
.pos = (struct Vec2){.x = x, .y = y},
.v = v,
.active = 1};
break;
}
}
++bullet_table.n;
}
void
bullet_table_update(void)
{
for (int i = 0; i < MAX_BULLETS; ++i) {
if (bullet_table.bullets[i].active) {
bullet_update(&bullet_table.bullets[i]);
}
}
}
void
bullet_update(struct Bullet *bullet)
{
bullet->pos.x += bullet->v;
/* boom */
const struct Vec2 level_dim = level_get_dim();
if (bullet->pos.x < -6 || bullet->pos.x > level_dim.x * TILE_S ||
bullet->pos.y < -6 || bullet->pos.y > level_dim.y * TILE_S) {
bullet_destroy(bullet);
}
}
void
bullet_table_draw(int timer)
{
for (int i = 0; i < MAX_BULLETS; ++i) {
if (bullet_table.bullets[i].active) {
bullet_draw(&bullet_table.bullets[i], timer);
}
}
}
void
bullet_draw(struct Bullet *bullet, int timer)
{
dsubimage(bullet->pos.x, bullet->pos.y, &img_bullet,
(timer / 2) % 2 * 6, 0, 6, 4, 0);
}
void
bullet_destroy(struct Bullet *bullet)
{
bullet->active = 0;
--bullet_table.n;
}
int
bullet_nb(void)
{
return bullet_table.n;
}

9
src/draw.c Normal file
View File

@ -0,0 +1,9 @@
#include <gint/display.h>
void
draw_rectangle(int x, int y, int w, int h, int c)
{
/* draw a rectangle at a given position (x, y) with a given size (w, h)
*/
drect(x, y, x + w - 1, y + h - 1, c);
}

64
src/hook.c Normal file
View File

@ -0,0 +1,64 @@
#include "hook.h"
#include "conf.h"
#include "level.h"
#include "player.h"
#include "tools.h"
#include <gint/display.h>
#include <stddef.h>
#include <stdlib.h>
static struct Hook_table hook_table = {.hooks = NULL};
static void hook_table_free(void);
void
hook_table_init(void)
{
hook_table_free();
hook_table.n = level_count(HOOK_T);
hook_table.hooks = malloc(hook_table.n * sizeof(struct Hook));
for (int i = 0; i < hook_table.n; ++i) {
hook_table.hooks[i].pos = level_search_s(HOOK_T, i + 1);
hook_table.hooks[i].pos.x =
hook_table.hooks[i].pos.x * TILE_S + TILE_S / 2;
hook_table.hooks[i].pos.y =
hook_table.hooks[i].pos.y * TILE_S + TILE_S / 2;
}
/*hook_table.hooks[0].pos = level_search_s(HOOK_T, 1);*/
}
void
hook_table_free(void)
{
if (hook_table.hooks != NULL) {
hook_table.hooks = NULL;
}
}
int
hook_nb(void)
{
return hook_table.n;
}
struct Vec2
hook_closest(struct Vec2 *pos)
{
/* search the closest hook */
struct Vec2 shortest = {0, 0};
if (hook_table.n) {
shortest = hook_table.hooks[0].pos;
float sh_dist = length(&shortest, pos);
for (int i = 0; i < hook_table.n; ++i) {
struct Hook h = hook_table.hooks[i];
const float dist = length(&h.pos, pos);
if (dist < sh_dist) {
shortest = h.pos;
sh_dist = dist;
}
}
}
shortest = (struct Vec2){shortest.x, shortest.y};
return shortest;
}

View File

@ -1,3 +1,5 @@
/* CODE FROM FISFOR */
#include "input.h"
#include <gint/keyboard.h>
@ -13,7 +15,6 @@ input_init(void)
input.keys[K_A] = KEY_SHIFT;
input.keys[K_B] = KEY_ALPHA;
input.keys[K_X] = KEY_OPTN;
input.keys[K_Y] = KEY_SQUARE;
input.keys[K_LEFT] = KEY_LEFT;
input.keys[K_RIGHT] = KEY_RIGHT;
input.keys[K_UP] = KEY_UP;

205
src/level.c Normal file
View File

@ -0,0 +1,205 @@
#include "level.h"
#include "conf.h"
#include "hook.h"
#include "player.h"
#include <gint/display.h>
#include <stdlib.h>
#include <string.h>
static struct Level level;
static void level_free(void);
static void level_load(void);
extern bopti_image_t img_tileset;
void
level_init(void)
{
level = (struct Level){
.w = 50,
.h = 28,
};
level.s = level.w * level.h;
level_free();
level_load();
hook_table_init();
player_init();
}
void
level_draw(void)
{
for (int m = 0; m < level.h; ++m) {
for (int n = 0; n < level.w; ++n) {
tile_t tile = level_get_tile(n, m);
dsubimage(n * TILE_S, m * TILE_S, &img_tileset,
((tile - 1) % TILESET_W) * TILE_S,
((tile - 1) / TILESET_W) * TILE_S, TILE_S,
TILE_S, 0);
/* dprint(n * TILE_S - camera.x, m * TILE_S - camera.y,
* C_BLACK, "%d", tile); */
}
}
}
tile_t
level_get_px(int x, int y)
{
return level.data[x / TILE_S + y / TILE_S * level.w];
}
tile_t
level_get_tile(int x, int y)
{
return level.data[x + y * level.w];
}
int
level_count(tile_t tile)
{
int i = 0;
for (int t = 0; t < level.h * level.w - 1; ++t) {
if (level.data[t] == tile) {
++i;
}
}
return i;
}
int
level_search_i(tile_t tile, int occ)
{
for (int t = 0; t < level.h * level.w - 1; ++t) {
if (level.data[t] == tile) {
if (!(occ - 1)) {
return t;
} else {
--occ;
}
}
}
return 0;
}
struct Vec2
level_search_s(tile_t tile, int occ)
{
for (int m = 0; m < level.h; ++m) {
for (int n = 0; n < level.w; ++n) {
if (level.data[n + m * level.w] == tile) {
if (!(occ - 1)) {
return (struct Vec2){n, m};
} else {
--occ;
}
}
}
}
return (struct Vec2){0, 0};
}
struct Vec2
level_get_dim(void)
{
return (struct Vec2){level.w, level.h};
}
static void
level_free(void)
{
level.data = (tile_t *)malloc(level.s * sizeof(tile_t));
}
static void
level_load(void)
{
/* TODO : LEVEL LOADING */
tile_t data[] = {
19, 21, 22, 22, 21, 20, 20, 21, 22, 19, 22, 20, 21, 21, 20, 22, 19,
20, 21, 21, 22, 21, 19, 21, 22, 20, 20, 21, 19, 19, 20, 19, 22, 21,
19, 22, 22, 19, 19, 20, 20, 22, 20, 20, 19, 20, 19, 22, 21, 20, 22,
19, 20, 20, 22, 22, 19, 19, 21, 21, 22, 22, 22, 20, 20, 22, 22, 21,
22, 21, 22, 22, 19, 20, 22, 21, 22, 22, 20, 21, 19, 19, 20, 22, 21,
19, 20, 22, 20, 19, 19, 20, 19, 20, 21, 22, 20, 21, 22, 21, 20, 21,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 19, 19, 19, 22, 17,
25, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 58,
0, 0, 0, 0, 0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58,
58, 0, 42, 42, 42, 42, 41, 42, 42, 26, 18, 19, 20, 20, 22, 17, 25,
42, 42, 42, 42, 58, 57, 58, 57, 58, 42, 42, 0, 0, 0, 0, 58, 0,
0, 0, 0, 0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58, 58,
0, 0, 0, 0, 0, 57, 0, 0, 26, 18, 22, 19, 20, 21, 17, 25, 0,
0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 41, 0, 0,
0, 0, 0, 0, 58, 57, 58, 57, 58, 57, 58, 57, 58, 57, 58, 0, 0,
0, 0, 42, 42, 41, 42, 42, 26, 18, 20, 20, 21, 22, 17, 25, 42, 42,
0, 41, 42, 41, 42, 41, 42, 41, 0, 0, 0, 0, 0, 58, 0, 0, 0,
0, 0, 41, 42, 41, 42, 42, 41, 42, 41, 42, 42, 41, 42, 41, 0, 0,
0, 0, 0, 57, 0, 0, 26, 18, 21, 21, 19, 22, 17, 25, 0, 0, 0,
0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0,
0, 0, 58, 0, 57, 58, 57, 58, 57, 58, 57, 0, 58, 0, 0, 0, 0,
0, 0, 57, 0, 0, 26, 18, 21, 20, 20, 19, 17, 25, 0, 0, 0, 0,
57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0,
0, 58, 58, 57, 58, 57, 58, 57, 58, 57, 58, 58, 0, 0, 0, 0, 0,
0, 57, 0, 0, 26, 18, 20, 20, 19, 22, 17, 25, 0, 0, 0, 0, 57,
58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0,
0, 0, 57, 58, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 26, 18, 22, 19, 22, 21, 17, 25, 0, 0, 0, 0, 57, 58,
57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41, 42, 41, 42, 41, 42, 41, 42, 9, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 26, 18, 22, 21, 19, 21, 17, 25, 0, 0, 0, 0, 57, 58, 57,
58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 57, 58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 26, 18, 21, 22, 22, 21, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58,
57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58,
57, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26, 18, 21, 19, 19, 19, 17, 25, 0, 0, 0, 0, 57, 58, 57, 58, 57,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57,
58, 57, 58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26,
18, 21, 21, 20, 20, 35, 44, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58,
57, 58, 57, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18,
22, 20, 20, 22, 51, 60, 0, 0, 0, 0, 57, 58, 57, 58, 57, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 57,
58, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 18, 22,
21, 22, 21, 51, 60, 58, 58, 0, 41, 42, 41, 42, 41, 42, 41, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 42, 41, 42, 41,
42, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 36, 22, 22,
21, 21, 3, 3, 3, 3, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 52, 22, 20, 22,
19, 19, 4, 4, 4, 0, 0, 58, 57, 58, 57, 58, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 58, 59, 52, 20, 19, 22, 21,
17, 25, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 33, 34, 34, 34,
34, 33, 34, 34, 33, 0, 1, 1, 2, 0, 58, 57, 58, 57, 58, 0, 2,
1, 1, 0, 33, 34, 34, 33, 34, 34, 34, 34, 34, 19, 20, 20, 20, 35,
44, 0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 49, 50, 50, 50, 50,
49, 58, 58, 57, 0, 41, 27, 17, 2, 3, 3, 3, 3, 3, 2, 18, 27,
41, 0, 57, 58, 58, 49, 50, 50, 50, 50, 18, 19, 21, 20, 21, 51, 60,
0, 0, 0, 0, 58, 57, 58, 57, 58, 0, 0, 49, 50, 50, 50, 50, 49,
58, 58, 57, 0, 41, 2, 2, 19, 19, 3, 2, 3, 19, 19, 2, 2, 41,
0, 57, 58, 58, 49, 50, 50, 50, 50, 18, 20, 20, 22, 19, 51, 60, 58,
58, 0, 0, 58, 57, 58, 57, 33, 34, 34, 33, 34, 34, 34, 34, 33, 42,
42, 42, 0, 0, 26, 19, 19, 19, 19, 4, 19, 19, 19, 19, 25, 0, 0,
41, 41, 42, 33, 34, 34, 34, 34, 34, 22, 21, 20, 20, 3, 3, 3, 3,
3, 3, 58, 57, 58, 57, 49, 50, 50, 49, 50, 50, 50, 50, 49, 58, 58,
57, 0, 0, 0, 18, 4, 4, 4, 4, 4, 4, 4, 17, 0, 0, 0, 57,
58, 58, 49, 50, 50, 50, 50, 18, 20, 19, 19, 19, 19, 20, 19, 19, 19,
17, 58, 57, 58, 57, 49, 50, 50, 49, 50, 50, 50, 50, 49, 58, 58, 57,
0, 0, 0, 0, 49, 50, 58, 57, 58, 50, 49, 0, 0, 0, 0, 57, 57,
58, 49, 50, 50, 50, 50, 18, 20, 21, 19, 21, 21, 22, 20, 20, 19, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 20, 20, 20, 20, 19, 20, 21, 21, 22, 19, 20,
22, 20, 22, 22, 19, 19, 22, 21, 19, 22, 20, 21, 21, 20, 21, 19, 19,
19, 20, 20, 22, 22, 21, 22, 21, 20, 22, 21, 19, 19, 19, 21, 19, 19,
22, 20, 21, 19, 22, 22, 22, 21, 20, 19, 22, 20, 22, 19, 22, 20, 20,
19, 21, 21, 22, 19, 19, 22, 21, 19, 22, 20, 22, 20, 22, 20, 22, 20,
19, 20, 21, 20, 19, 20, 22, 22, 22, 19, 19, 20, 21, 21, 19, 20, 19,
21, 19, 21, 21, 22, 19};
memcpy(level.data, data, sizeof(data));
}

View File

@ -1,225 +1,57 @@
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/std/string.h>
#include <stdlib.h>
#include "input.h"
#include "main.h"
#include "bullet.h"
#include "draw.h"
#include "hook.h"
#include "input.h"
#include "level.h"
#include "player.h"
static int running = 1;
static int timer = 0;
static void init(void);
static void update(void);
static void draw(void);
int
main(void)
{
extern bopti_image_t img_tileset;
Level level = {
.width = 50,
.height = 28,
};
/* dynamic level size */
level.data =
(tile_t *)malloc(level.width * level.height * sizeof(tile_t));
tile_t data[] = {
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 50, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 49, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 14, 14, 14, 14, 26, 26, 26,
26, 26, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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, 2, 2,
6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 2, 2, 2, 2, 37, 14, 14, 14, 14, 14, 14, 14, 14, 18,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 18, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 13,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 18, 13, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 18, 13, 14,
14, 14, 14, 14, 14, 14};
memcpy(level.data, data, sizeof(data));
input_init();
Player player = {.pos = {50, 50}, .spawn = {0, 0}, .spd = {0, 0}};
Vec2 camera = {0, 0};
int running = 1;
int jumping = 1;
int airbreak = 1;
int coyote = 0;
init();
while (running) {
update();
draw();
/* camera thing */
dclear(C_WHITE);
camera.x = player.pos.x - 190;
if (camera.x < 2) {
camera.x = 2;
}
if (camera.x > level.width * TILE_S - 398) {
camera.x = level.width * TILE_S - 398;
}
camera.y = player.pos.y - 104;
if (camera.y < 0) {
camera.y = 0;
}
if (camera.y > level.height * TILE_S - 224) {
camera.y = level.height * TILE_S - 224;
}
/* tiles */
for (int m = 0; m < level.height; ++m) {
for (int n = 0; n < level.width; ++n) {
tile_t tile = level.data[n + m * level.width];
dsubimage(n * TILE_S - camera.x,
m * TILE_S - camera.y, &img_tileset,
((tile - 1) % TILESET_W) * TILE_S,
((tile - 1) / TILESET_W) * TILE_S,
TILE_S, TILE_S, 0);
/* dprint(n * TILE_S - camera.x, m * TILE_S -
camera.y, C_BLACK, "%d", tile); */
}
}
drect(player.pos.x - camera.x, player.pos.y - camera.y,
player.pos.x + PLAYER_SIZE - camera.x - 1,
player.pos.y + PLAYER_SIZE - camera.y - 1, C_BLACK);
dprint(10, 10, C_BLACK, "%d", jumping);
/* input */
input_step();
Vec2 mov = {
.x = input_down(K_RIGHT) - input_down(K_LEFT),
.y = 0,
};
/* on the ground */
if (collide((Vec2){player.pos.x, player.pos.y + 1}, 0, 1,
level)) {
jumping = 0;
airbreak = 0;
coyote = COYOTE_TIME;
} else {
--coyote;
}
/* JUMP */
if (input_pressed(K_A) && coyote > 0) {
player.spd.y = -JUMP_H;
jumping = 2;
coyote = 0;
airbreak = 0;
}
/* airbreak */
if (!airbreak && (!input_down(K_A) || player.spd.y > 0)) {
airbreak = 1;
}
/* moving */
player.spd.x *= (1 - BASE_FRIC); /* friction */
player.spd.x += mov.x * PLAYER_ACC; /* idem */
player.spd.y += GRAVITY + (GRAVITY * airbreak); /* gravity */
if (player.spd.x > -0.2 && player.spd.x < 0.2) {
player.spd.x = 0;
}
if (player.spd.y > -0.2 && player.spd.y < 0.2) {
player.spd.y = 0;
}
Res_Mov position = move(player, level); /* i'm crying rn */
player = position.player;
/* if the player collide with a wall */
if (position.moved.x) {
player.spd.x = 0;
}
if (position.moved.y) {
player.spd.y = 0;
}
/* exit */
if (input_pressed(K_EXIT)) {
break;
running = 0;
}
dupdate();
}
return 1;
}
static void
init(void)
{
input_init();
level_init();
bullet_table_init();
}
static void
update(void)
{
input_step();
player_update();
bullet_table_update();
++timer;
}
static void
draw(void)
{
dclear(C_BLACK);
level_draw();
player_draw(timer);
bullet_table_draw(timer);
dupdate();
}

View File

@ -1,143 +1,308 @@
#include <gint/display.h>
#include "player.h"
#include "bullet.h"
#include "conf.h"
#include "draw.h"
#include "hook.h"
#include "input.h"
#include "level.h"
#include "tools.h"
#include <math.h>
#include <stdlib.h>
int
sign(int n)
static int k_up, k_down, k_left, k_right, k_jump, k_jumpdown, k_hook, k_fire;
static struct Player player;
static void player_get_input(void);
static void player_move(struct Vec2 spd);
static void player_hook(void);
static void player_hook_draw(void);
static int player_update_frame(int timer);
static struct Vec2 player_update_rem();
static int player_collide_pixel(int x, int y, tile_t id);
static int player_collide(struct Vec2 pos, tile_t id, int h);
extern bopti_image_t img_scarletR;
extern bopti_image_t img_scarletL;
extern bopti_image_t img_hooksel;
struct Vec2
player_get_pos(void)
{
/* I do not know well C lmao */
return player.pos;
}
if (n > 0) {
return 1;
} else {
return -1;
void
player_init(void)
{
player.pos = (struct Vec2){160, 100};
player.spd = (struct FVec2){0.0f, 0.0f};
player.rem = (struct FVec2){0.0f, 0.0f};
player.jumping = 1;
player.airbreak = 1;
player.hooking = 0;
player.locked = 0;
player.dir = 1;
player.hook_pos = (struct Vec2){0, 0};
player.hook_near = hook_closest(&player.pos);
}
void
player_update(void)
{
/* input and air movement */
player_get_input();
const int dir = k_right - k_left;
if (player.jumping && (!k_jumpdown || player.spd.y > 0)) {
player.airbreak = 1;
}
if (k_jump && !player.jumping) {
player.spd.y = -PLAYER_JUMP;
player.jumping = 1;
player.airbreak = 0;
}
/* hooking */
player_hook();
if (!player.hooking) {
player.spd.x *= (1 - PLAYER_FRIC);
player.spd.x += dir * PLAYER_ACC;
}
player.spd.y +=
GRAVITY + GRAVITY * (player.airbreak && !player.hooking);
/* applying movement */
player_move(player_update_rem());
if (player_collide((struct Vec2){player.pos.x, player.pos.y + 1}, 1,
0)) {
player.jumping = 0;
}
/* shooting */
if (k_fire) {
bullet_fire(player.pos.x, player.pos.y,
(dir ? dir : player.dir) * 6);
}
}
Vec2
search(tile_t x, Level level)
void
player_hook(void)
{
/* Search for x in a given matrix. */
/* If x is found, return it coordinates */
Vec2 coordinates = {0, 0};
for (int m = 0; m < level.width; ++m) {
for (int n = 0; n < level.height; ++n) {
if (level.data[m + n * level.width] == x) {
coordinates.x = m * TILE_S;
coordinates.y = n * TILE_S;
return coordinates;
player.hooking = 0;
struct Vec2 player_middle = {player.pos.x + PLAYER_S / 2,
player.pos.y + PLAYER_S / 2};
player.hook_near = hook_closest(&player_middle);
if (k_hook) {
/* get the nearest hook */
if (!player.locked) {
player.hook_pos = player.hook_near;
}
const float dist = length(&player_middle, &player.hook_pos);
/* if the nearest hook is in range */
if (dist < 100 && player_middle.y > player.hook_pos.y) {
player.hooking = 1;
player.locked = 1;
player.jumping = 1;
}
if (player.hooking && dist) {
/* determining hook force */
float dist_x = player.hook_pos.x - player_middle.x;
float dist_y = player.hook_pos.y - player_middle.y;
struct FVec2 force = {};
force.x = dist_x / dist;
force.y = dist_y / dist;
/* apply hook force */
player.spd.x += force.x;
player.spd.y += force.y;
/* cap speed */
if (abs(player.spd.x) > 16) {
player.spd.x = 16 * sign(player.spd.x);
}
if (abs(player.spd.y) > 16) {
player.spd.y = 16 * sign(player.spd.y);
}
}
} else {
/* unbind the player from the hook */
player.locked = 0;
}
}
void
player_draw(int timer)
{
const int frame = player_update_frame(timer);
if (player.dir == 1) {
dsubimage(player.pos.x - 5, player.pos.y - 5, &img_scarletR,
frame * PLAYER_W, 0, PLAYER_W, PLAYER_H, 0);
} else {
dsubimage(player.pos.x - 5, player.pos.y - 5, &img_scarletL,
frame * PLAYER_W, 0, PLAYER_W, PLAYER_H, 0);
}
/* draw_rectangle(player.pos.x, player.pos.y, PLAYER_S, PLAYER_S,
* C_WHITE); */
player_hook_draw();
}
int
player_update_frame(int timer)
{
if (player.hooking) {
return 5;
}
if (player.jumping && player.spd.y <= 0) {
return 2;
}
if (player.jumping && player.spd.y > 0) {
return 3;
}
if (abs(player.spd.x) > 0) {
return (6 + (timer / 2) % 8);
}
return ((timer / 60) % 2);
}
void
player_hook_draw(void)
{
struct Vec2 player_middle = {player.pos.x + PLAYER_S / 2,
player.pos.y + PLAYER_S / 2};
if (length(&player_middle, &player.hook_near) < 100 &&
player_middle.y > player.hook_near.y) {
dimage(player.hook_near.x - 5, player.hook_near.y - 5,
&img_hooksel);
};
if (player.hooking) {
dline(player.pos.x + PLAYER_S / 2, player.pos.y + 7,
player.hook_pos.x, player.hook_pos.y, C_RED);
}
}
static void
player_get_input(void)
{
k_up = input_down(K_UP);
k_down = input_down(K_DOWN);
k_left = input_down(K_LEFT);
k_right = input_down(K_RIGHT);
k_jump = input_pressed(K_A);
k_jumpdown = input_down(K_A);
k_hook = input_down(K_B);
k_fire = input_pressed(K_X);
}
static struct Vec2
player_update_rem(void)
{
struct FVec2 spdrem = (struct FVec2){player.spd.x + player.rem.x,
player.spd.y + player.rem.y};
struct Vec2 ispd = (struct Vec2){spdrem.x, spdrem.y};
player.rem.x = spdrem.x - (float)ispd.x;
player.rem.y = spdrem.y - (float)ispd.y;
return ispd;
}
static void
player_move(struct Vec2 spd)
{
if (player_collide(player.pos, 1, 0)) {
return;
}
/* OOB */
const struct Vec2 level_dim = level_get_dim();
if (spd.x) {
const int sign_x = sign(spd.x);
player.dir = sign_x;
player.pos.x += spd.x;
if (player.pos.x < 0) {
player.pos.x = 1;
}
if (player.pos.x > level_dim.x * TILE_S) {
player.pos.x = level_dim.x * TILE_S - 1;
}
if (player_collide(player.pos, 1, 0)) {
player.spd.x = 0.0f;
player.rem.x = 0.0f;
while (player_collide(player.pos, 1, 0)) {
player.pos.x -= sign_x;
}
}
}
return coordinates;
}
int
convert_all(tile_t x, tile_t y, Level level)
{
/* convert all instance of a tile */
for (int i = 0; i < level.width * level.height; ++i) {
if (level.data[i] == x) {
level.data[i] = y;
if (spd.y) {
const int sign_y = sign(spd.y);
player.pos.y += spd.y;
if (player.pos.y < 0) {
player.pos.y = 1;
}
if (player.pos.y > level_dim.y * TILE_S) {
player.pos.y = level_dim.y * TILE_S - 1;
}
if (player_collide(player.pos, 1, 0)) {
player.spd.y = 0.0f;
player.rem.y = 0.0f;
while (player_collide(player.pos, 1, 0)) {
player.pos.y -= sign_y;
}
}
}
return 1;
}
int
collide_pixel(Vec2 pos, tile_t obj, Level level)
static int
player_collide_pixel(int x, int y, tile_t id)
{
/* Check if there's something in (x, y) */
const int position = pos.x / TILE_S + pos.y / TILE_S * level.width;
const int uwu = level.data[position];
const tile_t tile = level_get_px(x, y);
if (position < 0 || position > level.width * level.height || uwu == 0) {
if (!tile) {
return 0;
}
/* others */
if (obj != 1) {
if (uwu == obj) {
return position;
} else {
return 0;
}
if (id == 1) {
return (tile - 1) % TILESET_W < 8;
}
/* solids */
if ((uwu - 1) % TILESET_W <= 6) {
return 1;
} else {
return 0;
}
return tile == id;
}
int
collide(Vec2 pos, int h, tile_t obj, Level level)
static int
player_collide(struct Vec2 pos, tile_t id, int h)
{
/* tl = top left */
/* br = bottom right */
const Vec2 pos_tl = (Vec2){pos.x + h, pos.y + h};
const Vec2 pos_br =
(Vec2){pos.x + PLAYER_SIZE - h - 1, pos.y + PLAYER_SIZE - h - 1};
const Vec2 middle =
(Vec2){pos.x + PLAYER_SIZE / 2, pos.y + PLAYER_SIZE / 2};
/* Check if there's something in */
/* the square (x, y, x + 15, y + 15) */
/* The size of the hitbox changes with h */
const struct Vec2 pos_tl = (struct Vec2){pos.x + h, pos.y + h};
const struct Vec2 pos_br =
(struct Vec2){pos.x + PLAYER_S - h - 1, pos.y + PLAYER_S - h - 1};
const struct Vec2 middle =
(struct Vec2){pos.x + PLAYER_S / 2, pos.y + PLAYER_S / 2};
if (collide_pixel(pos_tl, obj, level) ||
collide_pixel(pos_br, obj, level) ||
collide_pixel((Vec2){pos_tl.x, pos_br.y}, obj, level) ||
collide_pixel((Vec2){pos_br.x, pos_tl.y}, obj, level) ||
collide_pixel((Vec2){middle.x, pos_tl.y}, obj, level) ||
collide_pixel((Vec2){middle.x, pos_br.y}, obj, level) ||
collide_pixel((Vec2){pos_tl.x, middle.y}, obj, level) ||
collide_pixel((Vec2){pos_br.x, middle.y}, obj, level)) {
if (player_collide_pixel(pos_tl.x, pos_tl.y, id) ||
player_collide_pixel(pos_br.x, pos_br.y, id) ||
player_collide_pixel(pos_tl.x, pos_br.y, id) ||
player_collide_pixel(pos_br.x, pos_tl.y, id) ||
player_collide_pixel(middle.x, pos_tl.y, id) ||
player_collide_pixel(middle.x, pos_br.y, id) ||
player_collide_pixel(pos_tl.x, middle.y, id) ||
player_collide_pixel(pos_br.x, middle.y, id)) {
return 1;
}
return 0;
}
Res_Mov
move(Player player, Level level)
{
/* move the player */
Vec2 moved = {0, 0};
if (player.spd.x == 0 && player.spd.y == 0) {
return (Res_Mov){player, moved};
}
int Ispd_x = player.spd.x;
player.pos.x += Ispd_x;
if (collide(player.pos, 0, 1, level)) {
float sign_x = sign(player.spd.x);
while (collide(player.pos, 0, 1, level) == 1) {
player.pos.x -= sign_x;
}
moved.x = 1;
}
int Ispd_y = player.spd.y;
player.pos.y += Ispd_y;
if (collide(player.pos, 0, 1, level)) {
float sign_y = sign(player.spd.y);
while (collide(player.pos, 0, 1, level) == 1) {
player.pos.y -= sign_y;
}
moved.y = 1;
}
return (Res_Mov){player, moved};
}
Player
player_reset(Player player, Level level)
{
/* reset the level */
player.spawn = search(52, level);
player.pos = player.spawn;
player.spd = (FVec2){0, 0};
return player;
}

18
src/tools.c Normal file
View File

@ -0,0 +1,18 @@
#include "tools.h"
#include <math.h>
#include <stdlib.h>
int
sign(int x)
{
return (x > 0) - (x < 0); /* from jtmm2 */
}
int
length(struct Vec2 *a, struct Vec2 *b)
{
const int dist_x = abs(a->x - b->x);
const int dist_y = abs(a->y - b->y);
const float dist = sqrt(dist_x * dist_x + dist_y * dist_y);
return dist;
}

11
src/type.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
typedef int tile_t;
typedef struct Vec2 {
int x, y;
} Vec2;
typedef struct FVec2 {
float x, y;
} FVec2;