mirror of
https://github.com/libretro/libretro-chailove.git
synced 2025-02-21 08:51:08 +00:00
commit
d57052ee94
12
CHANGELOG.md
12
CHANGELOG.md
@ -4,6 +4,18 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 0.32.0 - 2019-03-10
|
||||
### Features
|
||||
- [BunnyMark](examples/bunnymark) to test performance
|
||||
|
||||
### Chores
|
||||
- ChaiLove now requires content to run
|
||||
- Updated ChaiScript_Extras for more string methods
|
||||
- Updated PhysFS
|
||||
- Updated libretro-common
|
||||
- Updated random to fix a gcc 7.3+ error
|
||||
- Updated stb
|
||||
|
||||
## 0.31.0 - 2018-12-24
|
||||
### Chores
|
||||
- Update to use the libretro audio callback
|
||||
|
@ -40,7 +40,7 @@ retroarch -L chailove_libretro.so FloppyBird.chailove
|
||||
|
||||
## API
|
||||
|
||||
The [ChaiLove API](https://rawgit.com/libretro/libretro-chailove/docs/) is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a [simple Hello World example](examples/simple/main.chai):
|
||||
The [ChaiLove API](https://raw.githack.com/libretro/libretro-chailove/docs/index.html) is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a [simple Hello World example](examples/simple/main.chai):
|
||||
|
||||
``` lua
|
||||
global logo
|
||||
@ -66,7 +66,7 @@ To run it, execute the following:
|
||||
retroarch -L chailove_libretro.so main.chai
|
||||
```
|
||||
|
||||
See the [ChaiLove API](https://rawgit.com/libretro/libretro-chailove/docs/) for coverage of all the callbacks and methods in ChaiLove.
|
||||
See the [ChaiLove API](https://raw.githack.com/libretro/libretro-chailove/docs/index.html) for coverage of all the callbacks and methods in ChaiLove.
|
||||
|
||||
## Development
|
||||
|
||||
@ -96,7 +96,7 @@ retroarch -L chailove_libretro.so test/main.chai
|
||||
|
||||
### Documentation
|
||||
|
||||
See the [ChaiLove API documentation](https://rawgit.com/libretro/libretro-chailove/docs/). Build it through [Doxygen](http://www.stack.nl/~dimitri/doxygen/) by using:
|
||||
See the [ChaiLove API documentation](https://raw.githack.com/libretro/libretro-chailove/docs/index.html). Build it through [Doxygen](http://www.stack.nl/~dimitri/doxygen/) by using:
|
||||
|
||||
```
|
||||
make docs
|
||||
|
@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = "0.31.0"
|
||||
PROJECT_NUMBER = "0.32.0"
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
BIN
examples/bunnymark/bunny.png
Normal file
BIN
examples/bunnymark/bunny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 449 B |
120
examples/bunnymark/main.chai
Normal file
120
examples/bunnymark/main.chai
Normal file
@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2018 KANO Computing Ltd.
|
||||
// Licensed under the GNU GPL v2
|
||||
//
|
||||
// Original by Iain Lobb
|
||||
// Inspired by PixieJS
|
||||
// Bunny Image by Amanda Lobb
|
||||
// https://github.com/rishavs/love2d-bunnymark
|
||||
// ChaiLove version by Rob Loach
|
||||
|
||||
def conf(t) {
|
||||
t.console = true
|
||||
t.window.title = "Bunnymark Mark II ; a little better!"
|
||||
t.window.width = 800
|
||||
t.window.height = 600
|
||||
}
|
||||
|
||||
def load() {
|
||||
global bunnies = List()
|
||||
global gravity = 0.98f
|
||||
|
||||
global maxX = love.graphics.getWidth( )
|
||||
global minX = 0
|
||||
|
||||
global maxY = love.graphics.getHeight( )
|
||||
global minY = 0
|
||||
|
||||
// optimise the bunny size for embedded devices
|
||||
global baseLitterSize = 50
|
||||
global litterSizeIncrement = 50
|
||||
global litterSize = baseLitterSize
|
||||
|
||||
global stdOutText = ""
|
||||
|
||||
global bunnyImg = love.graphics.newImage("bunny.png")
|
||||
procreate(0, 0)
|
||||
}
|
||||
|
||||
def draw() {
|
||||
love.graphics.print(to_string(bunnies.size()) + " Total Bunnies", 20, 10)
|
||||
love.graphics.print(to_string(litterSize) + " bunnies in each Litter", 20, 20)
|
||||
|
||||
// print the current memory usage
|
||||
// rounding down mem to three dig: math.floor(mem+0.5) / math.pow(10,dig)
|
||||
//love.graphics.print(floor(collectgarbage("count") + 0.5)/pow(10,3) + " MB Mem Usage", 20, 30)
|
||||
love.graphics.print("Current FPS: " + to_string(love.timer.getFPS()), 20, 40)
|
||||
//love.graphics.print(string.format("Elapsed clock cycles: " + to_string(%.4f", (os.clock() - x) *1000), 20, 50)
|
||||
|
||||
for (bunny : bunnies) {
|
||||
love.graphics.draw(bunnyImg, bunny[0], bunny[1])
|
||||
}
|
||||
}
|
||||
|
||||
def mousepressed(x, y, button) {
|
||||
for (var i = 0; i < litterSize; ++i) {
|
||||
procreate(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
def joystickpressed(joystick, button) {
|
||||
for (var i = 0; i < litterSize; ++i) {
|
||||
procreate(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 8.0f)
|
||||
}
|
||||
}
|
||||
|
||||
def update(dt) {
|
||||
// Initialize variables once per cycle.
|
||||
var tempBunnyPosX = 0.0f
|
||||
var tempBunnyPosY = 0.0f
|
||||
var tempBunnySpeedX = 0.0f
|
||||
var tempBunnySpeedY = 0.0f
|
||||
|
||||
for (bunny : bunnies) {
|
||||
// Retrieve the bunny values.
|
||||
tempBunnyPosX = bunny[0]
|
||||
tempBunnyPosY = bunny[1]
|
||||
tempBunnySpeedX = bunny[2]
|
||||
tempBunnySpeedY = bunny[3]
|
||||
|
||||
// Move the bunny.
|
||||
tempBunnyPosX = tempBunnyPosX + tempBunnySpeedX;
|
||||
tempBunnyPosY = tempBunnyPosY + tempBunnySpeedY;
|
||||
|
||||
// Adjust coordinates with world.
|
||||
tempBunnySpeedY = tempBunnySpeedY + gravity;
|
||||
if (tempBunnyPosX > maxX) {
|
||||
tempBunnySpeedX = tempBunnySpeedX * -0.9f;
|
||||
tempBunnyPosX = maxX;
|
||||
} else if (tempBunnyPosX < minX) {
|
||||
tempBunnySpeedX = tempBunnySpeedX * -0.9f;
|
||||
tempBunnyPosX = minX;
|
||||
}
|
||||
if (tempBunnyPosY > maxY) {
|
||||
tempBunnySpeedY = tempBunnySpeedY * -0.9f;
|
||||
tempBunnyPosY = maxY;
|
||||
} else if (tempBunnyPosY < minY) {
|
||||
tempBunnySpeedY = tempBunnySpeedY * -0.9f;
|
||||
tempBunnyPosY = minY;
|
||||
}
|
||||
|
||||
// Update the bunny
|
||||
bunny[0] = tempBunnyPosX
|
||||
bunny[1] = tempBunnyPosY
|
||||
bunny[2] = tempBunnySpeedX
|
||||
bunny[3] = tempBunnySpeedY
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
// Custom functions
|
||||
//------------------------------------------------
|
||||
|
||||
def procreate(x,y) {
|
||||
var bunnyPosX = x
|
||||
var bunnyPosY = y
|
||||
var bunnySpeedX = love.math.random(-5.0f, 5.0f)
|
||||
var bunnySpeedY = love.math.random(-5.0f, 5.0f)
|
||||
var bunny = [bunnyPosX, bunnyPosY, bunnySpeedX, bunnySpeedY]
|
||||
|
||||
bunnies.push_back_ref(bunny)
|
||||
}
|
@ -103,71 +103,6 @@ bool ChaiLove::load(const std::string& file, const void* data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ChaiLove::demo() {
|
||||
// Provides a demo screen that's presented when the core is loaded without content.
|
||||
std::string output = R"DEMO(
|
||||
global defaultFont
|
||||
global text = "ChaiLove - No Game"
|
||||
global x = 50.0f
|
||||
global y = 50.0f
|
||||
global radius = 20.0f
|
||||
global xSpeed = 35.0f
|
||||
global ySpeed = 35.0f
|
||||
|
||||
def load() {
|
||||
defaultFont = love.graphics.getFont()
|
||||
x = love.graphics.getWidth() / 2.0f
|
||||
y = love.graphics.getHeight() / 2.0f
|
||||
}
|
||||
|
||||
def conf(t) {
|
||||
t.window.width = 320
|
||||
t.window.height = 240
|
||||
t.console = true
|
||||
}
|
||||
|
||||
def draw() {
|
||||
love.graphics.setBackgroundColor(0, 138, 255)
|
||||
|
||||
// Draw a little circle.
|
||||
love.graphics.setColor(230, 88, 160)
|
||||
love.graphics.circle("fill", x, y, radius)
|
||||
love.graphics.setColor(0, 0, 0)
|
||||
love.graphics.circle("line", x, y, radius)
|
||||
|
||||
// Draw the text.
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.print(text, 10, love.graphics.getHeight() / 2.0f - 100)
|
||||
var ver = love.system.getVersionString()
|
||||
love.graphics.print(ver, love.graphics.getWidth() - defaultFont.getWidth(ver), love.graphics.getHeight() - defaultFont.getHeight(ver) * 2.0f)
|
||||
|
||||
love.graphics.print("FPS: " + to_string(love.timer.getFPS()), 10, love.graphics.getHeight() - defaultFont.getHeight(ver) * 2.0f)
|
||||
}
|
||||
|
||||
def update(dt) {
|
||||
x = x + xSpeed * dt
|
||||
y = y + ySpeed * dt
|
||||
if (x + radius > love.graphics.getWidth()) {
|
||||
x = love.graphics.getWidth() - radius
|
||||
xSpeed = xSpeed * -1
|
||||
}
|
||||
if (x - radius < 0) {
|
||||
x = radius
|
||||
xSpeed = abs(xSpeed)
|
||||
}
|
||||
if (y + radius > love.graphics.getHeight()) {
|
||||
y = love.graphics.getHeight() - radius
|
||||
ySpeed = ySpeed * -1
|
||||
}
|
||||
if (y - radius < 0) {
|
||||
y = radius
|
||||
ySpeed = abs(ySpeed)
|
||||
}
|
||||
}
|
||||
)DEMO";
|
||||
return output;
|
||||
}
|
||||
|
||||
void ChaiLove::update() {
|
||||
// Update and poll all the events.
|
||||
event.update();
|
||||
|
@ -45,9 +45,9 @@
|
||||
#define SRC_CHAILOVE_H_
|
||||
|
||||
#define CHAILOVE_VERSION_MAJOR 0
|
||||
#define CHAILOVE_VERSION_MINOR 31
|
||||
#define CHAILOVE_VERSION_MINOR 32
|
||||
#define CHAILOVE_VERSION_PATCH 0
|
||||
#define CHAILOVE_VERSION_STRING "0.31.0"
|
||||
#define CHAILOVE_VERSION_STRING "0.32.0"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "libretro.h"
|
||||
@ -99,7 +99,6 @@ class ChaiLove {
|
||||
love::math math;
|
||||
love::window window;
|
||||
love::event event;
|
||||
std::string demo();
|
||||
|
||||
~ChaiLove();
|
||||
void quit(void);
|
||||
|
@ -57,8 +57,8 @@ void retro_set_environment(retro_environment_t cb) {
|
||||
// Set the environment callback.
|
||||
ChaiLove::environ_cb = cb;
|
||||
|
||||
// The core supports having no game.
|
||||
bool no_rom = true;
|
||||
// The core requires content.
|
||||
bool no_rom = false;
|
||||
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_rom);
|
||||
|
||||
// Set the Variables.
|
||||
@ -208,7 +208,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info) {
|
||||
info->geometry.base_width = width;
|
||||
info->geometry.base_height = height;
|
||||
info->geometry.max_width = width;
|
||||
info->geometry.max_height = width;
|
||||
info->geometry.max_height = height;
|
||||
info->geometry.aspect_ratio = static_cast<float>(width) / static_cast<float>(height);
|
||||
|
||||
info->timing.fps = 60.0;
|
||||
|
@ -115,9 +115,13 @@ script::script(const std::string& file) {
|
||||
// ChaiScript Standard Library Additions
|
||||
// This adds some basic type definitions to ChaiScript.
|
||||
chai.add(bootstrap::standard_library::vector_type<std::vector<int>>("VectorInt"));
|
||||
chai.add(bootstrap::standard_library::vector_type<std::vector<float>>("VectorFloat"));
|
||||
chai.add(bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
|
||||
chai.add(bootstrap::standard_library::map_type<std::map<std::string, bool>>("StringBoolMap"));
|
||||
chai.add(bootstrap::standard_library::map_type<std::map<std::string, int>>("StringIntMap"));
|
||||
chai.add(bootstrap::standard_library::map_type<std::map<std::string, float>>("StringFloatMap"));
|
||||
|
||||
// ChaiScript_Extras: String Methods
|
||||
auto stringmethods = chaiscript::extras::string_methods::bootstrap();
|
||||
chai.add(stringmethods);
|
||||
|
||||
@ -413,23 +417,16 @@ script::script(const std::string& file) {
|
||||
// Ensure the love namespace is imported and ready.
|
||||
chai.import("love");
|
||||
|
||||
// Load the desired main.chai file.
|
||||
if (file.empty()) {
|
||||
// When no content is provided, display a No Game demo.
|
||||
eval(app->demo(), "demo.chai");
|
||||
mainLoaded = true;
|
||||
} else {
|
||||
// Load the main.chai file.
|
||||
require("conf");
|
||||
// Load the main.chai file.
|
||||
require("conf");
|
||||
|
||||
std::string extension(app->filesystem.getFileExtension(file));
|
||||
if (extension == "chailove" || extension == "chaigame") {
|
||||
mainLoaded = require("main");
|
||||
} else {
|
||||
// Otherwise, load the actual file.
|
||||
std::string filename(app->filesystem.getBasename(file));
|
||||
mainLoaded = require(filename);
|
||||
}
|
||||
std::string extension(app->filesystem.getFileExtension(file));
|
||||
if (extension == "chailove" || extension == "chaigame") {
|
||||
mainLoaded = require("main");
|
||||
} else {
|
||||
// Otherwise, load the actual file.
|
||||
std::string filename(app->filesystem.getBasename(file));
|
||||
mainLoaded = require(filename);
|
||||
}
|
||||
|
||||
// Find the game functions.
|
||||
|
2
vendor/ChaiScript_Extras
vendored
2
vendor/ChaiScript_Extras
vendored
@ -1 +1 @@
|
||||
Subproject commit 2aee0d2dc338d9a548e2c766da27112f2f6bca17
|
||||
Subproject commit 8c16c4a432c395f2f4e87912497d37b086f6846b
|
2
vendor/didstopia-physfs
vendored
2
vendor/didstopia-physfs
vendored
@ -1 +1 @@
|
||||
Subproject commit 58f9c0f558a8e74fe0bfafd1a1e3bdacb5841168
|
||||
Subproject commit 4bb453f6733dc085a10feda028904056c59ea84f
|
2
vendor/libretro-common
vendored
2
vendor/libretro-common
vendored
@ -1 +1 @@
|
||||
Subproject commit 33c632195f54d2ce0be34c56f98bb1a2a4c98831
|
||||
Subproject commit b506f65216ec46374c88477dc689e84496b99540
|
2
vendor/random
vendored
2
vendor/random
vendored
@ -1 +1 @@
|
||||
Subproject commit 985de84de4ec891ce060c4c6579cf70d3c1c86e2
|
||||
Subproject commit d1457a86ccac0e2af3c113ab8a655f44e698727e
|
2
vendor/stb
vendored
2
vendor/stb
vendored
@ -1 +1 @@
|
||||
Subproject commit e6afb9cbae4064da8c3e69af3ff5c4629579c1d2
|
||||
Subproject commit 2c2908f50515dcd939f24be261c3ccbcd277bb49
|
Loading…
x
Reference in New Issue
Block a user