Verified Commit 8621bb0b authored by RobLoach's avatar RobLoach
Browse files

Rename to ChaiLove

parent 563c4eb2
# 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)
>
......
TARGET_NAME := chaigame
TARGET_NAME := chailove
include Makefile.libretro
include Makefile.common
......
# 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
......
# 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) [![Build Status](https://img.shields.io/badge/platform-libretro-green.png)](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
- [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 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
......
display_name = "ChaiGame"
display_name = "ChaiLove"
authors = "Rob Loach"
supported_extensions = "chai|chaigame"
corename = "ChaiGame"
supported_extensions = "chai|chailove|chaigame"
corename = "ChaiLove"
categories = "Game engine"
systemname = "ChaiGame"
database = "ChaiGame"
systemname = "ChaiLove"
database = "ChaiLove"
license = "MIT"
permissions = ""
display_version = "0.4.0"
display_version = "0.5.0"
supports_no_game = "false"
#!/bin/sh
PACKAGE_NAME=libretro-chaigame
PACKAGE_NAME=libretro-chailove
# 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
/**
* ChaiGame Benchmark
* ChaiLove Benchmark
*/
// The Sprites and the image to load.
......
/**
* ChaiGame: Pong
* ChaiLove: Pong
*/
global players = []
global pongSound
......
/**
* ChaiGame: Snake
* ChaiLove: Snake
*/
global WIDTH
global HEIGHT
......
/**
* 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
......
......@@ -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);
}
#ifndef CHAIGAME_GAME_H
#define CHAIGAME_GAME_H
#ifndef CHAILOVE_GAME_H
#define CHAILOVE_GAME_H
#define CHAIGAME_VERSION_MAJOR 0
#define CHAIGAME_VERSION_MINOR 4
#define CHAIGAME_VERSION_PATCH 0
#define CHAIGAME_VERSION_STRING "0.4.0"
#define CHAILOVE_VERSION_MAJOR 0
#define CHAILOVE_VERSION_MINOR 4
#define CHAILOVE_VERSION_PATCH 0
#define CHAILOVE_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"
#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 ChaiGame {
class ChaiLove {
public:
static ChaiGame* getInstance();
static ChaiGame* m_instance;
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;
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;
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);
......
......@@ -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++) {
......
#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);
......
#ifndef CHAIGAME_UTILITY_AUDIOSTATE_H
#define CHAIGAME_UTILITY_AUDIOSTATE_H
#ifndef CHAILOVE_UTILITY_AUDIOSTATE_H
#define CHAILOVE_UTILITY_AUDIOSTATE_H
namespace chaigame {
namespace chailove {
enum AudioState {
Stopped = 0,
Paused,
......
......@@ -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;
......
#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);
......
#include "event.h"
namespace chaigame {
namespace chailove {
void event::quit() {
quitstatus = true;
}
......
#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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment