Verified Commit 958bc990 authored by RobLoach's avatar RobLoach
Browse files

Require content in ChaiLove

parent 9446966e
......@@ -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();
......
......@@ -99,7 +99,6 @@ class ChaiLove {
love::math math;
love::window window;
love::event event;
std::string demo();
~ChaiLove();
void quit(void);
......
......@@ -58,7 +58,7 @@ void retro_set_environment(retro_environment_t cb) {
ChaiLove::environ_cb = cb;
// The core supports having no game.
bool no_rom = true;
bool no_rom = false;
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_rom);
// Set the Variables.
......
......@@ -413,23 +413,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.
......
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