February 27

On Tuesday, 27 February 2024 at 03:43:56 UTC, Liam McGillivray wrote:

>

Raylib looks promising. I installed it along with your Raylib-d. I managed to build the example you provided with dub, but trying to use it in it's own dub project in a separate directory isn't working. Just copying and pasting app.d from the very example you provided results in a huge wall of errors, mostly "undefined reference to [some function]".

Nevermind this. I just needed to add libs "raylib" to dub.sdl. I didn't think I would need to specify the libraries in the project when they are accessed through an external library. Now I know.

Looking at the code examples on the Raylib and SFML website, they look similar in complexity of getting started, but I like it that the Raylib website has lots of simple demonstration programs on the website with the code provided. This is a great way to help with learning.
https://www.raylib.com/examples.html

So far it's been working when I try to do their C++ examples in D.

February 28

On Tuesday, 27 February 2024 at 22:05:48 UTC, Liam McGillivray wrote:

>

Looking at the code examples on the Raylib and SFML website, they look similar in complexity of getting started, but I like it that the Raylib website has lots of simple demonstration programs on the website with the code provided. This is a great way to help with learning.
https://www.raylib.com/examples.html

So far it's been working when I try to do their C++ examples in D.

See also https://github.com/D-a-n-i-l-o/raylib-d_examples 😏

Just „dub run“ to execute each raylib example there.

February 28

There's something very strange going on when using Raylib-D.

I tried using the raylib function LoadTexture like this:

tileSprites[i] = LoadTexture("../sprites/" ~ spriteName);

I got the following error:

Error: function `raylib.LoadTexture(const(char)* fileName)` is not callable using argument types `(string)`

So it's not allowing me to use a D string, but wants me to use (what I believe to be) the archaic C-style string. Here is how this function, as well as DrawText is declared in the Raylib-D bindings:

void DrawText(const(char)* text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
Texture2D LoadTexture(const(char)* fileName); // Load texture from file into GPU memory (VRAM)

The weird thing is that both of these functions are declared only once and with these C-style strings as arguments, yet I have already successfully called DrawText using a D string, yet Texture2D results in an error.

DrawText("Open Emblem", 180, 300, 64, Colors.RAYWHITE);

So why is it that one of these functions, but not the other is allowing D strings in place of C-style strings?

February 28

On Wednesday, 28 February 2024 at 07:56:16 UTC, Liam McGillivray wrote:

>
DrawText("Open Emblem", 180, 300, 64, Colors.RAYWHITE);

So why is it that one of these functions, but not the other is allowing D strings in place of C-style strings?

C is expecting null-terminated chars. D string type is not null-terminated,
but using directly a string literal like „Open Emblem“ is null-terminated.

In D you use mystring.toStringz to create a null-terminated C char-array.

Example for LoadTexture:
https://github.com/D-a-n-i-l-o/raylib-d_examples/blob/main/examples/textures/047_textures_logo_raylib/source/app.d

February 29

Examples were moved, so it‘s in the same place now:

March 01

I now have the Raylib functions working by using toStrinz.

I pushed some updates to the repository. I made the main project a source library so that I can experiment with different graphics library front-ends. I put have the front-end using Raylib in the raylib_frontend directory. It doesn't yet have any interactivity, but it should build and run successfully IIRC.

I don't know how best to organize the code. So far I have been putting the loop that runs during gameplay in the Mission function in mission.d. This function contains the arrays where sprites are stored. The code for unloading data from files is split between this function and maps.d. I was going to have a file in the main source/ (not raylib_frontend/source) called loadData.d which would handle unloading from files, but then I realized that those functions would need write access to multiple variables, making it a not very tidy approach.

One possibility is to turn Mission into a class. The Mission object would control the Map object and other things during gameplay. The other possibility is to make a derived class of Map with more graphics-related functionality and more.

March 01

On Friday, 1 March 2024 at 05:07:24 UTC, Liam McGillivray wrote:

>

I don't know how best to organize the code. So far I have been oo ideas

for a 2nd opinion: https://github.com/crazymonkyyy/raylib-2024/blob/master/docs/examplecode.md

Theres not a good learning resource but "data oirented design": pick good data for your problem then do the simplest thing that makes it work

March 06

I have made some progress on this. For the raylib front-end, I tried making a class called Mission which inherits Map. This class handles the graphics, input, and other game events. The program now compiles without errors, and there are some graphics. I have pushed these updates to the GitHub repository.
https://github.com/LiamM32/Open_Emblem

Currently, it just displays a map of grass tiles with one unit. Clicking on the unit causes a segmentation fault. There is something that's supposed to happen when clicked, but I don't know why it segfaults. The line where it segfaults appears to be roughly oe-raylib/source/mission.d:125.

I am continuing to work on this, but have been getting more strange runtime errors since the latest push.

March 06

There's something that I'm trying to do that D may or may not be capable of.

In the Map class, there is a 2-dimensional array called grid, where the Tile objects are stored. The Mission class inherits the Map class.

In the Mission class, I want the grid array to instead be composed of a derivative of the Tile class. I tried making a derived class called GridTile which contains the additional property specific to the Raylib front-end.

I tried doing this, but it won't let me override grid, even if I change it from private to protected in the Map class.

Is there a way I can do this, without this additional functionality being put in the base Tile class?

1 2
Next ›   Last »