Unverified Commit ffa918a8 authored by RobLoach's avatar RobLoach Committed by GitHub
Browse files

Merge pull request #161 from RobLoach/version-bump

0.11.0
parents 3b829751 c0948dd2
......@@ -4,7 +4,7 @@ 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).
## [Unreleased] - xxxx-xx-xx
## [0.11.0] - 2017-12-09
### Added
- `love` namespace
- Example: `love.graphics.draw()`
......@@ -13,10 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `love.graphics.getDefaultFilter()`
### Changed
- ChaiScript_Extras now using original source, upstream GCC issue fixed
- Updated libretro-common
- Updated random
- Updated sdl-libretro
- [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras) now using original source as upstream issue is fixed
- Updated [libretro-common](http://github.com/libretro/libretro-common)
- Updated [random](https://github.com/libretro/sdl-libretro)
- Updated [sdl-libretro](https://github.com/libretro/sdl-libretro)
### Fixed
- `keyreleased()` callback parameter types
......
......@@ -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.10.0"
PROJECT_NUMBER = "0.11.0"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......
......@@ -11,8 +11,8 @@
* global y
*
* def load() {
* graphics.setBackgroundColor(54, 172, 248)
* logo = graphics.newImage("logo.png")
* love.graphics.setBackgroundColor(54, 172, 248)
* logo = love.graphics.newImage("logo.png")
* x = 10.0f
* y = 10.0f
* }
......@@ -23,8 +23,8 @@
* }
*
* def draw() {
* graphics.print("Hello World!", 100, 100)
* graphics.draw(logo, x, y)
* love.graphics.print("Hello World!", 100, 100)
* love.graphics.draw(logo, x, y)
* }
* @endcode
*
......
......@@ -37,7 +37,7 @@ class graphics {
* @param height Height of the rectangle.
*
* @code
* graphics.rectangle("fill", 100, 100, 50, 50)
* love.graphics.rectangle("fill", 100, 100, 50, 50)
* @endcode
*/
void rectangle(const std::string& drawmode, int x, int y, int width, int height);
......
......@@ -28,9 +28,7 @@ void joystick::load() {
// Create the joystick handlers.
joysticks = new Joystick[numJoysticks];
for (int i = 0; i < numJoysticks; i++) {
joysticks[i].open(i);
}
clearCache();
}
void joystick::unload() {
......@@ -67,7 +65,7 @@ void joystick::update() {
int16_t state;
// Loop through each joystick.
for (i = 0; i < 4; i++) {
for (i = 0; i < numJoysticks; i++) {
// Loop through each button.
for (u = 0; u < 14; u++) {
// Retrieve the state of the button.
......@@ -88,6 +86,16 @@ void joystick::update() {
}
}
void joystick::clearCache() {
// Clear the cached.
for (int i = 0; i < numJoysticks; i++) {
// Loop through each button.
for (int u = 0; u < 14; u++) {
joystick_cache[i][u] = 0;
}
}
}
Joystick& joystick::operator[](int i) {
if (i < 0 || i >= numJoysticks) {
i = 0;
......
......@@ -34,6 +34,8 @@ class joystick {
*/
bool isOpen(int index);
void clearCache();
/**
* @brief Closes a joystick.
*/
......@@ -54,6 +56,18 @@ class joystick {
std::string getButtonName(int key);
int16_t joystick_cache[4][14];
/**
* @brief Retrieve the given joystick.
*
* ### Example
* @code
* love.joystick[0].isDown("left")
* @endcode
*
* @param player The number of which player's joystick you would like to retrieve.
*
* @return The joystick of the given player number.
*/
Joystick& operator[](int i);
};
......
......@@ -47,11 +47,11 @@ class script {
* global hamster
*
* def load() {
* hamster = graphics.newImage("hamster.png")
* hamster = love.graphics.newImage("hamster.png")
* }
*
* def draw() {
* graphics.draw(hamster, 100, 100)
* love.graphics.draw(hamster, 100, 100)
* }
* @endcode
*/
......@@ -71,10 +71,10 @@ class script {
* var rate = 3
*
* def update(dt) {
* if (keyboard.isDown("down")) {
* if (love.keyboard.isDown("down")) {
* position -= dt * rate
* }
* if (keyboard.isDown("up")) {
* if (love.keyboard.isDown("up")) {
* position += dt * rate
* }
* }
......@@ -93,11 +93,11 @@ class script {
* global hamster
*
* dev load() {
* hamster = graphics.newImage("hamster.png")
* hamster = love.graphics.newImage("hamster.png")
* }
*
* def love.draw() {
* graphics.draw(hamster, 100, 100)
* love.graphics.draw(hamster, 100, 100)
* }
* @endcode
*/
......
......@@ -7,24 +7,48 @@ namespace Types {
namespace Graphics {
/**
* @brief A color.
* @brief A color, holding red, green, blue and alpha values.
*/
struct Color {
/**
* @brief Create a color with the value of 0, 0, 0, 0.
*/
Color() : r(0), g(0), b(0), a(0) {
// Nothing.
}
/**
* @brief Create a new color.
*/
Color(int rValue, int gValue, int bValue, int aValue) : r(rValue), g(gValue), b(bValue), a(aValue) {
// Nothing.
}
/**
* @brief Create a new color.
*/
Color(int rValue, int gValue, int bValue) : r(rValue), g(gValue), b(bValue) {
// Nothing.
}
/**
* @brief The amount of red.
*/
int r;
/**
* @brief The amount of green.
*/
int g;
/**
* @brief The amount of blue.
*/
int b;
/**
* @brief The amount of alpha.
*/
int a;
SDL_Color toSDLColor() {
......
......@@ -29,14 +29,17 @@ class Font {
TTF_Font* ttfFont = NULL;
TTY_Font* ttyFont = NULL;
int ttyFontWidth, ttyFontHeight;
/**
* @brief Determines the vertical size the given text needs.
*/
int getHeight(const std::string& text);
/**
* @brief Determines the vertical size a line of text needs.
*/
int getHeight();
/**
* @brief Determines the horizontal size a line of text needs.
*/
......
......@@ -11,7 +11,28 @@ namespace Graphics {
*/
class Quad {
public:
int x, y, width, height, sw, sh;
/**
* @brief The x coordinate.
*/
int x;
/**
* @brief The y coordinate.
*/
int y;
/**
* @brief The width of the Quad.
*/
int width;
/**
* @brief The height of the Quad.
*/
int height;
int sw;
int sh;
Quad();
Quad(int x, int y, int width, int height, int sw, int sh);
Quad(int x, int y, int width, int height);
......
......@@ -27,13 +27,14 @@ bool Joystick::isOpen() {
return true;
}
bool Joystick::open(int i) {
index = i;
Joystick::Joystick() {
name = "RetroPad";
return true;
index = 0;
}
Joystick::Joystick() {
Joystick::Joystick(int i) {
index = i;
name = "RetroPad";
}
bool Joystick::isDown(int button) {
......
......@@ -12,6 +12,7 @@ namespace Input {
class Joystick {
public:
Joystick();
Joystick(int index);
/**
* @brief Gets the name of the joystick.
......@@ -21,7 +22,6 @@ class Joystick {
std::string getName();
bool isOpen();
void close();
bool open(int index);
/**
* @brief Checks if a button on the Joystick is pressed.
......
assert_not(love.joystick.isDown(0, "right"), "love.joystick.isDown()")
assert_not(love.joystick[0].isDown("right"), "love.joystick[]")
......@@ -10,6 +10,7 @@ def load() {
filesystem.load("font.chai")
filesystem.load("graphics.chai")
filesystem.load("math.chai")
filesystem.load("joystick.chai")
filesystem.load("keyboard.chai")
filesystem.load("timer.chai")
filesystem.load("system.chai")
......@@ -25,5 +26,6 @@ def load() {
}
def draw() {
love.graphics.print("ChaiLove: Unit Testing Framework", 100, 100)
love.graphics.print("Report: " + failure, 100, 200)
}
assert_equal(love.window.getTitle(), "ChaiLove", "love.window.getTitle()")
love.window.setTitle("ChaiLove Unit Testing")
assert_equal(love.window.getTitle(), "ChaiLove Unit Testing", "love.window.getTitle()")
assert_equal(love.window.getTitle(), "ChaiLove Unit Testing", "love.window.setTitle()")
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