- Simple: You only need to understand a few functions to create your game.
- Modern: Use the prebuilt third party API’s support to catch up with the thrends.
- Libre: Free as in freedom, available even for commercial projects.
Feature | Supported |
---|---|
Windows / Linux / MacOS | ✔ |
Flexible 2d graphics | ✔ |
Simplified sound and music api | ✔ |
PC, XInput, PS4 and Steam input supported | ✔ |
Built in JSON parsing | ✔ |
Steamworks | ✔ |
Collision detection, math, seeded randoms, logs etc... | ✔ |
Libre, MIT licensed | ✔ |
Image* image = rosalila()->graphics->getImage("image.png");
rosalila()->graphics->drawImage(image, 100, 200 /*x, y position*/);
rosalila()->graphics->drawRectangle(10, 20, /*position*/
200, 150, /*size*/
0.0, /*rotation*/
255, 0, 0, 255); /*RGBA*/
rosalila()->sound->playMusic("music.ogg", 0 /*music loops, 0 means infinite*/);
rosalila()->sound->addSound("my_sound", "sound.ogg");
[...]
rosalila()->sound->playSound("my_sound", -1 /*channel, use -1 to autopick*/, 1 /*loops, 0 means infinite*/, -1 /*stereo panning, 0 means mono, range from 1 to screen width*/);
[...]
rosalila()->sound->stopMusic();
if(rosalila()->receiver->isDown(0 /*0 is player 1, 1 is player 2 etc.*/, "up"))
{
// Player 1's "Up" button is down
}
if(rosalila()->receiver->isPressed(1 /*0 is player 1, 1 is player 2 etc.*/, "a"))
{
// Player 2 pressed the "a" button
}
rosalila()->api_integrator->unlockAchievement("My achievement");
int counter = rosalila()->api_integrator->getStat("My counter");
rosalila()->api_integrator->setStat("My counter",counter + 1);
rosalila()->api_integrator->setScore("Top scores", 143 /*score*/);
rosalila()->api_integrator->findLeaderboard("Top scores"); // Retreive the leaderboard externally
while (rosalila()->api_integrator->getState() == "loading") // Wait for it...
{
rosalila()->update();
}
if (rosalila()->api_integrator->getState() != "error")
{
Leaderboard *leaderboard = rosalila()->api_integrator->getLeaderboard("Top scores");
for (auto entry : current_leaderboard->top_entries) // Inspect entries
{
int rank = entry->rank;
std::string name = entry->name;
int score = entry->score;
[...]
}
for (auto entry : current_leaderboard->near_entries) // Same thing for entries near the player
{
[...]
}
for (auto entry : current_leaderboard->friends_entries) // And for his friend's entries
{
[...]
}
} else
{
// Handle errors
}
if (rosalila()->api_integrator->isUsingApi())
{
// External api is running
}
rosalila()->graphics->notification_handler.notifications.push_back(
new Notification(image,
0 /*x*/, 0 /*y*/,
100 /*target y, used for moving animation*/,
300 /*duration, in frames*/));
[...]
rosalila()->graphics->notification_handler.interruptCurrentNotification(); // Interrupt / Hide it
int width = rosalila()->graphics->screen_width;
int height = rosalila()->graphics->screen_height;
int random_number = rosalila()->utility->getRandomNumber();
int non_seeded_random_number = rosalila()->utility->getNonSeededRandomNumber();
rosalila()->utility->setRandomSeed(543245 /*seed*/);
rosalila()->utility->writeLogLine("My log text.");
Node* example_root_node = rosalila()->parser->getNodes("example.json");
Node* tag = example_root_node->getNodeByName("Tag");
cout << tag->attributes["a"] << endl;
for(auto array_element : example_root_node->getNodesByName("Array"))
{
cout << array_element->attributes["value"] << endl;
}
image.scale = 0.5; // defaults to 1.0
image.width = image.original_width * 2;
image.rotation = 45.0; // defaults to 0.0
image.flip_horizontally = true; // defaults to false
image.blend_effect = true; // defaults to false
image.color_filter.red = 0; // defaults to RGBA(255,255,255,255)
image.color_filter.alpha = 128;
rosalila()->sound->fadeMusicVolume(128 /*Target volume, 0 min 128 max*/,
2 /*Delta change speed*/);
rosalila()->graphics->transparency_effect.set(1.0 /*Target alpha percentage*/,
0.03 /*Delta change speed*/);
Link the Rosalila libraries and include it.
#include "Rosalila.h"
int main()
{
rosalila()->init("config.json");
// Initialize stuff here
while(true)
{
// Draw, play sounds, check inputs here
rosalila()->update();
}
return 0;
}
Also setup an config.json
file. Notice the Font
and Notifications
tags are optional.
{
"resolution":
{
"x": "1280",
"y": "720"
},
"screen_size":
{
"x": "1280",
"y": "720"
},
"fullscreen":
{
"enabled": "no"
},
"inputs":
{
"player":
{
"number": "0",
"type":
[
{
"name": "keyboard",
"button":
[
{
"name": "up",
"key": "up"
},
{
"name": "down",
"key": "down"
},
{
"name": "left",
"key": "left"
},
{
"name": "right",
"key": "right"
},
{
"name": "a",
"key": "z"
},
{
"name": "b",
"key": "x"
}
]
},
{
"name": "gamepad",
"button":
[
{
"name": "up",
"key": "up"
},
{
"name": "down",
"key": "down"
},
{
"name": "left",
"key": "left"
},
{
"name": "right",
"key": "right"
},
{
"name": "a",
"key": "1"
},
{
"name": "b",
"key": "2"
}
]
}
]
}
}
}
Attribute | Type | Required | Description |
---|---|---|---|
resolution |
resolution | ✔ | Screen resolution, in pixels |
screen_size |
screen_size | ✔ | Screen size, in pixels |
fullscreen |
fullscreen | ✔ | Fullscreen settings |
inputs |
inputs | ✔ | Input settings |
font |
font | Fullscreen settings | |
notifications |
notifications | Notification settings |
Attribute | Type | Required | Description |
---|---|---|---|
x | integer |
✔ | Resolution width |
y | integer |
✔ | Resolution height |
Attribute | Type | Required | Description |
---|---|---|---|
x | integer |
✔ | Screen width |
y | integer |
✔ | Screen height |
Attribute | Type | Required | Description |
---|---|---|---|
enabled | yes/no |
✔ | Defines whether the game will go fullscreen or not |
Attribute | Type | Required | Description |
---|---|---|---|
path | file path |
✔ | Path to the .ttf file |
red | integer |
✔ | Amount of red color from 0 to 255 |
green | integer |
✔ | Amount of green color from 0 to 255 |
blue | integer |
✔ | Amount of blue color from 0 to 255 |
size | integer |
✔ | Font size |
Attribute | Type | Required | Description |
---|---|---|---|
background_path | file path |
✔ | Path to the notification box .png background |
Attribute | Type | Required | Description |
---|---|---|---|
player[] | player | ✔ | Array of player's button configuration |
Attribute | Type | Required | Description |
---|---|---|---|
number | integer |
✔ | Player number from 0 onwards... |
type[] | type | ✔ | Array of types of inputs (gamepad or keyboard) |
Attribute | Type | Required | Description |
---|---|---|---|
name | keyboard/gamepad |
✔ | Type of input configuration |
button[] | button | ✔ | Button key-name mapping |
Attribute | Type | Required | Description |
---|---|---|---|
name | string |
✔ | Name of the button to be used on your game |
key | string |
✔ | Key associated to the name |
The Rosalila Framework Example is a very simple project using the Rosalila Framework. It helps you getting started.
Take a look at the Code Examples for quick code recipes.
sudo apt-get install g++ \
cmake libsdl2-dev libsdl2-image-dev \
libsdl2-mixer-dev libsdl2-ttf-dev \
libsdl2-net-dev libglew-dev
brew install sdl2
brew install sdl2_image
brew install sdl2_mixer
brew install sdl2_ttf
mkdir build
cd build
cmake ..
make