Update Shadow's master branch

This commit is contained in:
Shadow15510 2023-07-08 17:24:17 +02:00
commit 0050c2ddf8
29 changed files with 317 additions and 248 deletions

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ __pycache__/
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
.vscode .vscode
*.json

View file

@ -5,28 +5,30 @@ cmake_minimum_required(VERSION 3.15)
project(MyAddin) project(MyAddin)
include(GenerateG1A) include(GenerateG1A)
include(GenerateG3A)
include(Fxconv) include(Fxconv)
find_package(Gint 2.9 REQUIRED) find_package(Gint 2.9 REQUIRED)
find_package(LibProf 2.4 REQUIRED) find_package(LibProf 2.4 REQUIRED)
#set the color mode either to 1bit or 2bits #set the color mode either to 1bit or 2bits
set(COLORMODE 2b) set(COLORMODE 1b)
fxconv_declare_converters(assets-fx/converters.py) fxconv_declare_converters(assets/converters.py)
add_custom_command( add_custom_command(
COMMENT "Convert Tiled TMX map to usable JSON file" COMMENT "Convert Tiled TMX map to usable JSON file"
COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json COMMAND tiled --export-tileset json tilesetnpp.tsx tilesetnpp.json
COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json' COMMAND find | grep .*.tmx | sed 's/.tmx//g' | xargs -l bash -c 'tiled --export-map json $$0.tmx $$0.json'
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets-fx/levels/ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/assets/
OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets-fx/levels/level0.json" OUTPUT "${CMAKE_CURRENT_LIST_DIR}/assets/level0.json"
# if several levels/maps are created, just copy the previous line and change the .json name with the new level/map # if several levels/maps are created, just copy the previous line and change the .json name with the new level/map
DEPENDS assets-fx/converters.py DEPENDS assets/converters.py
assets-fx/levels/tileset.png assets/tileset.png
assets-fx/levels/tilesetnpp.tsx assets/tilesetnpp.tsx
assets-fx/levels/level0.tmx assets/level0.tmx
# if several levels/maps are created, just copy the previous line and change the .json name with the new level/map # if several levels/maps are created, just copy the previous line and change the .json name with the new level/map
) )
@ -39,10 +41,16 @@ set(SOURCES
) )
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets # Shared assets, fx-9860G-only assets and fx-CG-50-only assets
set(ASSETS set(ASSETS
assets/level0.json
assets/demo_player.png
# ... # ...
) )
set(ASSETS_cg
assets-cg/tileset2b_CG.png
)
set(ASSETS_fx set(ASSETS_fx
assets-fx/levels/level0.json
# ... # ...
) )
@ -56,10 +64,11 @@ set(ASSETS_fx_2b
# ... # ...
) )
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_fx_1b} ${ASSETS_fx_2b} WITH_METADATA) fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} ${ASSETS_fx_1b} ${ASSETS_fx_2b} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE}} ) add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}} ${ASSETS_${FXSDK_PLATFORM}_${COLORMODE}} )
if("${COLORMODE}" STREQUAL 1b) if("${COLORMODE}" STREQUAL 1b)
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR1BIT) target_compile_options(myaddin PRIVATE -Wall -Wextra -Os -DCOLOR1BIT)
endif() endif()
@ -75,6 +84,7 @@ target_link_libraries(myaddin LibProf::LibProf Gint::Gint)
if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G) if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
if("${COLORMODE}" STREQUAL 1b) if("${COLORMODE}" STREQUAL 1b)
generate_g1a(TARGET myaddin OUTPUT "PrjPC1b.g1a" generate_g1a(TARGET myaddin OUTPUT "PrjPC1b.g1a"
NAME "Col RPG NB" ICON assets-fx/icon1.png) NAME "Col RPG NB" ICON assets-fx/icon1.png)
@ -84,4 +94,11 @@ if("${FXSDK_PLATFORM_LONG}" STREQUAL fx9860G)
generate_g1a(TARGET myaddin OUTPUT "PrjPC2b.g1a" generate_g1a(TARGET myaddin OUTPUT "PrjPC2b.g1a"
NAME "Col RPG Grey" ICON assets-fx/icon2.png) NAME "Col RPG Grey" ICON assets-fx/icon2.png)
endif() endif()
elseif("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
generate_g3a(TARGET myaddin OUTPUT "PRJPC_CG.g3a"
NAME "Col_RPG_CG" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
endif() endif()

9
LICENSE.txt Normal file
View file

@ -0,0 +1,9 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to https://unlicense.org

View file

@ -0,0 +1,5 @@
tileset2b_CG.png:
type: bopti-image
name: img_tilesetnpp

BIN
assets-cg/icon-sel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
assets-cg/icon-uns.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
assets-cg/tileset2b_CG.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

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

View file

@ -1,7 +1,3 @@
*.json:
custom-type: map
name_regex: (.*)\.json map_\1
tileset1b.png: tileset1b.png:
type: bopti-image type: bopti-image
name: img_tilesetnpp name: img_tilesetnpp

View file

@ -1,44 +0,0 @@
{ "compressionlevel":-1,
"height":24,
"infinite":false,
"layers":[
{
"data":[257, 297, 298, 299, 300, 257, 386, 297, 298, 299, 300, 2, 2, 2, 2, 2, 257, 2, 2, 225, 226, 227, 228, 201, 202, 203, 204, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 253, 205, 229, 205, 229, 280, 179, 180, 179, 156, 156, 156, 158, 157, 179, 180, 253, 2, 2, 249, 250, 251, 252, 225, 226, 227, 228, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 301, 125, 126, 127, 128, 2, 385, 303, 350, 351, 303, 2, 2, 2, 350, 351, 301, 2, 2, 273, 274, 275, 276, 249, 250, 251, 252, 201, 202, 203, 204, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 325, 149, 150, 151, 152, 2, 2, 327, 374, 375, 327, 2, 184, 185, 374, 375, 325, 2, 279, 297, 298, 299, 300, 273, 274, 275, 276, 225, 226, 227, 228, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 257, 2, 2, 385, 2, 2, 385, 2, 265, 266, 2, 2, 208, 209, 352, 353, 257, 2, 302, 2, 130, 129, 166, 297, 298, 299, 300, 249, 250, 251, 252, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 281, 176, 2, 2, 278, 2, 2, 385, 289, 290, 2, 2, 232, 233, 376, 377, 281, 2, 326, 2, 154, 153, 190, 201, 202, 203, 204, 273, 274, 275, 276, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 201, 202, 203, 204, 302, 385, 2, 2, 265, 266, 2, 385, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 166, 225, 226, 227, 228, 297, 298, 299, 300, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 225, 226, 227, 228, 326, 2, 385, 2, 265, 266, 2, 2, 2, 2, 214, 215, 2, 2, 2, 2, 2, 2, 190, 249, 250, 251, 252, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 249, 250, 251, 252, 201, 202, 203, 204, 289, 290, 2, 258, 259, 260, 238, 239, 260, 260, 261, 262, 262, 263, 264, 273, 274, 275, 276, 2, 93, 94, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 273, 274, 275, 276, 225, 226, 227, 228, 265, 266, 2, 282, 283, 284, 285, 285, 285, 285, 285, 285, 286, 287, 288, 297, 298, 299, 300, 2, 117, 118, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 297, 298, 299, 300, 249, 250, 251, 252, 290, 2, 2, 306, 307, 308, 309, 308, 309, 308, 309, 310, 310, 311, 312, 131, 2, 339, 340, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 202, 203, 204, 386, 273, 274, 275, 276, 2, 2, 2, 330, 331, 332, 333, 332, 333, 332, 333, 334, 334, 335, 336, 132, 2, 363, 364, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 226, 227, 228, 386, 297, 298, 299, 300, 2, 290, 2, 162, 163, 164, 165, 162, 163, 164, 165, 162, 163, 164, 165, 132, 2, 201, 202, 203, 204, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 250, 251, 252, 2, 2, 2, 2, 2, 2, 2, 2, 86, 87, 88, 89, 186, 187, 188, 189, 86, 87, 88, 89, 132, 2, 225, 226, 227, 228, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 274, 275, 276, 2, 270, 271, 271, 271, 272, 2, 2, 110, 111, 112, 113, 210, 211, 212, 213, 110, 111, 112, 113, 133, 2, 249, 250, 251, 252, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 298, 299, 300, 2, 294, 1, 1, 1, 296, 2, 2, 136, 137, 0, 0, 234, 290, 265, 237, 2, 2, 339, 340, 2, 2, 273, 274, 275, 276, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 202, 203, 204, 2, 294, 1, 1, 1, 296, 2, 2, 160, 161, 265, 266, 266, 265, 266, 2, 2, 2, 363, 364, 2, 2, 297, 298, 299, 300, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 226, 227, 228, 2, 318, 319, 319, 319, 320, 2, 2, 2, 2, 289, 290, 265, 266, 290, 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, 250, 251, 252, 2, 2, 2, 2, 2, 2, 385, 386, 2, 2, 265, 265, 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, 2, 274, 275, 276, 201, 202, 203, 204, 257, 2, 2, 2, 257, 2, 265, 265, 2, 257, 2, 2, 2, 257, 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, 298, 299, 300, 225, 226, 227, 228, 253, 205, 229, 205, 253, 2, 290, 265, 2, 253, 205, 229, 205, 253, 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, 386, 249, 250, 251, 252, 345, 346, 347, 348, 277, 2, 265, 266, 2, 301, 386, 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, 202, 203, 204, 273, 274, 275, 276, 369, 370, 371, 372, 301, 2, 289, 290, 2, 325, 387, 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, 226, 227, 228, 297, 298, 299, 300, 393, 394, 395, 396, 325, 2, 265, 266, 2, 301, 386, 2, 2, 2, 2, 257, 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],
"height":24,
"id":1,
"name":"Background",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":48,
"x":0,
"y":0
},
{
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"height":24,
"id":2,
"name":"Foreground",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":48,
"x":0,
"y":0
}],
"nextlayerid":3,
"nextobjectid":1,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.8.0",
"tileheight":8,
"tilesets":[
{
"firstgid":1,
"source":"tilesetnpp.tsx"
}],
"tilewidth":8,
"type":"map",
"version":"1.8",
"width":48
}

View file

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View file

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -1,14 +0,0 @@
{ "columns":24,
"image":"tileset.png",
"imageheight":136,
"imagewidth":192,
"margin":0,
"name":"tileset",
"spacing":0,
"tilecount":408,
"tiledversion":"1.8.0",
"tileheight":8,
"tilewidth":8,
"type":"tileset",
"version":"1.8"
}

BIN
assets/demo_player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

View file

@ -0,0 +1,7 @@
*.json:
custom-type: map
name_regex: (.*)\.json map_\1
demo_player.png:
type: bopti-image
name: demo_player_img

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -5,68 +5,64 @@
#define USB_FEATURE 1 #define USB_FEATURE 1
#if USB_FEATURE==1 #if USB_FEATURE==1
#include <gint/usb-ff-bulk.h> #include <gint/usb-ff-bulk.h>
#include <gint/usb.h> #include <gint/usb.h>
#endif //USB_FEATURE #endif //USB_FEATURE
#ifdef COLOR2BIT #if !defined(FXCG50) && defined(COLOR2BIT)
#include <gint/gray.h> #define GRAYMODEOK
#endif //COLOR2BIT #endif
#ifdef GRAYMODEOK
#include <gint/gray.h>
#endif //GRAYMODEOK
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "map.h" #include "map.h"
#include "player.h" #include "player.h"
#include "mapdata.h"
/* Player data (defined in "player.h")*/ /* Player data (defined in "player.h")*/
struct Player MyPlayer = { 10, 5, 100 }; Player MyPlayer = { 10, 5, 0, 0, 100 };
Map *map_level = &map_level0;
/* some global variables */ /* some global variables */
bool exittoOS = false; // set to true when asked for exit bool exittoOS = false; // set to true when asked for exit
bool screenshot = false; // set to true when screenshot is required
bool record = false; // set to true when
bool screenshot = false; // set to true when screenshot is required
bool record = false; // set to true when
/* Key management */ /* Key management */
static void get_inputs( void ) static void get_inputs( void )
{ {
key_event_t ev; key_event_t ev;
while((ev = pollevent()).type != KEYEV_NONE) while((ev = pollevent()).type != KEYEV_NONE){
{
} }
/* Key binding for the Player action */ /* Key binding for the Player action */
/*************************************/
/*************************************/
if(keydown(KEY_EXIT)) exittoOS = true; if(keydown(KEY_EXIT)) exittoOS = true;
/* Player actions - Prototypes in player.h and implementation in player.c */ /* Player actions - Prototypes in player.h and implementation in player.c */
if(keydown(KEY_LEFT)) PlayerLeft(); if(keydown(KEY_LEFT)) PlayerLeft();
if(keydown(KEY_RIGHT)) PlayerRight(); if(keydown(KEY_RIGHT)) PlayerRight();
if(keydown(KEY_UP)) PlayerUp(); if(keydown(KEY_UP)) PlayerUp();
if(keydown(KEY_DOWN)) PlayerDown(); if(keydown(KEY_DOWN)) PlayerDown();
if(keydown(KEY_SHIFT)) PlayerAction(); if(keydown(KEY_SHIFT)) PlayerAction();
/* if USB is enabled - keybinding for screencapture */ /* if USB is enabled - keybinding for screencapture */
#if USB_FEATURE==1 #if USB_FEATURE==1
if(keydown(KEY_7)) screenshot = true; if(keydown(KEY_7)) screenshot = true;
if(keydown(KEY_8)) record = !record; if(keydown(KEY_8)) record = !record;
#endif //USB_FEATURE #endif //USB_FEATURE
} }
@ -76,88 +72,99 @@ static void get_inputs( void )
#if USB_FEATURE==1 #if USB_FEATURE==1
void USB_feature( void ) void USB_feature( void )
{ {
if (screenshot && usb_is_open()) { if (screenshot && usb_is_open()) {
if (!dgray_enabled())
usb_fxlink_screenshot(false);
else
usb_fxlink_screenshot_gray(false);
screenshot = false;
}
if (record && usb_is_open()) { #ifdef GRAYMODEOK // This is a trick, if GRAYMODEOK is defined then we make the code accessible
if (!dgray_enabled())
usb_fxlink_videocapture(false); if (dgray_enabled())
else usb_fxlink_screenshot_gray(false);
usb_fxlink_videocapture_gray(false); else
}
} #endif
usb_fxlink_screenshot(false); // else we just let the usual screeshot function
screenshot = false;
}
if (record && usb_is_open()) {
#ifdef GRAYMODEOK
if (dgray_enabled())
usb_fxlink_videocapture_gray(false);
else
#endif
usb_fxlink_videocapture(false);
}
}
#endif #endif
void GameLogic( void ) void GameLogic(void) {
{ // to be done
} }
int main(void) int main(void) {
{
#if USB_FEATURE==1 #if USB_FEATURE==1
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL}; usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
usb_open(interfaces, GINT_CALL_NULL); usb_open(interfaces, GINT_CALL_NULL);
#endif #endif
/* start grayscale engine */ /* start grayscale engine */
#ifdef COLOR2BIT #ifdef GRAYMODEOK
dgray( DGRAY_ON ); dgray( DGRAY_ON );
#endif #endif
do do
{ {
/* clear screen */ /* clear screen */
dclear(C_WHITE); dclear(C_WHITE);
/* render the map */ /* render the map */
RenderMap(); RenderMap(&MyPlayer, map_level);
PlayerDraw();
/* start the logic of the game */ /* start the logic of the game */
GameLogic(); GameLogic();
/* Screen blit */ /* Screen blit */
dupdate(); dupdate();
/* Screen capture feature if enabled */ /* Screen capture feature if enabled */
#if USB_FEATURE==1 #if USB_FEATURE==1
USB_feature(); USB_feature();
#endif #endif
/* Management of the inputs */ /* Management of the inputs */
get_inputs(); get_inputs();
} }
while (exittoOS == false); // want to exit ? while (exittoOS == false); // want to exit ?
/* shutdown grayengine*/ /* shutdown grayengine*/
#ifdef COLOR2BIT #ifdef GRAYMODEOK
dgray( DGRAY_OFF ); dgray( DGRAY_OFF );
#endif #endif
/* close USB */ /* close USB */
#if USB_FEATURE==1 #if USB_FEATURE==1
usb_close(); usb_close();
#endif #endif
return 1; return 1;
} }

117
src/map.c
View file

@ -1,38 +1,89 @@
#include "map.h" #include "map.h"
#include <gint/display.h> #include <gint/display.h>
extern struct Map map_level0; void RenderMap(Player *player, Map *map_level) {
/* for all Layer (2 in the current configuration: Background is layer 0 and
struct Map *map_level = &map_level0; * foreground is layer 1 ) */
/* x and y will contain the position in the loop. */
void RenderMap( void ) unsigned char x, y;
{ /* The positions where we start drawing the tiles will be in tx and
/* for all Layer (2 in the current configuration: Background is layer 0 and foreground is layer 1 ) */ * ty. */
for (int u = 0; u < map_level->nblayers; u++) unsigned short int tx, ty;
{ /* mx and my will contain how many pixels will be hidden on x and on
/* for each colum */ * y. */
for (int i = 0; i < map_level->w; i++) unsigned char mx, my;
{ /* dw and dh contain the amount of tiles that will be drawn on x and on
/* and each line */ * y. */
for (int j = 0; j < map_level->h; j++) unsigned char dw = DWIDTH/T_WIDTH+1, dh = DHEIGHT/T_HEIGHT+1;
{ /* mw and mh will contain the height and the width of the map. */
/* compute the index */ unsigned short int mw = map_level->w*T_WIDTH, mh = map_level->h*T_HEIGHT;
uint16_t index = j * map_level->w + i; /* tile contains the tile to draw. */
short int tile;
/* get the tile index from the map*/ /* The position where I start drawing */
int16_t currentTile = map_level->layers[u][index]; unsigned short int sx, sy;
/* The position of the tile in the tileset. */
/* currentTile == -1 means nothing to be draw */ unsigned short int xtile, ytile;
if (currentTile != -1) /* The layer we're drawing */
{ unsigned char l;
/* get x and y position in the tileset image */ /* Fix sx. */
uint16_t xtile = (currentTile % map_level->tileset_size) * 8; if(player->x<DWIDTH/2){
uint16_t ytile = (currentTile / map_level->tileset_size) * 8; /* If I can't center the player because I'm near the left border of
* the map. */
/* render */ player->px = player->x;
dsubimage(i * 8, j * 8, map_level->tileset, xtile, ytile, 8, 8, DIMAGE_NONE ); sx = 0;
} }else if(player->x+DWIDTH/2>mw){
} /* If I can't center the player because I'm near the right border of
* the map. */
sx = mw-DWIDTH;
player->px = player->x-sx;
}else{
/* I can center the player. */
player->px = DWIDTH/2;
sx = player->x-player->px;
}
/* Fix sy. */
if(player->y<DHEIGHT/2){
/* If I can't center the player because I'm near the top border of
* the map. */
player->py = player->y;
sy = 0;
}else if(player->y+DHEIGHT/2>mh){
/* If I can't center the player because I'm near the bottom border
* of the map. */
sy = mh-DHEIGHT;
player->py = player->y-sy;
}else{
/* I can center the player. */
player->py = DHEIGHT/2;
sy = player->y-player->py;
}
tx = sx/T_WIDTH;
ty = sy/T_HEIGHT;
mx = sx-tx*T_WIDTH;
my = sy-ty*T_HEIGHT;
for (l = 0; l < map_level->nblayers; l++){
/* Draw a layer of the map on screen. */
for(y=0;y<dh;y++){
for(x=0;x<dw;x++){
/* I get the tile number if his position is inside the map. Then
* I draw it. */
if(tx+x>=0 && tx+x < map_level->w &&
ty+y>=0 && ty+y < map_level->h){
tile = map_level->layers[l][(y+ty) * map_level->w + tx+x];
/* tile == -1 means nothing to be drawn */
if(tile >= 0){
/* get x and y position in the tileset image */
xtile = (tile % map_level->tileset_size) * T_WIDTH;
ytile = (tile / map_level->tileset_size) * T_HEIGHT;
/* render */
dsubimage(x*T_WIDTH-mx, y*T_HEIGHT-my,
map_level->tileset, xtile, ytile, T_WIDTH, T_HEIGHT,
DIMAGE_NONE);
}
}
}
}
} }
}
} }

View file

@ -2,25 +2,33 @@
#define MAP_H #define MAP_H
#ifdef FXCG50
#define T_HEIGHT 16
#define T_WIDTH 16
#else
#define T_HEIGHT 8
#define T_WIDTH 8
#endif
#include <gint/display.h> #include <gint/display.h>
#include "player.h"
void RenderMap(void); typedef struct {
/*width, height and the number of layer of the map*/
int w, h, nblayers;
struct Map { /*the tileset to use*/
bopti_image_t *tileset;
/*width, height and the number of layer of the map*/ int tileset_size;
int w, h, nblayers;
/*the tileset to use*/
bopti_image_t *tileset;
int tileset_size;
/*list of all the tiles*/
short *layers[];
};
/*list of all the tiles*/
short *layers[];
} Map;
void RenderMap(Player *player, Map *map_level);
#endif #endif

7
src/mapdata.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef MAPDATA_H
#define MAPDATA_H
extern Map map_level0;
#endif

View file

@ -1,30 +1,52 @@
#include "player.h" #include "player.h"
#include "map.h" #include "map.h"
#include <gint/display.h>
extern struct player;
extern struct Map *map_level;
void PlayerLeft( void ) #define P_WIDTH 8
{ #define P_HEIGHT 8
#ifdef FXCG50
#define SPEED 3
#else
#define SPEED 1
#endif
extern Player MyPlayer;
extern Map *map_level;
extern bopti_image_t demo_player_img;
void PlayerDraw(void) {
dimage(MyPlayer.px-P_WIDTH/2, MyPlayer.py-P_HEIGHT/2, &demo_player_img);
} }
void PlayerRight( void ) void PlayerLeft(void) {
{ if(MyPlayer.x >= SPEED){
MyPlayer.x-=SPEED;
}
} }
void PlayerUp( void ) void PlayerRight(void) {
{ if(MyPlayer.x <= map_level->w * T_WIDTH - SPEED){
MyPlayer.x+=SPEED;
}
} }
void PlayerDown( void ) void PlayerUp(void) {
{ if(MyPlayer.y >= SPEED){
MyPlayer.y-=SPEED;
}
} }
void PlayerAction( void ) void PlayerDown(void) {
{ if(MyPlayer.y <= map_level->h * T_HEIGHT - SPEED){
MyPlayer.y+=SPEED;
}
}
void PlayerAction(void) {
} }

View file

@ -1,27 +1,26 @@
#ifndef PLAYER_H #ifndef PLAYER_H
#define PLAYER_H #define PLAYER_H
#include <stdint.h>
/* Struct that define player parameters */ /* Struct that define player parameters */
struct Player typedef struct {
{ unsigned short int x, y; /* The position of the player */
uint16_t x, y; unsigned char px, py; /* The position of the player on screen */
uint16_t life; unsigned short int life; /* How many lives the player still has between 0
}; * and 100. */
} Player;
/* This function should be called after drawing the map ! */
void PlayerDraw(void);
void PlayerLeft(void);
void PlayerLeft( void ); void PlayerRight(void);
void PlayerRight( void ); void PlayerUp(void);
void PlayerUp( void ); void PlayerDown(void);
void PlayerDown( void ); void PlayerAction(void);
void PlayerAction( void );
#endif #endif