March 10

On Sunday, 10 March 2024 at 04:39:33 UTC, Liam McGillivray wrote:

>

https://github.com/LiamM32/Open_Emblem/tree/templates-interfaces

I will probably merge it into master soon.

I have put up a merge request for these changes I have made to the library and the Raylib front-end. I would be interested in having my code looked at by someone more experienced than me (which would be everyone who has replied here and most of those reading).
https://github.com/LiamM32/Open_Emblem/pull/2

You can take a look in source/map.d where the former Map class has been replaced with the Map interface and the MapTemp template. You may also look in oe-raylib/source/mission.d, and compare how sprites were handled before vs after.

Of course, you can also compile and run it yourself (assuming I didn't accidentally leave out a file).

Other commentary on my code would also be appreciated.

I don't know if there's a forum section appropriate for sharing personal projects, but I may post there too.

March 25

On Thursday, 7 March 2024 at 22:18:40 UTC, Richard (Rikki) Andrew Cattermole wrote:

>

There are two ways to do this.

  1. Use templates. https://tour.dlang.org/tour/en/basics/templates

Thank you for teaching me how to do this. This is where I first learned to use templates in D, and I have been using them since for functions, and as of yesterday, my first mixin template.

That being said, I'm pleased to announce the return of the Map class. As of yesterday's commit, the class template class MapTemp(TileType:Tile, UnitType:Unit) and interface Map have now been replaced with a single Map class as they were before.

At the time I had asked about this, I had not yet discovered that an array of objects can be filled with objects of a derived type by just using the regular cast syntax. Now that I know this, I've decided to just create the objects under the VisibleTile and VisibleUnit classes, place them in the Map object's arrays (cast to Tile and Unit), and then cast them back whenever I need to access anything specific to the derived classes.

Now I no longer have to deal with the limitations of interfaces. Things should be easier now.

The straw that broke the camels back was when I made my first mixin template, which adds functionality to a class for manipulating arrays of Unit objects. The compiler wasn't allowing it in the Map class because the array that I was trying to give it access to was of UnitType, not specifically the base Unit class. I'm happy to have it back.

1 2
Next ›   Last »