Compare commits
5 commits
fab0cfb277
...
3a5adfac64
Author | SHA1 | Date | |
---|---|---|---|
|
3a5adfac64 | ||
|
ce0a319a52 | ||
|
0d363f0c8d | ||
|
9e65d04d22 | ||
|
1084917cb6 |
|
@ -11,13 +11,16 @@ find_package(Gint 2.9 REQUIRED)
|
||||||
find_package(LibProf 2.1 REQUIRED)
|
find_package(LibProf 2.1 REQUIRED)
|
||||||
|
|
||||||
# le nom de votre jeu
|
# le nom de votre jeu
|
||||||
set(NAMEOFGAME "Test3D")
|
set(NAMEOFGAME "Illusion3D")
|
||||||
# Nom de l'auteur -> votre nom/pseudo
|
# Nom de l'auteur -> votre nom/pseudo
|
||||||
set(AUTHOR "Fcalva")
|
set(AUTHOR "Fcalva")
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
#sources de votre jeu
|
#sources du jeu
|
||||||
src/main.c
|
src/main.c
|
||||||
|
src/gfx.c
|
||||||
|
src/map.c
|
||||||
|
src/game.c
|
||||||
#sources du moteur
|
#sources du moteur
|
||||||
eng/moteur.c
|
eng/moteur.c
|
||||||
eng/map.c
|
eng/map.c
|
||||||
|
@ -27,15 +30,33 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
set(ASSETS
|
set(ASSETS
|
||||||
assets-fx/sprite.png
|
assets-fx/title.png
|
||||||
|
assets-fx/blood.png
|
||||||
|
|
||||||
|
assets-fx/hands0.png
|
||||||
|
assets-fx/hands1.png
|
||||||
|
assets-fx/hands2.png
|
||||||
|
assets-fx/anvil0.png
|
||||||
|
assets-fx/anvil1.png
|
||||||
|
assets-fx/anvil2.png
|
||||||
|
assets-fx/anvil3.png
|
||||||
|
|
||||||
|
assets-fx/sprites/friendlyguy.png
|
||||||
|
assets-fx/sprites/friendlyguy1.png
|
||||||
|
assets-fx/sprites/anvil_pickup.png
|
||||||
|
|
||||||
assets-fx/textures/briques0.png
|
assets-fx/textures/briques0.png
|
||||||
assets-fx/textures/buisson1.png
|
assets-fx/textures/buisson1.png
|
||||||
|
assets-fx/textures/bwain.png
|
||||||
|
assets-fx/textures/bwain1.png
|
||||||
|
assets-fx/textures/meat.png
|
||||||
|
assets-fx/textures/meat1.png
|
||||||
)
|
)
|
||||||
|
|
||||||
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
fxconv_declare_assets(${ASSETS} WITH_METADATA)
|
||||||
|
|
||||||
add_executable(Copy3DEngine ${SOURCES} ${ASSETS})
|
add_executable(Copy3DEngine ${SOURCES} ${ASSETS})
|
||||||
target_compile_options(Copy3DEngine PRIVATE -Wall -Wextra -Ofast)
|
target_compile_options(Copy3DEngine PRIVATE -Wall -Wextra -O2)
|
||||||
target_include_directories(Copy3DEngine PRIVATE "include/")
|
target_include_directories(Copy3DEngine PRIVATE "include/")
|
||||||
target_compile_definitions(Copy3DEngine PRIVATE NAMEOFGAME="${NAMEOFGAME}" AUTHOR="${AUTHOR}")
|
target_compile_definitions(Copy3DEngine PRIVATE NAMEOFGAME="${NAMEOFGAME}" AUTHOR="${AUTHOR}")
|
||||||
target_link_libraries(Copy3DEngine Gint::Gint)
|
target_link_libraries(Copy3DEngine Gint::Gint)
|
||||||
|
@ -44,8 +65,8 @@ target_link_options(Copy3DEngine PRIVATE -Wl,--print-memory-usage)
|
||||||
|
|
||||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
|
||||||
generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a"
|
generate_g1a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g1a"
|
||||||
NAME ${NAMEOFGAME} ICON assets-fx/icon.png)
|
NAME "Illu3D" ICON assets-fx/icon.png)
|
||||||
else()
|
else()
|
||||||
generate_g3a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g3a"
|
generate_g3a(TARGET Copy3DEngine OUTPUT ${NAMEOFGAME}".g3a"
|
||||||
NAME ${NAMEOFGAME} ICONS assets-fx/icon.png assets-fx/icon.png)
|
NAME "Illu3D" ICONS assets-fx/icon.png assets-fx/icon.png)
|
||||||
endif()
|
endif()
|
||||||
|
|
12
README.md
|
@ -1,8 +1,8 @@
|
||||||
# Copy3DEngine
|
### Illusion 3D, ma participation au CPC #31
|
||||||
|
Je ne recommande pas de prendre ce code comme base de quoi que ce soit :E
|
||||||
|
|
||||||
Un moteur de raycasting, fork de Maze3D, avec le but de faciliter la création de jeux de style <insérer nom ici> 3D
|
Tout est sous license GPLv3, assets inclus
|
||||||
|
|
||||||
### Utiliser
|
Dépendances :
|
||||||
|
- gint
|
||||||
Pour faire votre propre jeu, vous avez juste à changer le nom du jeu dans CMakeLists.txt, inclure vos propres assets dans assets-cg/ et les inclure dans main.c.
|
- libprof
|
||||||
Vous pouvez aussi éditer la carte dans map.c, et sa taille dans map.h
|
|
||||||
|
|
BIN
assets-fx/2bpp_palette.png
Normal file
After Width: | Height: | Size: 77 B |
BIN
assets-fx/anvil0.png
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
assets-fx/anvil1.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
assets-fx/anvil2.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
assets-fx/anvil3.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
assets-fx/blood.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
|
@ -1,4 +1,37 @@
|
||||||
sprite.png:
|
hands0.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: sprite_tst
|
|
||||||
profile: gray_alpha
|
profile: gray_alpha
|
||||||
|
name: hands0
|
||||||
|
hands1.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: hands1
|
||||||
|
hands2.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: hands2
|
||||||
|
|
||||||
|
anvil0.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: anvil0
|
||||||
|
anvil1.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: anvil1
|
||||||
|
anvil2.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: anvil2
|
||||||
|
anvil3.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: anvil3
|
||||||
|
|
||||||
|
blood.png:
|
||||||
|
type: bopti-image
|
||||||
|
profile: gray_alpha
|
||||||
|
name: blood
|
||||||
|
title.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: title
|
||||||
|
|
BIN
assets-fx/hands0.png
Normal file
After Width: | Height: | Size: 944 B |
BIN
assets-fx/hands1.png
Normal file
After Width: | Height: | Size: 998 B |
BIN
assets-fx/hands2.png
Normal file
After Width: | Height: | Size: 1,015 B |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 642 B |
BIN
assets-fx/sprites/anvil_pickup.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
assets-fx/sprites/friendlyguy.png
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
assets-fx/sprites/friendlyguy1.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
13
assets-fx/sprites/fxconv-metadata.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
friendlyguy.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: sprite_tst
|
||||||
|
profile: gray_alpha
|
||||||
|
friendlyguy1.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: sprite_tst1
|
||||||
|
profile: gray_alpha
|
||||||
|
|
||||||
|
anvil_pickup.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: anvil_pick
|
||||||
|
profile: gray_alpha
|
BIN
assets-fx/textures/bwain.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
assets-fx/textures/bwain1.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
|
@ -5,3 +5,17 @@ briques0.png:
|
||||||
buisson1.png:
|
buisson1.png:
|
||||||
type: bopti-image
|
type: bopti-image
|
||||||
name: buisson0
|
name: buisson0
|
||||||
|
|
||||||
|
bwain.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: bwain0
|
||||||
|
bwain1.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: bwain1
|
||||||
|
|
||||||
|
meat.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: meat0
|
||||||
|
meat1.png:
|
||||||
|
type: bopti-image
|
||||||
|
name: meat1
|
||||||
|
|
BIN
assets-fx/textures/meat.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
assets-fx/textures/meat1.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
assets-fx/title.png
Normal file
After Width: | Height: | Size: 1,016 B |
66
eng/map.c
|
@ -5,69 +5,3 @@
|
||||||
#include "C3D/map.h"
|
#include "C3D/map.h"
|
||||||
#include "C3D/moteur.h"
|
#include "C3D/moteur.h"
|
||||||
|
|
||||||
uint8_t __attribute__((section(".rodata"))) map_test[map_w][map_h] = {
|
|
||||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3},
|
|
||||||
{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,1,0,1,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,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,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,2,0,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1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
|
|
||||||
};
|
|
||||||
|
|
13
eng/moteur.c
|
@ -27,8 +27,8 @@ fixed_t zbuf[viewport_w];
|
||||||
|
|
||||||
void move(RcGame *game) {
|
void move(RcGame *game) {
|
||||||
extern int frame_time;
|
extern int frame_time;
|
||||||
fixed_t moveSpeed = fmul(fix(frame_time)/1000, 0x148); //frame_time * fix(carrés/seconde/1000) là carrés/seconde = 5
|
fixed_t moveSpeed = fmul(fix(frame_time/1000), 0x148); //frame_time * fix(carrés/seconde/1000) là carrés/seconde = 5
|
||||||
fixed_t rotSpeed = fmul(fix(frame_time)/1000, 0x83); //frame_time * fix(radians/seconde/1000) là radians/seconde = 2
|
fixed_t rotSpeed = fmul(fix(frame_time/1000), 0x83); //frame_time * fix(radians/seconde/1000) là radians/seconde = 2
|
||||||
fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed)));
|
fixed_t c_rotSpeed = fix(cos(f2float(rotSpeed)));
|
||||||
fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed)));
|
fixed_t s_rotSpeed = fix(sin(f2float(rotSpeed)));
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ void move(RcGame *game) {
|
||||||
V2d *plane = &game->player.plane;
|
V2d *plane = &game->player.plane;
|
||||||
V2d *dir = &game->player.dir;
|
V2d *dir = &game->player.dir;
|
||||||
V2d *pos = &game->player.pos;
|
V2d *pos = &game->player.pos;
|
||||||
|
int map_w = game->current_map->w;
|
||||||
|
int map_h = game->current_map->h;
|
||||||
|
|
||||||
fixed_t oldDirX;
|
fixed_t oldDirX;
|
||||||
fixed_t oldPlaneX;
|
fixed_t oldPlaneX;
|
||||||
|
@ -116,7 +118,7 @@ inline int __attribute__((always_inline))
|
||||||
if(layers > 2){
|
if(layers > 2){
|
||||||
alpha = !(layer_ptr[2] & mask);
|
alpha = !(layer_ptr[2] & mask);
|
||||||
}
|
}
|
||||||
return (alpha << 2) + (dark << 1) + light;
|
return (alpha << 2) | (dark << 1) | light;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *light, *dark;
|
uint32_t *light, *dark;
|
||||||
|
@ -151,6 +153,7 @@ inline void __attribute__((always_inline))
|
||||||
light[offset] |= mask;
|
light[offset] |= mask;
|
||||||
dark [offset] |= mask;
|
dark [offset] |= mask;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case C_NONE:
|
case C_NONE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -221,6 +224,8 @@ void draw_walls(
|
||||||
fixed_t planeY = game->player.plane.y;
|
fixed_t planeY = game->player.plane.y;
|
||||||
extern bopti_image_t *tex_index[TINDEX_S];
|
extern bopti_image_t *tex_index[TINDEX_S];
|
||||||
uint8_t *map_test = game->current_map->dat;
|
uint8_t *map_test = game->current_map->dat;
|
||||||
|
int map_w = game->current_map->w;
|
||||||
|
int map_h = game->current_map->h;
|
||||||
|
|
||||||
fixed_t cameraX;
|
fixed_t cameraX;
|
||||||
fixed_t rayDirX;
|
fixed_t rayDirX;
|
||||||
|
@ -375,7 +380,7 @@ void draw_walls(
|
||||||
texSampleY = 0;
|
texSampleY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int linePos = viewport_h/2 - lineHeight/2;
|
int linePos = viewport_h/2 - lineHeight/2 + game->flags.v_offset;
|
||||||
|
|
||||||
bopti_image_t *tex = tex_index[map_test[mapX*map_w+mapY]];
|
bopti_image_t *tex = tex_index[map_test[mapX*map_w+mapY]];
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <gint/gray.h>
|
#include <gint/gray.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "C3D/fixed.h"
|
#include "C3D/fixed.h"
|
||||||
#include "C3D/game.h"
|
#include "C3D/game.h"
|
||||||
|
@ -16,7 +17,7 @@
|
||||||
|
|
||||||
extern fixed_t zbuf[viewport_w];
|
extern fixed_t zbuf[viewport_w];
|
||||||
|
|
||||||
int spritec;
|
int spritec = 0;
|
||||||
|
|
||||||
Sprite *sprite_index[SINDEX_S];
|
Sprite *sprite_index[SINDEX_S];
|
||||||
|
|
||||||
|
@ -30,8 +31,19 @@ void clear_sprites(){
|
||||||
spritec = 0;
|
spritec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_sprite(GUNUSED Sprite *sprite){
|
int remove_sprite(Sprite *sprite){
|
||||||
//TODO
|
if(!sprite)
|
||||||
|
return 0;
|
||||||
|
int pos = -1;
|
||||||
|
for(int i = 0; i < spritec; i++){
|
||||||
|
if(sprite == sprite_index[i]){
|
||||||
|
pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pos < 0)
|
||||||
|
return 1;
|
||||||
|
memmove(&sprite_index[pos], &sprite_index[pos+1], sizeof(void*) * (spritec-pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Lodev's sprite projection, translated to use my functions and fixed point
|
//Lodev's sprite projection, translated to use my functions and fixed point
|
||||||
|
@ -77,7 +89,7 @@ void project_sprite(bopti_image_t *tex_index[], Sprite *sprite, RcActor *player)
|
||||||
fixed_t sprite_size = fdiv(fix(sprite_w), fix(TSIZE));
|
fixed_t sprite_size = fdiv(fix(sprite_w), fix(TSIZE));
|
||||||
|
|
||||||
for(int x = sprite_pos_x; x < sprite_end_x; x++){
|
for(int x = sprite_pos_x; x < sprite_end_x; x++){
|
||||||
if(ty < 0 || x < 0 || ty > zbuf[x])
|
if(ty < fix(0.4) || x < 0 || ty > zbuf[x])
|
||||||
continue;
|
continue;
|
||||||
if(x > viewport_w)
|
if(x > viewport_w)
|
||||||
break;
|
break;
|
||||||
|
@ -100,10 +112,10 @@ int sprite_cmpfnc(const void *p1, const void *p2){
|
||||||
void draw_sprites(bopti_image_t *tex_index[], RcActor *player){
|
void draw_sprites(bopti_image_t *tex_index[], RcActor *player){
|
||||||
struct SpriteDist dists[SINDEX_S];
|
struct SpriteDist dists[SINDEX_S];
|
||||||
memset(dists, 0, sizeof(struct SpriteDist)*SINDEX_S);
|
memset(dists, 0, sizeof(struct SpriteDist)*SINDEX_S);
|
||||||
|
|
||||||
for(int i = 0; i < spritec; i++){
|
for(int i = 0; i < spritec; i++){
|
||||||
Sprite *spr = sprite_index[i];
|
Sprite *spr = sprite_index[i];
|
||||||
fixed_t d = player->pos.x - spr->pos.x;
|
fixed_t d = fmul(player->pos.x - spr->pos.x, player->pos.x - spr->pos.x);
|
||||||
d = fmul(d,d);
|
|
||||||
d += fmul(player->pos.y - spr->pos.y,player->pos.y - spr->pos.y);
|
d += fmul(player->pos.y - spr->pos.y,player->pos.y - spr->pos.y);
|
||||||
dists[i].dist = d;
|
dists[i].dist = d;
|
||||||
dists[i].id = i;
|
dists[i].id = i;
|
||||||
|
@ -111,11 +123,12 @@ void draw_sprites(bopti_image_t *tex_index[], RcActor *player){
|
||||||
|
|
||||||
qsort(dists, SINDEX_S, sizeof(struct SpriteDist), &sprite_cmpfnc);
|
qsort(dists, SINDEX_S, sizeof(struct SpriteDist), &sprite_cmpfnc);
|
||||||
|
|
||||||
int msprite = min(spritec,max_sprites);
|
int msprite = spritec > max_sprites ? max_sprites:spritec;
|
||||||
for(int i = msprite; i > 0; i--){
|
for(int i = 0; i < msprite; i++){
|
||||||
struct SpriteDist *sd = &dists[i];
|
struct SpriteDist *sd = &dists[i];
|
||||||
Sprite *spr = sprite_index[sd->id];
|
Sprite *spr = sprite_index[sd->id];
|
||||||
if(sd->dist > max_dist)
|
|
||||||
|
if(sd->dist > max_dist || !spr)
|
||||||
continue;
|
continue;
|
||||||
project_sprite(tex_index, spr, player);
|
project_sprite(tex_index, spr, player);
|
||||||
}
|
}
|
||||||
|
@ -131,6 +144,8 @@ fixed_t raycast(RcGame *game, RcActor *origin, Sprite **hit){
|
||||||
fixed_t planeX = origin->plane.x;
|
fixed_t planeX = origin->plane.x;
|
||||||
fixed_t planeY = origin->plane.y;
|
fixed_t planeY = origin->plane.y;
|
||||||
uint8_t *map_test = game->current_map->dat;
|
uint8_t *map_test = game->current_map->dat;
|
||||||
|
int map_w = game->current_map->w;
|
||||||
|
int map_h = game->current_map->h;
|
||||||
|
|
||||||
fixed_t cameraX;
|
fixed_t cameraX;
|
||||||
fixed_t rayDirX;
|
fixed_t rayDirX;
|
||||||
|
@ -147,11 +162,8 @@ fixed_t raycast(RcGame *game, RcActor *origin, Sprite **hit){
|
||||||
int stepY;
|
int stepY;
|
||||||
int side = 0; //was a NS or a EW wall hit?
|
int side = 0; //was a NS or a EW wall hit?
|
||||||
|
|
||||||
//int v_offset = 0;
|
|
||||||
fixed_t h_offset = 0;
|
|
||||||
|
|
||||||
//calculate ray position and direction
|
//calculate ray position and direction
|
||||||
cameraX = fdiv(fix(x*2), fix(viewport_w)) - 0xFFFF + h_offset; //x-coordinate in camera space
|
cameraX = fdiv(fix(x*2), fix(viewport_w)) - 0xFFFF; //x-coordinate in camera space
|
||||||
|
|
||||||
rayDirX = dirX + fmul(planeX, cameraX);
|
rayDirX = dirX + fmul(planeX, cameraX);
|
||||||
rayDirY = dirY + fmul(planeY, cameraX);
|
rayDirY = dirY + fmul(planeY, cameraX);
|
||||||
|
@ -207,7 +219,7 @@ fixed_t raycast(RcGame *game, RcActor *origin, Sprite **hit){
|
||||||
//perform DDA
|
//perform DDA
|
||||||
while(true) {
|
while(true) {
|
||||||
//Check if the ray is out of range/bounds
|
//Check if the ray is out of range/bounds
|
||||||
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapY >= map_w || mapX >= map_h) {
|
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX <= 0 || mapY <= 0 || mapY >= map_w || mapX >= map_h) {
|
||||||
coll = 0;
|
coll = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
78
eng/utils.c
|
@ -1,4 +1,82 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "C3D/fixed.h"
|
#include "C3D/fixed.h"
|
||||||
#include "C3D/game.h"
|
#include "C3D/game.h"
|
||||||
|
|
||||||
|
bool rect_rect_coll(Rect *a, Rect *b){
|
||||||
|
bool r = a->x0 >= b->x0 && a->x1 <= b->x1;
|
||||||
|
r = r && a->y0 >= b->y0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmpfunc (const void * a, const void * b) {
|
||||||
|
return ( *(int*)a - *(int*)b );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1990 Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. [rescinded 22 July 1999]
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform a binary search.
|
||||||
|
*
|
||||||
|
* The code below is a bit sneaky. After a comparison fails, we
|
||||||
|
* divide the work in half by moving either left or right. If lim
|
||||||
|
* is odd, moving left simply involves halving lim: e.g., when lim
|
||||||
|
* is 5 we look at item 2, so we change lim to 2 so that we will
|
||||||
|
* look at items 0 & 1. If lim is even, the same applies. If lim
|
||||||
|
* is odd, moving right again involes halving lim, this time moving
|
||||||
|
* the base up one item past p: e.g., when lim is 5 we change base
|
||||||
|
* to item 3 and make lim 2 so that we will look at items 3 and 4.
|
||||||
|
* If lim is even, however, we have to shrink it by one before
|
||||||
|
* halving: e.g., when lim is 4, we still looked at item 2, so we
|
||||||
|
* have to make lim 3, then halve, obtaining 1, so that we will only
|
||||||
|
* look at item 3.
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
bsearch (const void *key, const void *base0,
|
||||||
|
size_t nmemb, size_t size,
|
||||||
|
int (*compar)(const void *, const void *))
|
||||||
|
{
|
||||||
|
const char *base = (const char *) base0;
|
||||||
|
int lim, cmp;
|
||||||
|
const void *p;
|
||||||
|
|
||||||
|
for (lim = nmemb; lim != 0; lim >>= 1) {
|
||||||
|
p = base + (lim >> 1) * size;
|
||||||
|
cmp = (*compar)(key, p);
|
||||||
|
if (cmp == 0)
|
||||||
|
return (void *)p;
|
||||||
|
if (cmp > 0) { /* key > p: move right */
|
||||||
|
base = (const char *)p + size;
|
||||||
|
lim--;
|
||||||
|
} /* else move left */
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
|
|
||||||
#define screen_w 128
|
#define screen_w 128
|
||||||
#define screen_h 64
|
#define screen_h 64
|
||||||
#define viewport_w 128
|
#define viewport_w 100
|
||||||
#define viewport_h 64
|
#define viewport_h 64
|
||||||
#define max_dist fix(32)
|
#define max_dist fix(32)
|
||||||
//Max sprites to attempt to render
|
//Max sprites to attempt to render
|
||||||
#define max_sprites 16
|
#define max_sprites 32
|
||||||
|
|
||||||
#define TSIZE 32
|
#define TSIZE 32
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,13 @@ typedef int32_t fixed_t;
|
||||||
/* Standard arithmetic. */
|
/* Standard arithmetic. */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t x ,y;
|
int32_t x,y;
|
||||||
} V2d;
|
} V2d;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int16_t x,y;
|
||||||
|
} V2d16;
|
||||||
|
|
||||||
static inline fixed_t fmul(fixed_t left, fixed_t right)
|
static inline fixed_t fmul(fixed_t left, fixed_t right)
|
||||||
{
|
{
|
||||||
/* Generally optimized by the compiler to use dmuls.l and xtrct */
|
/* Generally optimized by the compiler to use dmuls.l and xtrct */
|
||||||
|
@ -25,6 +29,8 @@ static inline fixed_t fmul(fixed_t left, fixed_t right)
|
||||||
|
|
||||||
static inline fixed_t fdiv(fixed_t left, fixed_t right)
|
static inline fixed_t fdiv(fixed_t left, fixed_t right)
|
||||||
{
|
{
|
||||||
|
if(!right)
|
||||||
|
return 0;
|
||||||
/* Pretty slow */
|
/* Pretty slow */
|
||||||
int64_t d = (int64_t)left << 16;
|
int64_t d = (int64_t)left << 16;
|
||||||
return d / right;
|
return d / right;
|
||||||
|
@ -72,7 +78,7 @@ static inline double f2double(fixed_t f)
|
||||||
return (double)f / 65536;
|
return (double)f / 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline fixed_t feasein(fixed_t x)
|
static inline fixed_t fsq(fixed_t x)
|
||||||
{
|
{
|
||||||
return fmul(x, x);
|
return fmul(x, x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <gint/display.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
V2d pos;
|
V2d pos;
|
||||||
Rect coll;
|
Rect coll;
|
||||||
int tex;
|
int16_t tex;
|
||||||
} Sprite;
|
int16_t hp;
|
||||||
|
} GPACKED(4) Sprite;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int w, h;
|
int w, h;
|
||||||
|
@ -20,6 +22,8 @@ typedef struct {
|
||||||
|
|
||||||
Sprite sprites[SINDEX_S/2];
|
Sprite sprites[SINDEX_S/2];
|
||||||
|
|
||||||
|
V2d start_pos;
|
||||||
|
|
||||||
} RcMap;
|
} RcMap;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +32,9 @@ typedef struct {
|
||||||
|
|
||||||
V2d pos;
|
V2d pos;
|
||||||
Rect coll;
|
Rect coll;
|
||||||
int tex;
|
int16_t tex;
|
||||||
|
int16_t hp;
|
||||||
|
|
||||||
V2d dir;
|
V2d dir;
|
||||||
V2d plane;
|
V2d plane;
|
||||||
|
|
||||||
|
@ -37,6 +43,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
||||||
uint8_t exit;
|
uint8_t exit;
|
||||||
|
uint8_t __pad;
|
||||||
|
int16_t v_offset;
|
||||||
|
|
||||||
} RcFlags;
|
} RcFlags;
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,3 @@
|
||||||
#include "fixed.h"
|
#include "fixed.h"
|
||||||
#include "sprites.h"
|
#include "sprites.h"
|
||||||
|
|
||||||
//TODO : deprecate
|
|
||||||
//! Attention à avoir *exactement* la même taille entre ces valeurs et la carte dans map.c !
|
|
||||||
|
|
||||||
#define map_w 64
|
|
||||||
#define map_h 128
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ void add_sprite(Sprite *sprite);
|
||||||
|
|
||||||
void clear_sprites();
|
void clear_sprites();
|
||||||
|
|
||||||
|
int remove_sprite(Sprite *sprite);
|
||||||
|
|
||||||
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
|
void draw_sprites(bopti_image_t *tex_index[], RcActor *player);
|
||||||
|
|
||||||
//Returns distance (-1 if no hit), hit is set to the hit sprite
|
//Returns distance (-1 if no hit), hit is set to the hit sprite
|
||||||
|
|
|
@ -11,11 +11,8 @@
|
||||||
#define min(x, xmin) (x > xmin ? xmin:x)
|
#define min(x, xmin) (x > xmin ? xmin:x)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x0,x1;
|
int16_t x0,x1;
|
||||||
int y0,y1;
|
int16_t y0,y1;
|
||||||
} Rect;
|
} Rect;
|
||||||
|
|
||||||
static bool rect_rect_coll(Rect *a, Rect *b){
|
int cmpfunc (const void * a, const void * b);
|
||||||
bool r = a->x0 >= b->x0 && a->x1 <= b->x1;
|
|
||||||
r = r && a->y0 >= b->y0;
|
|
||||||
}
|
|
||||||
|
|
173
src/game.c
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "C3D/sprites.h"
|
||||||
|
#include "C3D/fixed.h"
|
||||||
|
#include "C3D/game.h"
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
|
#include "gfx.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
int sreserve_c = 0;
|
||||||
|
Sprite sprite_reserve[SINDEX_S];
|
||||||
|
|
||||||
|
Rect sprite_colls[] = {
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{.x0 = fix(.25), .y0 = fix(.25), .x1 = fix(.5), .y1 = fix(.5)},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
int16_t sprite_hp[] = {
|
||||||
|
0x1000,
|
||||||
|
0x1000,
|
||||||
|
0x1000,
|
||||||
|
0x1000,
|
||||||
|
2,
|
||||||
|
0x1000,
|
||||||
|
0x1000,
|
||||||
|
0x1000
|
||||||
|
};
|
||||||
|
|
||||||
|
Sprite *cc_mksprite(V2d pos, int type){
|
||||||
|
if(sreserve_c >= SINDEX_S)
|
||||||
|
return NULL;
|
||||||
|
Sprite *spr = &sprite_reserve[sreserve_c++];
|
||||||
|
spr->tex = type;
|
||||||
|
spr->coll = sprite_colls[type];
|
||||||
|
spr->pos = pos;
|
||||||
|
spr->hp = sprite_hp[type];
|
||||||
|
add_sprite(spr);
|
||||||
|
return spr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cc_rmsprite(int pos){
|
||||||
|
if(pos < 0 || pos >= sreserve_c)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if(!remove_sprite(&sprite_reserve[pos]))
|
||||||
|
return 2;
|
||||||
|
if(pos+1 != sreserve_c){
|
||||||
|
memmove(&sprite_reserve[pos], &sprite_reserve[pos+1], sizeof(Sprite)*(sreserve_c-pos));
|
||||||
|
}
|
||||||
|
sreserve_c--;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_load_msprites(Sprite *mapsprites, int spritec){
|
||||||
|
sreserve_c = 0;
|
||||||
|
for(int i = 0; i < spritec; i++)
|
||||||
|
cc_mksprite(mapsprites[i].pos, mapsprites[i].tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_hit(CCGame *game, int hitstr){
|
||||||
|
if(game->hit > 0)
|
||||||
|
return;
|
||||||
|
game->hit = 40;
|
||||||
|
game->_bgame.player.hp -= hitstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_ai_mov(RcGame *game, Sprite *spr, fixed_t spd, int hitstr, int coll, fixed_t range){
|
||||||
|
fixed_t dx = spr->pos.x - game->player.pos.x;
|
||||||
|
fixed_t dy = spr->pos.y - game->player.pos.y;
|
||||||
|
fixed_t player_dist = fsq(dx) + fsq(dy);
|
||||||
|
int dxs = (dx >= 0) * 2 - 1;
|
||||||
|
int dys = (dy >= 0) * 2 - 1;
|
||||||
|
|
||||||
|
if(player_dist > fsq(max_dist) || player_dist < fsq(fix(0.5)))
|
||||||
|
return;
|
||||||
|
if(player_dist < fsq(range))
|
||||||
|
cc_hit((CCGame*)game, hitstr);
|
||||||
|
|
||||||
|
int nx = spr->pos.x;
|
||||||
|
int ny = spr->pos.y;
|
||||||
|
if(fixabs(dx) >= fixabs(dy))
|
||||||
|
nx -= dxs * spd;
|
||||||
|
else
|
||||||
|
ny -= dys * spd;
|
||||||
|
if(!game->current_map->dat[ffloor(nx)*game->current_map->w + ffloor(ny)] || !coll){
|
||||||
|
spr->pos.x = nx;
|
||||||
|
spr->pos.y = ny;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cc_ai(RcGame *game){
|
||||||
|
for(int i = 0; i < sreserve_c; i++){
|
||||||
|
Sprite *spr = &sprite_reserve[i];
|
||||||
|
if(spr->hp <= 0){
|
||||||
|
if(cc_rmsprite(i) == 2)
|
||||||
|
game->flags.exit = 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch(spr->tex){
|
||||||
|
default:
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
case 4:{
|
||||||
|
cc_ai_mov(game, spr, fix(.025), 5, 1, fix(1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WeaponStat weapon_stats[] = {
|
||||||
|
{0},
|
||||||
|
{.range = fix(1), .dmg = 1},
|
||||||
|
{.range = fix(1.5), .dmg = 5}
|
||||||
|
};
|
||||||
|
|
||||||
|
void weapon_hurt_stuff(CCGame *game){
|
||||||
|
Sprite *hit;
|
||||||
|
int dist = raycast((RcGame*)game, &((RcGame*)game)->player, &hit);
|
||||||
|
if(dist > weapon_stats[game->curr_weapon].range || !hit)
|
||||||
|
return;
|
||||||
|
//:p
|
||||||
|
if(hit > 0x90000000)
|
||||||
|
return;
|
||||||
|
hit->hp -= weapon_stats[game->curr_weapon].dmg;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern WeapAnim weap_anims[WEAP_ANIM_C];
|
||||||
|
|
||||||
|
int cc_logic(RcGame *_game){
|
||||||
|
CCGame *game = (void*)_game;
|
||||||
|
if(game->hit)
|
||||||
|
game->hit--;
|
||||||
|
|
||||||
|
if(game->weapon_use){
|
||||||
|
game->weapon_use = (game->weapon_use+1) %
|
||||||
|
(weap_anims[game->curr_weapon].framec*4);
|
||||||
|
if(game->weapon_use == weap_anims[game->curr_weapon].frame_hit*4)
|
||||||
|
weapon_hurt_stuff(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_game->player.hp <= 0){
|
||||||
|
death_anim(_game);
|
||||||
|
switch_map(game, game->curr_map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void use_weapon(CCGame *game){
|
||||||
|
if(game->weapon_use)
|
||||||
|
return;
|
||||||
|
game->weapon_use = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_logic(){
|
||||||
|
add_logic_hook((RcLogicFunc*)&cc_ai);
|
||||||
|
add_logic_hook((RcLogicFunc*)&cc_logic);
|
||||||
|
}
|
41
src/game.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//Par Fcalva, et est sous GPLv3
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "C3D/game.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
stype_frenguy = 4,
|
||||||
|
stype_anvilpick = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
weap_none = 0,
|
||||||
|
weap_hands = 1,
|
||||||
|
weap_anvilstick = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
RcGame _bgame;
|
||||||
|
int8_t curr_map;
|
||||||
|
int8_t hit;
|
||||||
|
int8_t curr_weapon;
|
||||||
|
int8_t weapon_use;
|
||||||
|
} CCGame; //CpC game Game struct
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
fixed_t range;
|
||||||
|
int dmg;
|
||||||
|
} WeaponStat;
|
||||||
|
|
||||||
|
void cc_load_msprites(Sprite *mapsprites, int spritec);
|
||||||
|
|
||||||
|
Sprite *cc_mksprite(V2d pos, int type);
|
||||||
|
|
||||||
|
int cc_rmsprite(int pos);
|
||||||
|
|
||||||
|
void use_weapon(CCGame *game);
|
||||||
|
|
||||||
|
int cc_logic_onframe(CCGame *game);
|
||||||
|
|
||||||
|
void init_logic();
|
105
src/gfx.c
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
//Par Fcalva et est sous GPLv3
|
||||||
|
#include <gint/display.h>
|
||||||
|
#include <gint/keyboard.h>
|
||||||
|
#include <gint/clock.h>
|
||||||
|
|
||||||
|
#include "C3D/fixed.h"
|
||||||
|
#include "C3D/game.h"
|
||||||
|
#include "C3D/sprites.h"
|
||||||
|
#include "C3D/moteur.h"
|
||||||
|
#include "C3D/map.h"
|
||||||
|
#include "C3D/config.h"
|
||||||
|
|
||||||
|
#include "gfx.h"
|
||||||
|
|
||||||
|
extern bopti_image_t briques0;
|
||||||
|
extern bopti_image_t buisson0;
|
||||||
|
extern bopti_image_t sprite_tst;
|
||||||
|
extern bopti_image_t sprite_tst1;
|
||||||
|
extern bopti_image_t bwain0;
|
||||||
|
extern bopti_image_t bwain1;
|
||||||
|
extern bopti_image_t meat0;
|
||||||
|
extern bopti_image_t meat1;
|
||||||
|
extern bopti_image_t anvil_pick;
|
||||||
|
|
||||||
|
bopti_image_t *tex_index[TINDEX_S] = {
|
||||||
|
&briques0, //0
|
||||||
|
&buisson0, //1
|
||||||
|
&briques0, //2
|
||||||
|
&briques0, //3
|
||||||
|
&sprite_tst, //4
|
||||||
|
&bwain0, //5
|
||||||
|
&meat0, //6
|
||||||
|
&anvil_pick //7
|
||||||
|
};
|
||||||
|
|
||||||
|
int state = 0;
|
||||||
|
int anim_tex(GUNUSED RcGame *game){
|
||||||
|
tex_index[5] = state > 7 ? &bwain0:&bwain1;
|
||||||
|
tex_index[6] = state > 7 ? &meat0:&meat1;
|
||||||
|
tex_index[4] = state > 7 ? &sprite_tst:&sprite_tst1;
|
||||||
|
state = (state+1) % 16;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_gfx(){
|
||||||
|
add_logic_hook((RcLogicFunc*)&anim_tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern bopti_image_t blood;
|
||||||
|
|
||||||
|
void death_anim(RcGame *game){
|
||||||
|
for(int i = -23; i < DHEIGHT; i+=2){
|
||||||
|
dimage(0,i,&blood);
|
||||||
|
dupdate();
|
||||||
|
sleep_us(10000);
|
||||||
|
}
|
||||||
|
dtext_opt(DWIDTH/2,DHEIGHT/2-20,0,C_NONE,DTEXT_CENTER,DTEXT_TOP,
|
||||||
|
"Votre inconscient",-1);
|
||||||
|
dtext_opt(DWIDTH/2,DHEIGHT/2-10,0,C_NONE,DTEXT_CENTER,DTEXT_TOP,
|
||||||
|
"l'a emporte...",-1);
|
||||||
|
dtext_opt(DWIDTH/2,DHEIGHT/2+10,0,C_NONE,DTEXT_CENTER,DTEXT_TOP,
|
||||||
|
"[shift] recommencer",-1);
|
||||||
|
dupdate();
|
||||||
|
while(getkey_opt(0,NULL).key != KEY_SHIFT){}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern bopti_image_t hands0;
|
||||||
|
extern bopti_image_t hands1;
|
||||||
|
extern bopti_image_t hands2;
|
||||||
|
|
||||||
|
extern bopti_image_t anvil0;
|
||||||
|
extern bopti_image_t anvil1;
|
||||||
|
extern bopti_image_t anvil2;
|
||||||
|
extern bopti_image_t anvil3;
|
||||||
|
|
||||||
|
WeapAnim weap_anims[WEAP_ANIM_C] = {
|
||||||
|
{},
|
||||||
|
{.frames = {&hands0, &hands1, &hands2, &hands1},
|
||||||
|
.x = 15,
|
||||||
|
.y = 42,
|
||||||
|
.framec = 4,
|
||||||
|
.frame_hit = 2
|
||||||
|
},
|
||||||
|
{.frames = {&anvil0, &anvil1, &anvil2, &anvil3, &anvil2, &anvil1},
|
||||||
|
.x = 0,
|
||||||
|
.y = 0,
|
||||||
|
.framec = 6,
|
||||||
|
.frame_hit = 3
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void draw_hands(CCGame *game){
|
||||||
|
WeapAnim *anim = &weap_anims[game->curr_weapon];
|
||||||
|
dimage(anim->x, anim->y, anim->frames[game->weapon_use/4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_gui(CCGame *game){
|
||||||
|
draw_hands(game);
|
||||||
|
dline(100,0,100,63,3);
|
||||||
|
dprint_opt(127,10,3,C_NONE,DTEXT_RIGHT,DTEXT_TOP,"%d",game->_bgame.player.hp);
|
||||||
|
//TODO : replace w/ icon
|
||||||
|
dtext_opt(127,20,3,C_NONE,DTEXT_RIGHT,DTEXT_TOP,"HP",-1);
|
||||||
|
}
|
||||||
|
|
31
src/gfx.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
//Par Fcalva et est sous GPLv3
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gint/display.h>
|
||||||
|
|
||||||
|
#include "C3D/fixed.h"
|
||||||
|
#include "C3D/game.h"
|
||||||
|
#include "C3D/sprites.h"
|
||||||
|
#include "C3D/moteur.h"
|
||||||
|
#include "C3D/map.h"
|
||||||
|
#include "C3D/config.h"
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
#define WEAP_ANIM_C 8
|
||||||
|
#define WEAP_FRAMES_C 8
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bopti_image_t *frames[WEAP_FRAMES_C];
|
||||||
|
int8_t x;
|
||||||
|
int8_t y;
|
||||||
|
int8_t framec;
|
||||||
|
int8_t frame_hit;
|
||||||
|
} WeapAnim;
|
||||||
|
|
||||||
|
void death_anim(RcGame *game);
|
||||||
|
|
||||||
|
void init_gfx();
|
||||||
|
|
||||||
|
void draw_gui(CCGame *game);
|
152
src/main.c
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <gint/display.h>
|
#include <gint/display.h>
|
||||||
#include <gint/keyboard.h>
|
#include <gint/keyboard.h>
|
||||||
|
#include <gint/clock.h>
|
||||||
#include <gint/image.h>
|
#include <gint/image.h>
|
||||||
#include <gint/gray.h>
|
#include <gint/gray.h>
|
||||||
#include <gint/dma.h>
|
#include <gint/dma.h>
|
||||||
|
@ -12,13 +13,16 @@
|
||||||
#include <libprof.h>
|
#include <libprof.h>
|
||||||
|
|
||||||
#include "C3D/fixed.h"
|
#include "C3D/fixed.h"
|
||||||
|
|
||||||
#include "C3D/game.h"
|
#include "C3D/game.h"
|
||||||
#include "C3D/sprites.h"
|
#include "C3D/sprites.h"
|
||||||
#include "C3D/moteur.h"
|
#include "C3D/moteur.h"
|
||||||
#include "C3D/map.h"
|
#include "C3D/map.h"
|
||||||
#include "C3D/config.h"
|
#include "C3D/config.h"
|
||||||
|
|
||||||
|
#include "gfx.h"
|
||||||
|
#include "map.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
//====== Copy3DEngine =====
|
//====== Copy3DEngine =====
|
||||||
// Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine
|
// Git du moteur : https://git.planet-casio.com/Fcalva/Copy3DEngine
|
||||||
// Git du jeu : [Rajoutez le vôtre ici]
|
// Git du jeu : [Rajoutez le vôtre ici]
|
||||||
|
@ -29,42 +33,37 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
bopti_image_t *tex_index[TINDEX_S];
|
extern bopti_image_t *tex_index[TINDEX_S];
|
||||||
|
|
||||||
extern uint8_t map_test[map_w][map_h];
|
|
||||||
|
|
||||||
//Vos images ici
|
|
||||||
|
|
||||||
extern bopti_image_t briques0;
|
|
||||||
extern bopti_image_t buisson0;
|
|
||||||
extern bopti_image_t sprite_tst;
|
|
||||||
|
|
||||||
char disp_frame_time = 0;
|
char disp_frame_time = 0;
|
||||||
char first_frame = 0;
|
char first_frame = 0;
|
||||||
int frame_time_timer = 1;
|
int frame_time_timer = 1;
|
||||||
|
|
||||||
RcMap map0 = {
|
CCGame game = {
|
||||||
.w = 128,
|
._bgame = {
|
||||||
.h = 64,
|
.player = {
|
||||||
.dat = (void*)&map_test
|
.pos = {fix(3.1), fix(3.1)},
|
||||||
};
|
.dir = {fix(0), fix(1)},
|
||||||
|
.plane = {fix(0.66), fix(0)},
|
||||||
RcGame game = {
|
.hp = 100
|
||||||
.player = {
|
},
|
||||||
.pos = {fix(3.1), fix(3.1)},
|
.flags = {0, 0}
|
||||||
.dir = {fix(0), fix(1)},
|
|
||||||
.plane = {fix(0.66), fix(0)}
|
|
||||||
},
|
},
|
||||||
.current_map = &map0,
|
.hit = 0,
|
||||||
.flags = {0}
|
.curr_weapon = 1,
|
||||||
|
.weapon_use = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
int frame_time = 1;
|
int frame_time = 1;
|
||||||
|
|
||||||
void keys_get(){
|
void keys_get(RcGame *game){
|
||||||
pollevent();
|
pollevent();
|
||||||
|
|
||||||
move(&game);
|
move(game);
|
||||||
|
|
||||||
|
if(keydown(KEY_SHIFT)){
|
||||||
|
use_weapon((CCGame*)game);
|
||||||
|
}
|
||||||
|
|
||||||
if (keydown(KEY_F1) && frame_time_timer <= 0) {
|
if (keydown(KEY_F1) && frame_time_timer <= 0) {
|
||||||
if (disp_frame_time == 0) {
|
if (disp_frame_time == 0) {
|
||||||
|
@ -77,10 +76,22 @@ void keys_get(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frame_time_timer--;
|
frame_time_timer--;
|
||||||
if (keydown(KEY_EXIT)) game.flags.exit = 1;
|
if (keydown(KEY_EXIT)) game->flags.exit = 1;
|
||||||
|
|
||||||
if(keydown(KEY_F2)){
|
if(keydown(KEY_F2)){
|
||||||
dprint(0,0,3,"%d",raycast(&game, &game.player, NULL));
|
dprint(0,0,3,"%d",raycast(game, &game->player, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(keydown(KEY_F3)){
|
||||||
|
cc_mksprite(game->player.pos, 7);
|
||||||
|
while(keydown(KEY_F3)){
|
||||||
|
clearevents();
|
||||||
|
pollevent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(keydown(KEY_F4)){
|
||||||
|
cc_rmsprite(0);
|
||||||
|
while(keydown(KEY_F4)) { clearevents(); pollevent();}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
|
@ -88,114 +99,85 @@ void keys_get(){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_menu(){
|
extern bopti_image_t title;
|
||||||
dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1);
|
|
||||||
dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De "AUTHOR, -1);
|
|
||||||
dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
|
||||||
|
|
||||||
dupdate();
|
|
||||||
getkey();
|
|
||||||
}
|
|
||||||
|
|
||||||
Sprite tsprite = {
|
|
||||||
.pos = {200000, 300000},
|
|
||||||
.tex = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
int movdir = 1;
|
|
||||||
|
|
||||||
int test_logic(RcGame *game){
|
|
||||||
tsprite.pos.x += movdir*500;
|
|
||||||
if(tsprite.pos.x > fix(4) || tsprite.pos.x < fix(2))
|
|
||||||
movdir = -movdir;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
RcGame *rcgame = (RcGame*)&game;
|
||||||
|
|
||||||
dclear(C_WHITE);
|
dclear(C_WHITE);
|
||||||
|
|
||||||
//trucs de chargement
|
//trucs de chargement
|
||||||
|
|
||||||
load_map();
|
load_map();
|
||||||
|
|
||||||
tex_index[1] = &buisson0;
|
|
||||||
tex_index[2] = &briques0;
|
|
||||||
|
|
||||||
//Vos textures générées procéduralement (TODO)
|
|
||||||
|
|
||||||
tex_index[0] = &briques0;
|
|
||||||
tex_index[3] = &briques0;
|
|
||||||
|
|
||||||
tex_index[4] = &sprite_tst;
|
|
||||||
|
|
||||||
prof_init();
|
prof_init();
|
||||||
|
|
||||||
if(dgray(DGRAY_ON))
|
if(dgray(DGRAY_ON))
|
||||||
goto c3d_abort;
|
rcgame->flags.exit = 1;
|
||||||
dupdate();
|
dupdate();
|
||||||
|
|
||||||
dclear(0);
|
dimage(0,0,&title);
|
||||||
|
dupdate();
|
||||||
|
sleep_us(2000000);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
EngineTimers timers;
|
EngineTimers timers;
|
||||||
//gdb_start_on_exception();
|
//gdb_start_on_exception();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_sprite(&tsprite);
|
init_gfx();
|
||||||
|
init_map(&game);
|
||||||
|
init_logic();
|
||||||
|
|
||||||
add_logic_hook((RcLogicFunc*)&test_logic);
|
while (!rcgame->flags.exit) {
|
||||||
|
|
||||||
while (!game.flags.exit) {
|
|
||||||
prof_t frame = prof_make();
|
prof_t frame = prof_make();
|
||||||
prof_enter(frame);
|
prof_enter(frame);
|
||||||
|
|
||||||
dclear(C_WHITE);
|
dclear(C_WHITE);
|
||||||
|
|
||||||
if(first_frame){
|
keys_get(rcgame);
|
||||||
main_menu();
|
|
||||||
}
|
|
||||||
|
|
||||||
keys_get();
|
do_logic(rcgame, frame_time);
|
||||||
|
|
||||||
do_logic(&game, frame_time);
|
|
||||||
|
|
||||||
draw_walls(
|
draw_walls(
|
||||||
#if debug
|
#if debug
|
||||||
&timers,
|
&timers,
|
||||||
#endif
|
#endif
|
||||||
&game
|
rcgame
|
||||||
);
|
);
|
||||||
|
|
||||||
draw_sprites(tex_index, &game.player);
|
draw_sprites(tex_index, &rcgame->player);
|
||||||
|
|
||||||
if (disp_frame_time == 1) dprint( 0, 0, C_BLACK, "%d ms", frame_time/1000);
|
if (disp_frame_time == 1) dprint( 0, 0, C_BLACK, "%d ms", frame_time/1000);
|
||||||
|
|
||||||
|
draw_gui(&game);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
dprint( 1, 27, C_BLACK, "pX %d", game.player.pos.x);
|
dprint( 1, 27, C_BLACK, "pX %d", ffloor(rcgame->player.pos.x));
|
||||||
dprint( 1, 36, C_BLACK, "pY %d", game.player.pos.y);
|
dprint( 1, 36, C_BLACK, "pY %d", ffloor(rcgame->player.pos.y));
|
||||||
dprint( 1, 9, C_BLACK, "Rct %d", prof_time(timers.raycast_time));
|
dprint( 1, 9, C_BLACK, "Rct %d", prof_time(timers.raycast_time));
|
||||||
dprint( 1, 18, C_BLACK, "Dt %d", prof_time(timers.draw_time));
|
dprint( 1, 18, C_BLACK, "Dt %d", prof_time(timers.draw_time));
|
||||||
timers.raycast_time = prof_make();
|
timers.raycast_time = prof_make();
|
||||||
timers.draw_time = prof_make();
|
timers.draw_time = prof_make();
|
||||||
#endif
|
#endif
|
||||||
|
if(game.hit > 30){
|
||||||
|
drect(0,0,127,63,C_INVERT);
|
||||||
|
}
|
||||||
dupdate();
|
dupdate();
|
||||||
prof_leave(frame);
|
prof_leave(frame);
|
||||||
frame_time = (int)prof_time(frame);
|
frame_time = prof_time(frame);
|
||||||
first_frame = 0;
|
first_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
c3d_abort:
|
|
||||||
|
|
||||||
dgray(DGRAY_OFF);
|
dgray(DGRAY_OFF);
|
||||||
|
|
||||||
prof_quit();
|
prof_quit();
|
||||||
|
|
||||||
//Libérez vos textures générées procéduralement
|
if(rcgame->flags.exit > 1){
|
||||||
|
dclear(0);
|
||||||
//bopti_free(tex_index[0]);
|
dprint(0,0,3,"Error %x !", rcgame->flags.exit);
|
||||||
//bopti_free(tex_index[3]);
|
dupdate();
|
||||||
|
getkey();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
199
src/map.c
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
// Voir README.md pour license précise, par Fcalva 2023-2024 et est sous GPLv3
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "C3D/map.h"
|
||||||
|
#include "C3D/moteur.h"
|
||||||
|
#include "C3D/game.h"
|
||||||
|
#include "C3D/fixed.h"
|
||||||
|
|
||||||
|
#include "map.h"
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
#define SEC_ROM __attribute__((section(".rodata")))
|
||||||
|
|
||||||
|
int trigger_weapon_anvilstick(RcGame *_game){
|
||||||
|
CCGame *game = (void*)_game;
|
||||||
|
game->curr_weapon = weap_anvilstick;
|
||||||
|
game->weapon_use = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t SEC_ROM map_dat0[] = {
|
||||||
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,6,5,5,5,6,6,6,6,6,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,6,
|
||||||
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,6,0,0,6,0,0,6,0,0,6,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,1,6,5,5,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,1,0,0,0,0,0,0,6,0,0,6,0,0,6,0,0,6,0,6,
|
||||||
|
6,0,1,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,6,0,0,6,0,0,6,0,0,6,0,6,
|
||||||
|
6,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
|
||||||
|
};
|
||||||
|
|
||||||
|
CCMap SEC_ROM map0 = {
|
||||||
|
._bmap = {
|
||||||
|
.w = 20,
|
||||||
|
.h = 20,
|
||||||
|
.dat = (void*)&map_dat0,
|
||||||
|
.start_pos = {fix(3.1),fix(1.1)},
|
||||||
|
.sprites = {
|
||||||
|
{.pos = {fix(4.2),fix(14.2)}, .tex = 4},
|
||||||
|
{.pos = {fix(8.2),fix(10.2)}, .tex = 4}
|
||||||
|
},
|
||||||
|
.spritec = 2
|
||||||
|
},
|
||||||
|
.triggers = {
|
||||||
|
{.pos = {10,2},
|
||||||
|
.dat = {.tolvl = 1},
|
||||||
|
.type = 0
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t SEC_ROM map_dat1[] = {
|
||||||
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
|
6,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,6,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,6,
|
||||||
|
6,0,6,6,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,6,0,0,0,0,0,0,0,2,0,0,0,0,0,0,6,
|
||||||
|
6,6,6,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,6,0,0,0,0,0,6,0,0,0,6,
|
||||||
|
6,6,0,6,6,6,0,6,0,0,0,6,6,6,6,6,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,6,6,6,6,0,0,0,6,6,0,0,0,6,
|
||||||
|
6,0,5,5,0,0,0,6,6,6,6,6,0,6,5,6,0,0,6,6,
|
||||||
|
6,0,5,0,0,5,0,6,0,0,0,0,0,0,0,0,0,6,0,6,
|
||||||
|
6,0,0,0,5,5,0,0,0,5,0,6,0,6,6,6,6,0,0,6,
|
||||||
|
6,0,5,0,0,0,0,6,6,0,0,6,0,6,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,6,0,0,6,0,0,0,0,0,6,
|
||||||
|
6,0,6,6,6,6,6,6,6,6,6,0,5,6,6,6,6,6,6,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,6,6,5,5,6,6,5,6,6,6,6,6,6,6,6,6,6,6,6
|
||||||
|
};
|
||||||
|
|
||||||
|
CCMap SEC_ROM map1 = {
|
||||||
|
._bmap = {
|
||||||
|
.w = 20,
|
||||||
|
.h = 20,
|
||||||
|
.dat = map_dat1,
|
||||||
|
.start_pos = {fix(1.5),fix(1.5)},
|
||||||
|
.spritec = 4,
|
||||||
|
.sprites = {
|
||||||
|
{.pos = {fix(17.25),fix(2.25)}, .tex = 7},
|
||||||
|
{.pos = {fix(12.25),fix(3.25)}, .tex = 4},
|
||||||
|
{.pos = {fix(15.25),fix(6.25)}, .tex = 4},
|
||||||
|
{.pos = {fix(8.25),fix(1.25)}, .tex = 4}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.triggers = {
|
||||||
|
{.pos = {3,12},
|
||||||
|
.type = 0,
|
||||||
|
.dat = {.tolvl = 2}
|
||||||
|
},
|
||||||
|
{.pos = {17,2},
|
||||||
|
.type = 1,
|
||||||
|
.dat = {&trigger_weapon_anvilstick}
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t SEC_ROM map_dat2[] = {
|
||||||
|
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,0,0,0,0,0,0,6,
|
||||||
|
6,0,0,0,0,6,5,6,6,6,5,0,0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6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||||
|
};
|
||||||
|
|
||||||
|
CCMap SEC_ROM map2 = {
|
||||||
|
._bmap = {
|
||||||
|
.w = 30,
|
||||||
|
.h = 20,
|
||||||
|
.dat = map_dat2,
|
||||||
|
.start_pos = {fix(18.5),fix(1.5)},
|
||||||
|
.spritec = 0,
|
||||||
|
.sprites = {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.triggers = {
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MAPC 3
|
||||||
|
|
||||||
|
CCMap *maps[MAPC] = {
|
||||||
|
&map0,
|
||||||
|
&map1,
|
||||||
|
&map2
|
||||||
|
};
|
||||||
|
|
||||||
|
void switch_map(CCGame *game, int map){
|
||||||
|
clear_sprites();
|
||||||
|
RcMap *nmap = (RcMap*)maps[map];
|
||||||
|
game->_bgame.current_map = nmap;
|
||||||
|
game->curr_map = map;
|
||||||
|
cc_load_msprites(nmap->sprites, nmap->spritec);
|
||||||
|
game->_bgame.player.pos = nmap->start_pos;
|
||||||
|
game->_bgame.player.hp = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
int map_triggers_agent(RcGame *game){
|
||||||
|
CCMap *map = (CCMap*)game->current_map;
|
||||||
|
for(int i = 0; i < LTRIGGER_C; i++){
|
||||||
|
LevelTrigger *trig = &map->triggers[i];
|
||||||
|
if(trig->pos.x == ffloor(game->player.pos.x) &&
|
||||||
|
trig->pos.y == ffloor(game->player.pos.y)){
|
||||||
|
if(!trig->type)
|
||||||
|
switch_map((CCGame*)game, trig->dat.tolvl);
|
||||||
|
else
|
||||||
|
if(trig->dat.func(game))
|
||||||
|
game->flags.exit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_map(CCGame *game){
|
||||||
|
switch_map(game, 0);
|
||||||
|
add_logic_hook((RcLogicFunc*)&map_triggers_agent);
|
||||||
|
};
|
||||||
|
|
35
src/map.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
//Par Fcalva et est sous GPLv3
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "C3D/game.h"
|
||||||
|
|
||||||
|
#include "game.h"
|
||||||
|
|
||||||
|
#define LTRIGGER_C 3
|
||||||
|
|
||||||
|
typedef union{
|
||||||
|
RcLogicFunc *func;
|
||||||
|
int tolvl;
|
||||||
|
} TriggerType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
V2d pos;
|
||||||
|
TriggerType dat;
|
||||||
|
bool type;
|
||||||
|
|
||||||
|
} LevelTrigger;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
RcMap _bmap;
|
||||||
|
LevelTrigger triggers[3];
|
||||||
|
|
||||||
|
} CCMap;
|
||||||
|
|
||||||
|
void init_map(CCGame *game);
|
||||||
|
|
||||||
|
void switch_map(CCGame *game, int map);
|