On Sunday, 15 March 2020 at 20:19:17 UTC, Steven Schveighoffer
wrote:
On 3/15/20 4:12 PM, Jordan Wilson wrote:
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer
wrote:
I want to try and learn how to write 2d games. I'd prefer to
do it with D.
I've found a ton of tutorials on learning 2d gaming with
other languages. Is there a place to look that uses D for
learning? Should I just start with another language and then
migrate to D later? Anyone recommend any specific
tutorial/book?
I'm on a similar journey myself, I'll list my findings, maybe
it could be useful for you.
I decided on a game programming library. I mostly looked at
SFML and Allegro, and found both to have good bindings
available in D, and good documentation, and got minimal
examples working with both. I went with SFML, simply because
there was a book written specifically about writing a game in
SFML. I didn't see any such books for Allegro (although there
are plenty of tutorials/articles).
I learnt about the "game loop". Bauss touched on it in his
post, and I'm sure there are a lot of tutorials on it. I
specifically learnt about it from the first few chapters of
the SFML Game Development book.
I learnt about game design. In doing so, I came across
Entity-Component-System design pattern. I decided to use this
pattern, for no other reason than to try something other than
OOP.
I found these links useful:
https://medium.com/ingeniouslysimple/entities-components-and-systems-89c31464240d
https://gameprogrammingpatterns.com/component.html
https://www.richardlord.net/blog/ecs/what-is-an-entity-framework.html
I started writing a game, using the derelict-sfml2 as my game
library (again, I found the allegro library to be good too),
and entitysysd to provide the ECS framework (there are a few
ECS written in D available). Are they the best choices? Is
SFML technically limited? Will I cope with ECS beyound the toy
game example? No idea. But I'm having a lot of fun, which I
think for a hobby project, is a fairly good measure of success
;-)
OK, I will take a look there. I am running through some basic
SDL game video tutorials right now.
Thanks everyone for the pointers.
-Steve
I wouldn't use SDL2 for rendering. It is really just there for
legacy. The only thing people use SDL2 is for setting up a window
and creating a render context for OpenGL/Vulkan/Directx, along
with handling input/events.
Do you want to create games, or do you want to create game
engines? If you want to make games, then you are better off using
something like Unity or UE4. If you want to learn how game
engines work, then you are better off going the
OpenGL/Vulkan/Directx route. But it'll be a lot of work and you
basically have to create everything from the ground up yourself.
If you want to try and lighten your load, it can be difficult to
find separate libraries as everything is quite interconnected,
and if they weren't built to communicate with one another you are
just going to have a difficult time getting everything to work.