Merge branch 'master' of github.com:RobLoach/ChaiLove into travis

This commit is contained in:
Rob Loach 2017-10-30 02:32:06 -04:00
commit 3cba72fb1e
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
68 changed files with 370 additions and 349 deletions

View File

@ -1,6 +1,6 @@
# LICENSE
[ChaiGame](http://github.com/RobLoach/ChaiGame) is released under the MIT License:
[ChaiLove](http://github.com/RobLoach/ChaiLove) is released under the MIT License:
> Copyright (C) 2017+ [Rob Loach](http://robloach.net)
>

View File

@ -1,4 +1,4 @@
TARGET_NAME := chaigame
TARGET_NAME := chailove
include Makefile.libretro
include Makefile.common

View File

@ -1,13 +1,13 @@
# ChaiGame
# ChaiLove
SOURCES_CXX += $(wildcard \
src/*.cpp \
src/chaigame/*.cpp \
src/chailove/*.cpp \
test/*.cpp \
src/chaigame/graphics/*.cpp \
src/chaigame/input/*.cpp \
src/chaigame/audio/*.cpp \
src/chaigame/system/*.cpp \
src/chailove/graphics/*.cpp \
src/chailove/input/*.cpp \
src/chailove/audio/*.cpp \
src/chailove/system/*.cpp \
)
# PhysFS
@ -29,13 +29,13 @@ SOURCES_C += $(wildcard \
# SDL
ifeq ($(platform), win)
SDL_SOURCES_C += $(wildcard ./vendor/sdl-libretro/src/*.c ./vendor/sdl-libretro/src/audio/*.c ./vendor/sdl-libretro/src/cdrom/dummy/*.c ./vendor/sdl-libretro/src/cdrom/*.c ./vendor/sdl-libretro/src/cpuinfo/*.c ./vendor/sdl-libretro/src/events/*.c ./vendor/sdl-libretro/src/file/*.c ./vendor/sdl-libretro/src/stdlib/*.c ./vendor/sdl-libretro/src/thread/*.c ./vendor/sdl-libretro/src/timer/*.c ./vendor/sdl-libretro/src/video/*.c ./vendor/sdl-libretro/src/joystick/*.c ./vendor/sdl-libretro/src/video/libretro/*.c ./vendor/sdl-libretro/src/joystick/libretro/*.c ./vendor/sdl-libretro/src/timer/libretro/*.c ./vendor/sdl-libretro/src/audio/libretro/*.c ./vendor/sdl-libretro/src/thread/win32/SDL_sysmutex.c ./vendor/sdl-libretro/src/thread/win32/SDL_syssem.c ./vendor/sdl-libretro/src/thread/win32/SDL_systhread.c ./vendor/sdl-libretro/src/thread/generic/SDL_syscond.c ./vendor/sdl-libretro/src/loadso/dummy/*.c)
SOURCES_C += $(wildcard ./vendor/sdl-libretro/src/*.c ./vendor/sdl-libretro/src/audio/*.c ./vendor/sdl-libretro/src/cdrom/dummy/*.c ./vendor/sdl-libretro/src/cdrom/*.c ./vendor/sdl-libretro/src/cpuinfo/*.c ./vendor/sdl-libretro/src/events/*.c ./vendor/sdl-libretro/src/file/*.c ./vendor/sdl-libretro/src/stdlib/*.c ./vendor/sdl-libretro/src/thread/*.c ./vendor/sdl-libretro/src/timer/*.c ./vendor/sdl-libretro/src/video/*.c ./vendor/sdl-libretro/src/joystick/*.c ./vendor/sdl-libretro/src/video/libretro/*.c ./vendor/sdl-libretro/src/joystick/libretro/*.c ./vendor/sdl-libretro/src/timer/libretro/*.c ./vendor/sdl-libretro/src/audio/libretro/*.c ./vendor/sdl-libretro/src/thread/win32/SDL_sysmutex.c ./vendor/sdl-libretro/src/thread/win32/SDL_syssem.c ./vendor/sdl-libretro/src/thread/win32/SDL_systhread.c ./vendor/sdl-libretro/src/thread/generic/SDL_syscond.c ./vendor/sdl-libretro/src/loadso/dummy/*.c)
else
SDL_SOURCES_C += $(wildcard ./vendor/sdl-libretro/src/*.c ./vendor/sdl-libretro/src/audio/*.c ./vendor/sdl-libretro/src/cdrom/dummy/*.c ./vendor/sdl-libretro/src/cdrom/*.c ./vendor/sdl-libretro/src/cpuinfo/*.c ./vendor/sdl-libretro/src/events/*.c ./vendor/sdl-libretro/src/file/*.c ./vendor/sdl-libretro/src/stdlib/*.c ./vendor/sdl-libretro/src/thread/*.c ./vendor/sdl-libretro/src/timer/*.c ./vendor/sdl-libretro/src/video/*.c ./vendor/sdl-libretro/src/joystick/*.c ./vendor/sdl-libretro/src/video/libretro/*.c ./vendor/sdl-libretro/src/thread/generic/*.c ./vendor/sdl-libretro/src/joystick/libretro/*.c ./vendor/sdl-libretro/src/timer/libretro/*.c ./vendor/sdl-libretro/src/audio/libretro/*.c ./vendor/sdl-libretro/src/loadso/dummy/*.c)
SOURCES_C += $(wildcard ./vendor/sdl-libretro/src/*.c ./vendor/sdl-libretro/src/audio/*.c ./vendor/sdl-libretro/src/cdrom/dummy/*.c ./vendor/sdl-libretro/src/cdrom/*.c ./vendor/sdl-libretro/src/cpuinfo/*.c ./vendor/sdl-libretro/src/events/*.c ./vendor/sdl-libretro/src/file/*.c ./vendor/sdl-libretro/src/stdlib/*.c ./vendor/sdl-libretro/src/thread/*.c ./vendor/sdl-libretro/src/timer/*.c ./vendor/sdl-libretro/src/video/*.c ./vendor/sdl-libretro/src/joystick/*.c ./vendor/sdl-libretro/src/video/libretro/*.c ./vendor/sdl-libretro/src/thread/generic/*.c ./vendor/sdl-libretro/src/joystick/libretro/*.c ./vendor/sdl-libretro/src/timer/libretro/*.c ./vendor/sdl-libretro/src/audio/libretro/*.c ./vendor/sdl-libretro/src/loadso/dummy/*.c)
endif
FLAGS += -DSDL_THREADS_DISABLED -DSDL_CDROM_DISABLED
OBJECTS += $(SDL_SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o) $(SOURCES_C:.c=.o)
OBJECTS += $(SOURCES_CXX:.cpp=.o) $(SOURCES_C:.c=.o)
# Build all the dependencies, and the core.
all: | dependencies $(TARGET)

View File

@ -1,25 +1,25 @@
# ChaiGame [![Build Status](https://travis-ci.org/RobLoach/ChaiGame.svg?branch=master)](https://travis-ci.org/RobLoach/ChaiGame) [![Build Status](https://img.shields.io/badge/platform-libretro-green.png)](http://buildbot.fiveforty.net/admin/buildbot/build/?name=chaigame)
# ChaiLove [![Build Status](https://travis-ci.org/RobLoach/ChaiLove.svg?branch=master)](https://travis-ci.org/RobLoach/ChaiLove) [![platform libretro](https://img.shields.io/badge/platform-libretro-brightgreen.svg)](http://buildbot.fiveforty.net/admin/buildbot/build/?name=chailove)
Framework to make 2D games with [ChaiScript](http://chaiscript.com/) and [libretro](https://www.libretro.com)/[RetroArch](http://retroarch.com).
![ChaiGame Benchmark Screenshot](examples/benchmark/screenshot.png)
![ChaiLove Benchmark Screenshot](examples/benchmark/screenshot.png)
## Sample Games
## Games
- [Floppy Bird](https://github.com/RobLoach/ChaiGame-FloppyBird)
- [Floppy Bird](https://github.com/RobLoach/ChaiLove-FloppyBird)
## Usage
ChaiGame is a [libretro](https://www.libretro.com/) core, which can be run through [RetroArch](http://retroarch.com/). To play [Floppy Bird](https://github.com/RobLoach/ChaiGame-FloppyBird), run RetroArch and...
ChaiLove is a [libretro](https://www.libretro.com/) core, which can be run through [RetroArch](http://retroarch.com/). To play [Floppy Bird](https://github.com/RobLoach/ChaiLove-FloppyBird), run RetroArch and...
1. Run [RetroArch](http://retroarch.com/)
2. Download the ChaiGame core through RetroArch at *Online Updater**Core Updator* → *ChaiGame*
3. Download *Floppy Bird* through RetroArch at *Online Updater**Content Downloader**ChaiGame* → *Floppy Bird*
4. Launch the game over through *Load Content**Downloads* → *Floppy Bird.chaigame*
2. Download the ChaiLove core through RetroArch at *Online Updater**Core Updator* → *ChaiLove*
3. Download *Floppy Bird* through RetroArch at *Online Updater**Content Downloader**ChaiLove* → *Floppy Bird*
4. Launch the game over through *Load Content**Downloads* → *Floppy Bird.chailove*
## API
ChaiGame is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a Hello World sample application:
ChaiLove is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a simple Hello World sample application:
``` lua
global logo
@ -41,12 +41,12 @@ def update(delta) {
To run it, execute the following:
```
retroarch -L chaigame_libretro.so main.chai
retroarch -L chailove_libretro.so main.chai
```
## Development
Building ChaiGame takes some time, so have patience. Use the following command to compile the core:
Building ChaiLove takes some time, so have patience. Use the following command to compile the core:
```
make

View File

@ -1,11 +0,0 @@
display_name = "ChaiGame"
authors = "Rob Loach"
supported_extensions = "chai|chaigame"
corename = "ChaiGame"
categories = "Game engine"
systemname = "ChaiGame"
database = "ChaiGame"
license = "MIT"
permissions = ""
display_version = "0.4.0"
supports_no_game = "false"

11
chailove_libretro.info Normal file
View File

@ -0,0 +1,11 @@
display_name = "ChaiLove"
authors = "Rob Loach"
supported_extensions = "chai|chailove|chaigame"
corename = "ChaiLove"
categories = "Game engine"
systemname = "ChaiLove"
database = "ChaiLove"
license = "MIT"
permissions = ""
display_version = "0.5.0"
supports_no_game = "false"

2
configure vendored
View File

@ -1,3 +1,3 @@
#!/bin/sh
PACKAGE_NAME=libretro-chaigame
PACKAGE_NAME=libretro-chailove

View File

@ -1,5 +1,5 @@
# ChaiGame Examples
# ChaiLove Examples
Provides a few examples of usage of ChaiGame. To run them, execute:
Provides a few examples of usage of ChaiLove. To run them, execute:
retroarch -L chaigame_libretro.so examples/snake/main.chai
retroarch -L chailove_libretro.so examples/snake/main.chai

View File

@ -1,5 +1,5 @@
/**
* ChaiGame Benchmark
* ChaiLove Benchmark
*/
// The Sprites and the image to load.

View File

@ -1,5 +1,5 @@
/**
* ChaiGame: Pong
* ChaiLove: Pong
*/
global players = []
global pongSound

View File

@ -1,5 +1,5 @@
/**
* ChaiGame: Snake
* ChaiLove: Snake
*/
global WIDTH
global HEIGHT

View File

@ -1,7 +1,7 @@
/**
* ChaiGame: Example
* ChaiLove: Example
*
* Small example of what a ChaiGame script could look like.
* Small example of what a ChaiLove script could look like.
*/
global x = 10.0f
global y = 10.0f

View File

@ -1,75 +0,0 @@
#ifndef CHAIGAME_GAME_H
#define CHAIGAME_GAME_H
#define CHAIGAME_VERSION_MAJOR 0
#define CHAIGAME_VERSION_MINOR 4
#define CHAIGAME_VERSION_PATCH 0
#define CHAIGAME_VERSION_STRING "0.4.0"
#include "SDL.h"
#include "libretro.h"
#include "chaigame/keyboard.h"
#include "chaigame/system/Config.h"
#include "chaigame/script.h"
#include "chaigame/filesystem.h"
#include "chaigame/graphics.h"
#include "chaigame/image.h"
#include "chaigame/system.h"
#include "chaigame/sound.h"
#include "chaigame/font.h"
#include "chaigame/timer.h"
#include "chaigame/audio.h"
#include "chaigame/joystick.h"
#include "chaigame/mouse.h"
#include "chaigame/window.h"
#include "chaigame/math.h"
#include "chaigame/event.h"
#ifdef __HAVE_TESTS__
#include "test/Test.h"
#endif
class ChaiGame {
public:
static ChaiGame* getInstance();
static ChaiGame* m_instance;
static void destroy();
static retro_input_state_t input_state_cb;
static retro_input_poll_t input_poll_cb;
chaigame::Config config;
chaigame::keyboard keyboard;
chaigame::script* script;
chaigame::filesystem filesystem;
chaigame::graphics graphics;
chaigame::image image;
chaigame::system system;
chaigame::sound sound;
chaigame::font font;
chaigame::timer timer;
chaigame::audio audio;
chaigame::joystick joystick;
chaigame::mouse mouse;
chaigame::math math;
chaigame::window window;
chaigame::event event;
void quit(void);
bool load(const std::string& file);
bool update();
void draw();
void reset();
std::string savestate();
bool loadstate(const std::string& data);
uint32_t *videoBuffer;
SDL_Surface* screen;
SDL_Event sdlEvent;
#ifdef __HAVE_TESTS__
Test test;
#endif
};
#endif

View File

@ -3,24 +3,24 @@
#include "SDL.h"
#include "libretro.h"
#include "ChaiGame.h"
#include "ChaiLove.h"
ChaiGame* ChaiGame::m_instance = NULL;
retro_input_state_t ChaiGame::input_state_cb = NULL;
retro_input_poll_t ChaiGame::input_poll_cb = NULL;
ChaiLove* ChaiLove::m_instance = NULL;
retro_input_state_t ChaiLove::input_state_cb = NULL;
retro_input_poll_t ChaiLove::input_poll_cb = NULL;
void ChaiGame::destroy() {
void ChaiLove::destroy() {
m_instance = NULL;
}
ChaiGame* ChaiGame::getInstance() {
ChaiLove* ChaiLove::getInstance() {
if (!m_instance) {
m_instance = new ChaiGame;
m_instance = new ChaiLove;
}
return m_instance;
}
void ChaiGame::quit(void) {
void ChaiLove::quit(void) {
// Quit all the subsystems.
joystick.unload();
font.unload();
@ -31,17 +31,17 @@ void ChaiGame::quit(void) {
std::cout << "Finish" << std::endl;
}
bool ChaiGame::load(const std::string& file) {
// Display a welcome message from ChaiGame.
bool ChaiLove::load(const std::string& file) {
// Display a welcome message from ChaiLove.
#ifndef GIT_VERSION
#define GIT_VERSION ""
#endif
std::string version = CHAIGAME_VERSION_STRING GIT_VERSION;
std::cout << "ChaiGame " << version.c_str() << std::endl;
std::string version = CHAILOVE_VERSION_STRING GIT_VERSION;
std::cout << "ChaiLove " << version.c_str() << std::endl;
// Initalize all the subsystems.
filesystem.init(file);
script = new chaigame::script(file);
script = new chailove::script(file);
script->conf(config);
#ifdef __HAVE_TESTS__
@ -70,7 +70,7 @@ bool ChaiGame::load(const std::string& file) {
return true;
}
bool ChaiGame::update() {
bool ChaiLove::update() {
if (event.quitstatus) {
return false;
}
@ -113,16 +113,16 @@ bool ChaiGame::update() {
/**
* Reset the current game.
*/
void ChaiGame::reset() {
void ChaiLove::reset() {
// Tell the script that we are to reset the game.
std::cout << "[game] Reset" << std::endl;
script->reset();
}
/**
* Render the ChaiGame.
* Render the ChaiLove.
*/
void ChaiGame::draw() {
void ChaiLove::draw() {
if (!event.quitstatus) {
// Clear the screen.
graphics.clear();
@ -144,13 +144,13 @@ void ChaiGame::draw() {
/**
* Tell the script to return a string representing the game data.
*/
std::string ChaiGame::savestate() {
std::string ChaiLove::savestate() {
return script->savestate();
}
/**
* Ask the script to load the given string.
*/
bool ChaiGame::loadstate(const std::string& data) {
bool ChaiLove::loadstate(const std::string& data) {
return script->loadstate(data);
}

75
src/ChaiLove.h Normal file
View File

@ -0,0 +1,75 @@
#ifndef CHAILOVE_GAME_H
#define CHAILOVE_GAME_H
#define CHAILOVE_VERSION_MAJOR 0
#define CHAILOVE_VERSION_MINOR 5
#define CHAILOVE_VERSION_PATCH 0
#define CHAILOVE_VERSION_STRING "0.5.0"
#include "SDL.h"
#include "libretro.h"
#include "chailove/keyboard.h"
#include "chailove/system/Config.h"
#include "chailove/script.h"
#include "chailove/filesystem.h"
#include "chailove/graphics.h"
#include "chailove/image.h"
#include "chailove/system.h"
#include "chailove/sound.h"
#include "chailove/font.h"
#include "chailove/timer.h"
#include "chailove/audio.h"
#include "chailove/joystick.h"
#include "chailove/mouse.h"
#include "chailove/window.h"
#include "chailove/math.h"
#include "chailove/event.h"
#ifdef __HAVE_TESTS__
#include "test/Test.h"
#endif
class ChaiLove {
public:
static ChaiLove* getInstance();
static ChaiLove* m_instance;
static void destroy();
static retro_input_state_t input_state_cb;
static retro_input_poll_t input_poll_cb;
chailove::Config config;
chailove::keyboard keyboard;
chailove::script* script;
chailove::filesystem filesystem;
chailove::graphics graphics;
chailove::image image;
chailove::system system;
chailove::sound sound;
chailove::font font;
chailove::timer timer;
chailove::audio audio;
chailove::joystick joystick;
chailove::mouse mouse;
chailove::math math;
chailove::window window;
chailove::event event;
void quit(void);
bool load(const std::string& file);
bool update();
void draw();
void reset();
std::string savestate();
bool loadstate(const std::string& data);
uint32_t *videoBuffer;
SDL_Surface* screen;
SDL_Event sdlEvent;
#ifdef __HAVE_TESTS__
Test test;
#endif
};
#endif

View File

@ -1,12 +0,0 @@
#ifndef CHAIGAME_UTILITY_AUDIOSTATE_H
#define CHAIGAME_UTILITY_AUDIOSTATE_H
namespace chaigame {
enum AudioState {
Stopped = 0,
Paused,
Playing
};
}
#endif

View File

@ -1,16 +0,0 @@
#ifndef CHAIGAME_IMAGE_H
#define CHAIGAME_IMAGE_H
#include "graphics/ImageData.h"
#include <string>
namespace chaigame {
class image {
public:
bool load();
bool unload();
chaigame::ImageData* newImageData(const std::string& filename);
};
}
#endif

View File

@ -3,11 +3,11 @@
#include "audio/SoundData.h"
#include "audio/AudioState.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include "sound.h"
#include "physfs.h"
namespace chaigame {
namespace chailove {
void audio::play(SoundData* soundData) {
if (soundData) {
soundData->play();
@ -17,14 +17,14 @@ namespace chaigame {
SoundData* audio::newSource(const std::string& filename) {
SoundData* newSound = new SoundData(filename);
if (newSound->isLoaded()) {
ChaiGame::getInstance()->sound.sounds.push_back(newSound);
ChaiLove::getInstance()->sound.sounds.push_back(newSound);
return newSound;
}
return NULL;
}
void audio::mixer_render(int16_t *buffer) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
// Clear buffer
memset(buffer, 0, AUDIO_FRAMES * 2 * sizeof(int16_t));
for (std::vector<SoundData*>::size_type i = 0; i != app->sound.sounds.size(); i++) {

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_AUDIO_H
#define CHAIGAME_AUDIO_H
#ifndef CHAILOVE_AUDIO_H
#define CHAILOVE_AUDIO_H
#include "audio/SoundData.h"
#include "sound.h"
namespace chaigame {
namespace chailove {
class audio {
public:
void play(SoundData* soundData);

View File

@ -0,0 +1,12 @@
#ifndef CHAILOVE_UTILITY_AUDIOSTATE_H
#define CHAILOVE_UTILITY_AUDIOSTATE_H
namespace chailove {
enum AudioState {
Stopped = 0,
Paused,
Playing
};
}
#endif

View File

@ -3,14 +3,14 @@
//#include "SDL_mixer.h"
#include <string>
#include "../../ChaiGame.h"
#include "../../ChaiLove.h"
#include "AudioState.h"
#include "physfs.h"
namespace chaigame {
namespace chailove {
SoundData::SoundData(const std::string& filename) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
PHYSFS_file* file = app->filesystem.openFile(filename);
if (file == NULL) {
return;

View File

@ -1,5 +1,5 @@
#ifndef CHAIGAME_UTILITY_SOUNDDATA_H
#define CHAIGAME_UTILITY_SOUNDDATA_H
#ifndef CHAILOVE_UTILITY_SOUNDDATA_H
#define CHAILOVE_UTILITY_SOUNDDATA_H
//#include "SDL.h"
//#include "SDL_mixer.h"
@ -30,7 +30,7 @@ typedef struct
wavhead_t head;
} snd_SoundData;
namespace chaigame {
namespace chailove {
class SoundData {
public:
SoundData(const std::string& filename);

View File

@ -1,6 +1,6 @@
#include "event.h"
namespace chaigame {
namespace chailove {
void event::quit() {
quitstatus = true;
}

View File

@ -1,7 +1,7 @@
#ifndef CHAIGAME_EVENT_H
#define CHAIGAME_EVENT_H
#ifndef CHAILOVE_EVENT_H
#define CHAILOVE_EVENT_H
namespace chaigame {
namespace chailove {
class event {
public:
void quit();

View File

@ -4,18 +4,18 @@
#include "filesystem.h"
#include "vendor/physfs/extras/physfsrwops.h"
#include "vendor/filesystem/filesystem/path.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include <iostream>
using namespace filesystem;
namespace chaigame {
namespace chailove {
bool filesystem::init(const std::string& file) {
PHYSFS_init(NULL);
// Check if we are simply running the ChaiGame.
// Check if we are simply running the ChaiLove.
if (file.empty()) {
return mount(".", "/");
}
@ -27,7 +27,7 @@ namespace chaigame {
std::string parentPath(parent.str());
// Allow loading from an Archive.
if (extension == "chaigame" || extension == "zip") {
if (extension == "chailove" || extension == "zip") {
return mount(file.c_str(), "/");
}
@ -39,12 +39,12 @@ namespace chaigame {
}
bool filesystem::load(const std::string& file) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
return app->script->loadModule(file);
}
bool filesystem::exists(const std::string& file) {
return PHYSFS_exists(file.c_str()) != 0;
return PHYSFS_exists(file.c_str()) > 0;
}
int filesystem::getSize(const std::string& file) {

View File

@ -1,12 +1,12 @@
#ifndef CHAIGAME_FILESYSTEM_H
#define CHAIGAME_FILESYSTEM_H
#ifndef CHAILOVE_FILESYSTEM_H
#define CHAILOVE_FILESYSTEM_H
#include <string>
#include <vector>
#include "SDL.h"
#include "physfs.h"
namespace chaigame {
namespace chailove {
class filesystem {
public:
bool load(const std::string& file);

View File

@ -4,7 +4,7 @@
#include "font.h"
#include "graphics/Font.h"
namespace chaigame {
namespace chailove {
bool font::load() {
/*int result = TTF_Init();
if(result == -1) {

View File

@ -1,9 +1,9 @@
#ifndef CHAIGAME_FONT_H
#define CHAIGAME_FONT_H
#ifndef CHAILOVE_FONT_H
#define CHAILOVE_FONT_H
#include "graphics/Font.h"
namespace chaigame {
namespace chailove {
class font {
public:
bool load();

View File

@ -4,19 +4,19 @@
#include <SDL_gfxPrimitives.h>
#include <SDL_gfxBlitFunc.h>
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include "graphics/ImageData.h"
#include "graphics/Image.h"
#include "graphics/Font.h"
namespace chaigame {
namespace chailove {
graphics::graphics() {
setFont();
}
SDL_Surface* graphics::getScreen() {
return ChaiGame::getInstance()->screen;
return ChaiLove::getInstance()->screen;
}
bool graphics::load() {

View File

@ -1,5 +1,5 @@
#ifndef CHAIGAME_GRAPHICS_H
#define CHAIGAME_GRAPHICS_H
#ifndef CHAILOVE_GRAPHICS_H
#define CHAILOVE_GRAPHICS_H
#include "SDL.h"
#include "SDL_gfxPrimitives.h"
@ -8,7 +8,7 @@
#include "graphics/Quad.h"
#include "graphics/Font.h"
namespace chaigame {
namespace chailove {
class graphics {
public:

View File

@ -4,11 +4,11 @@
//#include "SDL_ttf.h"
#include <SDL_gfxPrimitives.h>
#include <SDL_fnt.h>
#include "../../ChaiGame.h"
#include "../../ChaiLove.h"
#include "ImageData.h"
namespace chaigame {
namespace chailove {
Font::Font() {
// Nothing.
}
@ -29,9 +29,9 @@ namespace chaigame {
}
Font::Font(const std::string& filename, int ptsize) {
printf("TTF fonts are not supported by ChaiGame, currently.");
printf("TTF fonts are not supported by ChaiLove, currently.");
/*
SDL_RWops* rwops = ChaiGame::getInstance()->filesystem.openRW(filename);
SDL_RWops* rwops = ChaiLove::getInstance()->filesystem.openRW(filename);
if (rwops) {
TTF_Font* newFont = TTF_OpenFontRW(rwops, 1, ptsize);
if (!newFont) {
@ -112,7 +112,7 @@ namespace chaigame {
}
void Font::print(const std::string& text, int x, int y, int r, int g, int b, int a) {
SDL_Surface* screen = ChaiGame::getInstance()->screen;
SDL_Surface* screen = ChaiLove::getInstance()->screen;
/*
// Attempt to render the TTF Font.

View File

@ -1,5 +1,5 @@
#ifndef CHAIGAME_UTILITY_FONT_H
#define CHAIGAME_UTILITY_FONT_H
#ifndef CHAILOVE_UTILITY_FONT_H
#define CHAILOVE_UTILITY_FONT_H
#include "SDL.h"
//#include "SDL_ttf.h"
@ -7,7 +7,7 @@
#include "SDL_fnt.h"
#include "ImageData.h"
namespace chaigame {
namespace chailove {
class Font {
public:
Font();

View File

@ -1,5 +1,5 @@
#include "Image.h"
namespace chaigame {
namespace chailove {
// Nothing.
}

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_UTILITY_IMAGE_H
#define CHAIGAME_UTILITY_IMAGE_H
#ifndef CHAILOVE_UTILITY_IMAGE_H
#define CHAILOVE_UTILITY_IMAGE_H
#include <string>
#include "ImageData.h"
namespace chaigame {
namespace chailove {
class Image : public ImageData {
using ImageData::ImageData;

View File

@ -5,10 +5,10 @@
#include <iostream>
#include <string>
#include "../../ChaiGame.h"
#include "../../ChaiLove.h"
namespace chaigame {
namespace chailove {
ImageData::ImageData(SDL_RWops* rw) {
loadFromRW(rw);
@ -32,7 +32,7 @@ namespace chaigame {
}
// Optimize the image to the display format.
ChaiGame* game = ChaiGame::getInstance();
ChaiLove* game = ChaiLove::getInstance();
SDL_Surface* optimizedImage = NULL;
if (game->config.options["alphablending"]) {
optimizedImage = SDL_DisplayFormatAlpha(surface);
@ -65,7 +65,7 @@ namespace chaigame {
}
ImageData::ImageData(const std::string& filename) {
SDL_RWops* image = ChaiGame::getInstance()->filesystem.openRW(filename);
SDL_RWops* image = ChaiLove::getInstance()->filesystem.openRW(filename);
loadFromRW(image);
}

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_UTILITY_IMAGEDATA_H
#define CHAIGAME_UTILITY_IMAGEDATA_H
#ifndef CHAILOVE_UTILITY_IMAGEDATA_H
#define CHAILOVE_UTILITY_IMAGEDATA_H
#include <SDL.h>
#include <string>
namespace chaigame {
namespace chailove {
class ImageData {
public:
SDL_Surface* surface;

View File

@ -1,5 +1,5 @@
#include "Point.h"
namespace chaigame {
namespace chailove {
// Nothing.
}

View File

@ -1,7 +1,7 @@
#ifndef CHAIGAME_UTILITY_POINT_H
#define CHAIGAME_UTILITY_POINT_H
#ifndef CHAILOVE_UTILITY_POINT_H
#define CHAILOVE_UTILITY_POINT_H
namespace chaigame {
namespace chailove {
struct Point {
Point() : x(0), y(0) {}
Point(int val) : x(val), y(val) {}

View File

@ -2,7 +2,7 @@
#include "SDL.h"
namespace chaigame {
namespace chailove {
Quad::Quad(int t_x, int t_y, int t_width, int t_height, int t_sw, int t_sh)
: x(t_x), y(t_y), width(t_width), height(t_height), sw(t_sw), sh(t_sh) {
// Nothing.

View File

@ -1,9 +1,9 @@
#ifndef CHAIGAME_UTILITY_QUAD_H
#define CHAIGAME_UTILITY_QUAD_H
#ifndef CHAILOVE_UTILITY_QUAD_H
#define CHAILOVE_UTILITY_QUAD_H
#include "SDL.h"
namespace chaigame {
namespace chailove {
class Quad {
public:
int x, y, width, height, sw, sh;

View File

@ -2,9 +2,9 @@
#include <string>
#include "graphics/ImageData.h"
namespace chaigame {
chaigame::ImageData* image::newImageData(const std::string& filename) {
ImageData* image = new chaigame::ImageData(filename);
namespace chailove {
chailove::ImageData* image::newImageData(const std::string& filename) {
ImageData* image = new chailove::ImageData(filename);
if (image->loaded()) {
return image;
}

16
src/chailove/image.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef CHAILOVE_IMAGE_H
#define CHAILOVE_IMAGE_H
#include "graphics/ImageData.h"
#include <string>
namespace chailove {
class image {
public:
bool load();
bool unload();
chailove::ImageData* newImageData(const std::string& filename);
};
}
#endif

View File

@ -1,9 +1,9 @@
#include "Joystick.h"
#include "SDL.h"
#include "../../ChaiGame.h"
#include "../../ChaiLove.h"
#include <string>
namespace chaigame {
namespace chailove {
std::string Joystick::getName() {
return name;
}
@ -34,7 +34,7 @@ namespace chaigame {
}
bool Joystick::isDown(int button) {
return (bool)ChaiGame::getInstance()->joystick.joystick_cache[index][button];
return (bool)ChaiLove::getInstance()->joystick.joystick_cache[index][button];
// TODO: Switch from libretro joysticks to SDL.
/*if (joy) {
@ -45,7 +45,7 @@ namespace chaigame {
}
bool Joystick::isDown(const std::string& button) {
int key = ChaiGame::getInstance()->joystick.getButtonKey(button);
int key = ChaiLove::getInstance()->joystick.getButtonKey(button);
return isDown(key);
}

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_UTILITY_JOYSTICK_H
#define CHAIGAME_UTILITY_JOYSTICK_H
#ifndef CHAILOVE_UTILITY_JOYSTICK_H
#define CHAILOVE_UTILITY_JOYSTICK_H
//#include "SDL.h"
#include <string>
namespace chaigame {
namespace chailove {
class Joystick {
public:
//Joystick(int num, SDL_Joystick* joystick);

View File

@ -4,11 +4,11 @@
#include <vector>
#include <libretro.h>
#include "input/Joystick.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include <iostream>
namespace chaigame {
namespace chailove {
Joystick* joystick::getJoysticks() {
return joysticks;
}
@ -67,7 +67,7 @@ namespace chaigame {
// Loop through each button.
for (u = 0; u < 14; u++) {
// Retrieve the state of the button.
state = ChaiGame::input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, u);
state = ChaiLove::input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, u);
// Check if there's a change of state.
if (joystick_cache[i][u] != state) {
@ -75,10 +75,10 @@ namespace chaigame {
std::string name = getButtonName(u);
if (state == 1) {
ChaiGame::getInstance()->script->joystickpressed(i, name);
ChaiLove::getInstance()->script->joystickpressed(i, name);
}
else if (state == 0) {
ChaiGame::getInstance()->script->joystickreleased(i, name);
ChaiLove::getInstance()->script->joystickreleased(i, name);
}
}
}

View File

@ -1,11 +1,11 @@
#ifndef CHAIGAME_JOYSTICK_H
#define CHAIGAME_JOYSTICK_H
#ifndef CHAILOVE_JOYSTICK_H
#define CHAILOVE_JOYSTICK_H
#include "input/Joystick.h"
#include "SDL.h"
#include <string>
namespace chaigame {
namespace chailove {
class joystick {
public:
void load();

View File

@ -4,7 +4,7 @@
#include <iostream>
//#include "SDL.h"
namespace chaigame {
namespace chailove {
bool keyboard::isDown(int key) {
return (bool)keys[key];

View File

@ -1,11 +1,11 @@
#ifndef CHAIGAME_KEYBOARD_H
#define CHAIGAME_KEYBOARD_H
#ifndef CHAILOVE_KEYBOARD_H
#define CHAILOVE_KEYBOARD_H
#include <string>
#include <map>
#include "SDL.h"
namespace chaigame {
namespace chailove {
class keyboard {
public:
Uint8* keys;

View File

@ -2,7 +2,7 @@
#include <cstdlib>
#include <ctime>
namespace chaigame {
namespace chailove {
bool math::load() {
setRandomSeed((int)time(0));

View File

@ -1,7 +1,7 @@
#ifndef CHAIGAME_MATH_H
#define CHAIGAME_MATH_H
#ifndef CHAILOVE_MATH_H
#define CHAILOVE_MATH_H
namespace chaigame {
namespace chailove {
class math {
public:
bool load();

View File

@ -3,10 +3,10 @@
#include <SDL.h>
#include <libretro.h>
#include "graphics/Point.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include <string>
namespace chaigame {
namespace chailove {
bool mouse::load() {
setVisible(false);
@ -94,15 +94,15 @@ namespace chaigame {
void mouse::moveEvent(SDL_MouseMotionEvent event) {
m_x = event.x;
m_y = event.y;
ChaiGame::getInstance()->script->mousemove(m_x, m_y);
ChaiLove::getInstance()->script->mousemove(m_x, m_y);
}
void mouse::buttonEvent(SDL_MouseButtonEvent event) {
if (event.state == SDL_PRESSED) {
ChaiGame::getInstance()->script->mousepressed(m_x, m_y, event.button);
ChaiLove::getInstance()->script->mousepressed(m_x, m_y, event.button);
}
else if (event.state == SDL_RELEASED) {
ChaiGame::getInstance()->script->mousereleased(m_x, m_y, event.button);
ChaiLove::getInstance()->script->mousereleased(m_x, m_y, event.button);
}
buttonState[event.button] = event.state;
}

View File

@ -1,11 +1,11 @@
#ifndef CHAIGAME_MOUSE_H
#define CHAIGAME_MOUSE_H
#ifndef CHAILOVE_MOUSE_H
#define CHAILOVE_MOUSE_H
#include <SDL.h>
#include <string>
#include "graphics/Point.h"
namespace chaigame {
namespace chailove {
class mouse {
public:
bool load();

View File

@ -1,5 +1,5 @@
#include "script.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include "vendor/filesystem/filesystem/path.h"
#ifdef __HAVE_CHAISCRIPT__
@ -7,27 +7,45 @@
using namespace chaiscript;
#endif
namespace chaigame {
namespace chailove {
bool script::loadModule(const std::string& moduleName) {
#ifdef __HAVE_CHAISCRIPT__
ChaiGame* app = ChaiGame::getInstance();
std::string contents = app->filesystem.read(moduleName);
if (!contents.empty()) {
// TODO: Are tabs problematic?
contents = replaceString(contents, "\t", " ");
chai.eval(contents, Exception_Handler(), moduleName);
return true;
ChaiLove* app = ChaiLove::getInstance();
// Store a filename for the module.
std::string filename = moduleName;
// Make sure it exists.
if (!app->filesystem.exists(filename)) {
// See if we are to append .chai.
filename = filename + ".chai";
if (!app->filesystem.exists(filename)) {
std::cout << "[script] Module " << moduleName << " not found." << std::endl;
return false;
}
}
else {
std::cout << "Module {} was empty." << moduleName << std::endl;
// Load the contents of the file.
std::string contents = app->filesystem.read(filename);
// Make sure it was not empty.
if (contents.empty()) {
std::cout << "[script] Module " << moduleName << " was loaded, but empty." << std::endl;
return false;
}
// Replace possible problematic tabs, and evaluate the script.
contents = replaceString(contents, "\t", " ");
chai.eval(contents, Exception_Handler(), filename);
return true;
#endif
return false;
}
script::script(const std::string& file) {
#ifdef __HAVE_CHAISCRIPT__
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
// ChaiScript Standard Library Additions
// This adds some basic type definitions to ChaiScript.
@ -208,10 +226,10 @@ namespace chaigame {
chai.add(fun(&math::getRandomSeed), "getRandomSeed");
chai.add_global(var(std::ref(app->math)), "math");
// Load main.chai if it's a ChaiGame file.
// Load main.chai if it's a ChaiLove file.
::filesystem::path p(file.c_str());
std::string extension(p.extension());
if (extension == "chaigame" || file.empty()) {
if (extension == "chailove" || file.empty()) {
loadModule("main.chai");
}
else {
@ -376,7 +394,7 @@ namespace chaigame {
}
}
else {
ChaiGame::getInstance()->graphics.print("ChaiGame: def draw() not found.", 100, 100);
ChaiLove::getInstance()->graphics.print("ChaiLove: def draw() not found.", 100, 100);
}
#endif
}
@ -491,6 +509,9 @@ namespace chaigame {
return false;
}
/**
* Replaces all instances of a string in a given subject string.
*/
std::string script::replaceString(std::string subject, const std::string& search, const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {

View File

@ -1,5 +1,5 @@
#ifndef CHAIGAME_SCRIPT_H
#define CHAIGAME_SCRIPT_H
#ifndef CHAILOVE_SCRIPT_H
#define CHAILOVE_SCRIPT_H
#include <string>
#include "system/Config.h"
@ -11,7 +11,7 @@
//#include <chaiscript/chaiscript_stdlib.hpp>
#endif
namespace chaigame {
namespace chailove {
class script {
public:
script(const std::string& file);

View File

@ -2,10 +2,10 @@
#include <string>
#include "sound.h"
#include "SDL.h"
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include "audio/SoundData.h"
namespace chaigame {
namespace chailove {
bool sound::load() {
return true;
@ -23,6 +23,6 @@ namespace chaigame {
}
SoundData* sound::newSoundData(const std::string& filename) {
return ChaiGame::getInstance()->audio.newSource(filename);
return ChaiLove::getInstance()->audio.newSource(filename);
}
}

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_SOUND_H
#define CHAIGAME_SOUND_H
#ifndef CHAILOVE_SOUND_H
#define CHAILOVE_SOUND_H
#include "audio/SoundData.h"
#include <vector>
namespace chaigame {
namespace chailove {
class sound {
public:
bool load();

View File

@ -2,7 +2,7 @@
#include <string>
namespace chaigame {
namespace chailove {
std::string system::getOS() {
return "libretro";
}

View File

@ -1,9 +1,9 @@
#ifndef CHAIGAME_SYSTEM_H
#define CHAIGAME_SYSTEM_H
#ifndef CHAILOVE_SYSTEM_H
#define CHAILOVE_SYSTEM_H
#include <string>
namespace chaigame {
namespace chailove {
class system {
public:
std::string getOS();

View File

@ -1,10 +1,10 @@
#include "Config.h"
#include "../../ChaiGame.h"
#include "../../ChaiLove.h"
namespace chaigame {
namespace chailove {
Config::Config() {
options["alphablending"] = true;
options["highquality"] = true;
version = CHAIGAME_VERSION_STRING;
version = CHAILOVE_VERSION_STRING;
}
}

View File

@ -1,15 +1,15 @@
#ifndef CHAIGAME_UTILITY_CONFIG_H
#define CHAIGAME_UTILITY_CONFIG_H
#ifndef CHAILOVE_UTILITY_CONFIG_H
#define CHAILOVE_UTILITY_CONFIG_H
#include <string>
#include <map>
namespace chaigame {
namespace chailove {
struct windowConfig {
int width = 800;
int height = 600;
int bbp = 32;
std::string title = "ChaiGame";
std::string title = "ChaiLove";
bool asyncblit = true;
bool hwsurface = true;
bool doublebuffering = true;
@ -22,7 +22,7 @@ namespace chaigame {
class Config {
public:
Config();
std::string identity = "chaigame";
std::string identity = "chailove";
std::string version;
windowConfig window;
moduleConfig modules;

View File

@ -1,7 +1,7 @@
#include "timer.h"
#include "SDL.h"
namespace chaigame {
namespace chailove {
timer::timer() {
m_delta = 0;

View File

@ -1,7 +1,7 @@
#ifndef CHAIGAME_TIMER_H
#define CHAIGAME_TIMER_H
#ifndef CHAILOVE_TIMER_H
#define CHAILOVE_TIMER_H
namespace chaigame {
namespace chailove {
class timer {
public:
timer();

View File

@ -1,13 +1,13 @@
#include "window.h"
#include <string>
#include "../ChaiGame.h"
#include "../ChaiLove.h"
#include "SDL.h"
#include "system/Config.h"
namespace chaigame {
namespace chailove {
bool window::load(Config& config) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
// Initialize SDL.
if (SDL_Init(SDL_INIT_VIDEO) == -1) {

View File

@ -1,10 +1,10 @@
#ifndef CHAIGAME_WINDOW_H
#define CHAIGAME_WINDOW_H
#ifndef CHAILOVE_WINDOW_H
#define CHAILOVE_WINDOW_H
#include <string>
#include "system/Config.h"
namespace chaigame {
namespace chailove {
class window {
public:
bool load(Config& config);

View File

@ -4,7 +4,7 @@
#include <sstream>
#include <iostream>
#include "libretro.h"
#include "ChaiGame.h"
#include "ChaiLove.h"
char RETRO_DIR[512];
const char *retro_save_directory;
@ -32,16 +32,16 @@ void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) {
audio_batch_cb = cb;
}
void retro_set_input_poll(retro_input_poll_t cb) {
ChaiGame::input_poll_cb = cb;
ChaiLove::input_poll_cb = cb;
}
void retro_set_input_state(retro_input_state_t cb) {
ChaiGame::input_state_cb = cb;
ChaiLove::input_state_cb = cb;
}
static void emit_audio(void)
{
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
app->audio.mixer_render(audio_buffer);
audio_batch_cb(audio_buffer, (44100 / 60));
}
@ -60,7 +60,7 @@ void libretro_audio_cb(int16_t left, int16_t right) {
}
short int libretro_input_state_cb(unsigned port, unsigned device, unsigned index, unsigned id) {
return ChaiGame::input_state_cb(port, device, index, id);
return ChaiLove::input_state_cb(port, device, index, id);
}
#ifdef __cplusplus
}
@ -74,10 +74,10 @@ void retro_set_environment(retro_environment_t cb) {
// Set the Variables.
struct retro_variable variables[] = {
{
"chaigame_alphablending", "Alpha Blending; enabled|disabled",
"chailove_alphablending", "Alpha Blending; enabled|disabled",
},
{
"chaigame_highquality", "High Quality; enabled|disabled",
"chailove_highquality", "High Quality; enabled|disabled",
},
{ NULL, NULL },
};
@ -85,11 +85,11 @@ void retro_set_environment(retro_environment_t cb) {
}
static void update_variables(void) {
ChaiGame* game = ChaiGame::getInstance();
ChaiLove* game = ChaiLove::getInstance();
struct retro_variable var = {0};
// Alpha Blending
var.key = "chaigame_alphablending";
var.key = "chailove_alphablending";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
std::string varvalue(var.value);
@ -99,7 +99,7 @@ static void update_variables(void) {
}
// High Quality
var.key = "chaigame_highquality";
var.key = "chailove_highquality";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
std::string varvalue(var.value);
@ -111,18 +111,18 @@ static void update_variables(void) {
void retro_get_system_info(struct retro_system_info *info) {
memset(info, 0, sizeof(*info));
info->library_name = "ChaiGame";
info->library_name = "ChaiLove";
#ifndef GIT_VERSION
#define GIT_VERSION ""
#endif
info->library_version = CHAIGAME_VERSION_STRING GIT_VERSION;
info->library_version = CHAILOVE_VERSION_STRING GIT_VERSION;
info->need_fullpath = true;
info->valid_extensions = "chai|chaigame";
info->valid_extensions = "chai|chailove";
info->block_extract = true;
}
void retro_get_system_av_info(struct retro_system_av_info *info) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
unsigned int width = 640;
unsigned int height = 480;
if (app != NULL) {
@ -157,8 +157,8 @@ size_t retro_serialize_size(void) {
* Serialize the current state to save a slot.
*/
bool retro_serialize(void *data, size_t size) {
// Ask ChaiGame for save data.
ChaiGame* app = ChaiGame::getInstance();
// Ask ChaiLove for save data.
ChaiLove* app = ChaiLove::getInstance();
std::string state = app->savestate();
if (state.empty()) {
return false;
@ -182,7 +182,7 @@ bool retro_unserialize(const void *data, size_t size) {
std::string loadData = ss.str();
// Pass the string to the script.
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
return app->loadstate(loadData);
}
@ -197,7 +197,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) {
}
void texture_init(){
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
if (app->videoBuffer) {
memset(app->videoBuffer, 0, sizeof(app->videoBuffer));
}
@ -205,7 +205,7 @@ void texture_init(){
void frame_time_cb(retro_usec_t usec) {
float delta = usec / 1000000.0;
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
app->timer.step(delta);
}
@ -223,7 +223,7 @@ bool retro_load_game(const struct retro_game_info *info) {
// Load the game.
std::string full(info ? info->path : "main.chai");
return ChaiGame::getInstance()->load(full);
return ChaiLove::getInstance()->load(full);
}
bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info) {
@ -236,7 +236,7 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i
void retro_unload_game(void) {
// Nothing.
printf("retro_unload_game\n");
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
app->event.quit();
}
@ -325,7 +325,7 @@ void retro_init(void) {
void retro_deinit(void) {
std::cout << "retro_deinit" << std::endl;
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
if (app) {
app->event.quit();
app->quit();
@ -336,17 +336,17 @@ void retro_deinit(void) {
* The frontend requested to reset the game.
*/
void retro_reset(void) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
if (app) {
app->reset();
}
}
void retro_run(void) {
ChaiGame* app = ChaiGame::getInstance();
ChaiLove* app = ChaiLove::getInstance();
if (!app->event.quitstatus) {
// Poll all the inputs.
ChaiGame::input_poll_cb();
ChaiLove::input_poll_cb();
// Update the game.
if (!app->update()) {

View File

@ -1,7 +1,7 @@
/**
* ChaiGame: Native Tests
* ChaiLove: Native Tests
*
* Tests some of the usage of ChaiGame without the need of scripts.
* Tests some of the usage of ChaiLove without the need of scripts.
*
* Usage: make test-noscript
*/
@ -9,17 +9,17 @@
#ifdef __HAVE_TESTS__
#include "Test.h"
#include "../src/ChaiGame.h"
#include "../src/ChaiLove.h"
ChaiGame* app;
ChaiLove* app;
void Test::conf(chaigame::Config& t) {
void Test::conf(chailove::Config& t) {
t.window.width = 1080;
t.window.height = 768;
}
bool Test::load() {
app = ChaiGame::getInstance();
app = ChaiLove::getInstance();
app->filesystem.mount("test", "/");
secondfont = app->graphics.newFont("assets/Raleway-Regular.ttf", 60);
thefont = app->graphics.newFont("assets/c64_16x16.png", 16, 16, "\x7f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");

View File

@ -1,23 +1,23 @@
#ifdef __HAVE_TESTS__
#ifndef CHAIGAME_TEST_TEST_H
#define CHAIGAME_TEST_TEST_H
#ifndef CHAILOVE_TEST_TEST_H
#define CHAILOVE_TEST_TEST_H
#include "../src/chaigame/graphics/Font.h"
#include "../src/chaigame/system/Config.h"
#include "../src/chaigame/audio/SoundData.h"
#include "../src/chailove/graphics/Font.h"
#include "../src/chailove/system/Config.h"
#include "../src/chailove/audio/SoundData.h"
class Test {
public:
void conf(chaigame::Config& t);
void conf(chailove::Config& t);
bool load();
void update(float delta);
void draw();
int tester = 0;
chaigame::Font* thefont;
chaigame::Font* secondfont;
chaigame::SoundData* jump;
chaigame::ImageData* img;
chailove::Font* thefont;
chailove::Font* secondfont;
chailove::SoundData* jump;
chailove::ImageData* img;
};
#endif

View File

@ -1,5 +1,5 @@
/**
* ChaiGame: Testing Framework
* ChaiLove: Testing Framework
*/
global testNames = [
"graphics_print",