drawing walls

This commit is contained in:
Masséna Fezard | Nounouille 2021-03-08 08:16:10 +01:00
parent fba8ac8e52
commit c1001437b2
6 changed files with 39 additions and 2 deletions

View File

@ -11,6 +11,7 @@ find_package(Gint 2.1 REQUIRED)
set(SOURCES
src/main.c
src/levels.c
# ...
)
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
@ -23,6 +24,7 @@ set(ASSETS_fx
)
set(ASSETS_cg
assets-cg/img/player.png
assets-cg/img/wall.png
# ...
)

View File

@ -1,3 +1,7 @@
player.png:
type: bopti-image
name: img_player
name: img_player
wall.png:
type: bopti-image
name: img_wall

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 145 B

BIN
assets-cg/img/wall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

18
src/levels.c Normal file
View File

@ -0,0 +1,18 @@
const int level[16][16] = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 0, 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, 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, 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
};

View File

@ -4,6 +4,9 @@
int main(void)
{
extern bopti_image_t img_player;
extern bopti_image_t img_wall;
extern int level[16][16];
int running = 1;
@ -15,12 +18,22 @@ int main(void)
while(running) {
dclear(C_BLACK);
// drawing the player
dimage(player_x, player_y, &img_player);
// drawing the level
for(int m = 0; m < 16; ++m){
for(int n = 0; n < 16; ++n){
if(level[m][n]) {
dimage(m * 12, n * 12, &img_wall);
}
}
}
dupdate();
clearevents();
// trying to move the player >w<
player_x += keydown(KEY_RIGHT) - keydown(KEY_LEFT);
player_y += keydown(KEY_DOWN) - keydown(KEY_UP);