mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2025-01-04 07:53:39 +01:00
153 lines
2.8 KiB
C
153 lines
2.8 KiB
C
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
|
|
#define USB_FEATURE 1
|
|
|
|
#if USB_FEATURE==1
|
|
#include <gint/usb-ff-bulk.h>
|
|
#include <gint/usb.h>
|
|
#endif //USB_FEATURE
|
|
|
|
|
|
#ifdef COLOR2BIT
|
|
#include <gint/gray.h>
|
|
#endif //COLOR2BIT
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "map.h"
|
|
#include "player.h"
|
|
#include "mapdata.h"
|
|
|
|
/* Player data (defined in "player.h")*/
|
|
Player MyPlayer = { 10, 5, 0, 0, 100 };
|
|
Map *map_level = &map_level0;
|
|
|
|
/* some global variables */
|
|
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
|
|
|
|
/* Key management */
|
|
|
|
static void get_inputs( void )
|
|
{
|
|
key_event_t ev;
|
|
while((ev = pollevent()).type != KEYEV_NONE){
|
|
|
|
}
|
|
|
|
/* Key binding for the Player action */
|
|
|
|
/*************************************/
|
|
|
|
if(keydown(KEY_EXIT)) exittoOS = true;
|
|
|
|
/* Player actions - Prototypes in player.h and implementation in player.c */
|
|
if(keydown(KEY_LEFT)) PlayerLeft();
|
|
if(keydown(KEY_RIGHT)) PlayerRight();
|
|
if(keydown(KEY_UP)) PlayerUp();
|
|
if(keydown(KEY_DOWN)) PlayerDown();
|
|
if(keydown(KEY_SHIFT)) PlayerAction();
|
|
|
|
/* if USB is enabled - keybinding for screencapture */
|
|
|
|
#if USB_FEATURE==1
|
|
|
|
if(keydown(KEY_7)) screenshot = true;
|
|
if(keydown(KEY_8)) record = !record;
|
|
|
|
#endif //USB_FEATURE
|
|
}
|
|
|
|
|
|
/* screen capture management code */
|
|
|
|
#if USB_FEATURE==1
|
|
|
|
void USB_feature( void )
|
|
{
|
|
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()) {
|
|
if (!dgray_enabled())
|
|
usb_fxlink_videocapture(false);
|
|
else
|
|
usb_fxlink_videocapture_gray(false);
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
void GameLogic(void) {
|
|
|
|
}
|
|
|
|
|
|
int main(void) {
|
|
|
|
#if USB_FEATURE==1
|
|
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
|
|
usb_open(interfaces, GINT_CALL_NULL);
|
|
#endif
|
|
|
|
|
|
/* start grayscale engine */
|
|
|
|
#ifdef COLOR2BIT
|
|
dgray( DGRAY_ON );
|
|
#endif
|
|
|
|
|
|
do
|
|
{
|
|
/* clear screen */
|
|
dclear(C_WHITE);
|
|
|
|
/* render the map */
|
|
RenderMap(&MyPlayer, map_level);
|
|
PlayerDraw();
|
|
|
|
/* start the logic of the game */
|
|
GameLogic();
|
|
|
|
/* Screen blit */
|
|
dupdate();
|
|
|
|
/* Screen capture feature if enabled */
|
|
#if USB_FEATURE==1
|
|
USB_feature();
|
|
#endif
|
|
|
|
/* Management of the inputs */
|
|
get_inputs();
|
|
|
|
}
|
|
while (exittoOS == false); // want to exit ?
|
|
|
|
|
|
|
|
/* shutdown grayengine*/
|
|
#ifdef COLOR2BIT
|
|
dgray( DGRAY_OFF );
|
|
#endif
|
|
|
|
|
|
/* close USB */
|
|
#if USB_FEATURE==1
|
|
usb_close();
|
|
#endif
|
|
|
|
|
|
return 1;
|
|
}
|