Jump to page: 1 25  
Page
Thread overview
Best way to learn 2d games with D?
Mar 15, 2020
bauss
Mar 15, 2020
Ferhat Kurtulmuş
Mar 15, 2020
Ferhat Kurtulmuş
Mar 16, 2020
Mike Parker
Mar 16, 2020
bauss
Mar 16, 2020
Mike Parker
Mar 15, 2020
Jordan Wilson
Mar 15, 2020
Arine
Mar 16, 2020
Mike Parker
Mar 16, 2020
Arine
Mar 16, 2020
Mike Parker
Mar 16, 2020
Arine
Mar 15, 2020
Sebastiaan Koppe
Mar 16, 2020
dwdv
Mar 16, 2020
Jacob Carlborg
Mar 16, 2020
SashaGreat
Mar 16, 2020
Murilo
Mar 17, 2020
aberba
Mar 17, 2020
aberba
Mar 17, 2020
aberba
Mar 17, 2020
aberba
Mar 17, 2020
Sebastiaan Koppe
Mar 17, 2020
Sebastiaan Koppe
Mar 17, 2020
Dennis
Mar 18, 2020
bauss
Mar 19, 2020
Kagamin
Mar 19, 2020
German Diago
Mar 17, 2020
Denis Feklushkin
Mar 17, 2020
Denis Feklushkin
Mar 17, 2020
Jan Hönig
Mar 17, 2020
Dennis
Mar 19, 2020
dangbinghoo
Mar 21, 2020
Gregor Mückl
Mar 22, 2020
Ferhat Kurtulmuş
March 15, 2020
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?

-Steve
March 15, 2020
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?
>
> -Steve

The theory is the same in any language ex. if you can write a 2d game in C++ chances are you can do it in D as well but you could probably apply the same theory to C, Java, Python etc.

So for D what you really need to be familiar with, is just the library you're using.

The theory for a 2d game is rather simple though.

You have a loop on the main thread (or ui thread) and within that you handle events, clear the screen, draw the graphics and repeat pretty much.

I would recommend using Derelict and SDL with D since it's the most mature.

There's DSFML but it's dead and doesn't support the latest version of SFML.

You could also try SFML through Derelict but SDL just seems more stable tbh.

TBH. if you have any experience with GUI engines then applying that to writing a game is pretty much the same.

A player, monster, NPC etc. is just a sprite (which is pretty much just an image.) it has a size, position etc. and you just manipulate that based on the events you receive in your main loop etc.

I don't think there's currently any good or complete tutorials on game development in D, much less 2d game development. There's a lot of "dead" libraries etc.

If you can get a SDL application running and at the very least showing a window then I won't mind helping you in the right direction.

It should be trivial using the guides available at the derelict docs.


March 15, 2020
On 3/15/20 2:14 PM, bauss 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?
>>
> 
> The theory is the same in any language ex. if you can write a 2d game in C++ chances are you can do it in D as well but you could probably apply the same theory to C, Java, Python etc.
> 
> So for D what you really need to be familiar with, is just the library you're using.
> 
> The theory for a 2d game is rather simple though.
> 
> You have a loop on the main thread (or ui thread) and within that you handle events, clear the screen, draw the graphics and repeat pretty much.
>

[snip]

> I would recommend using Derelict and SDL with D since it's the most mature.
> If you can get a SDL application running and at the very least showing a window then I won't mind helping you in the right direction.
> 
> It should be trivial using the guides available at the derelict docs.

Thanks, I'm pretty much starting from zero as I have very little experience in what is necessary to actually do the drawing parts, or how to store/manipulate sprites etc. I've got a lot of experience in GUI design, but getting the rendering to work, making sure it's fast enough, etc. seems like something I'd rather leave to someone else (i.e. library/framework/etc).

I was looking at the lispysnake stuff, and realizing I have no idea what any of the blogs are talking about. The D gaming libraries seem to come from the perspective of "Oh, you know how to write games, here's how you do it in D". I kind of need a "here's how you write 2d games" which uses D as a way to show it.

I think I'll probably just use a straight tutorial with another language and then move on to D. But thank you for the offer, I might take you up on it later.

-Steve
March 15, 2020
On Sunday, 15 March 2020 at 18:45:14 UTC, Steven Schveighoffer wrote:
> On 3/15/20 2:14 PM, bauss wrote:
>>[...]
>
> [snip]
>
>> [...]
>
> Thanks, I'm pretty much starting from zero as I have very little experience in what is necessary to actually do the drawing parts, or how to store/manipulate sprites etc. I've got a lot of experience in GUI design, but getting the rendering to work, making sure it's fast enough, etc. seems like something I'd rather leave to someone else (i.e. library/framework/etc).
>
> I was looking at the lispysnake stuff, and realizing I have no idea what any of the blogs are talking about. The D gaming libraries seem to come from the perspective of "Oh, you know how to write games, here's how you do it in D". I kind of need a "here's how you write 2d games" which uses D as a way to show it.
>
> I think I'll probably just use a straight tutorial with another language and then move on to D. But thank you for the offer, I might take you up on it later.
>
> -Steve

I refer this ugly site a lot for basics of SDL. Since one could easily convert c code to d, transition is very fast.

My favorite 2d game engine is cocos2dx but it has no support for d. I consider Godot-d offers a similar experience. However, it has almost zero documentation.
March 15, 2020
On Sunday, 15 March 2020 at 19:02:11 UTC, Ferhat Kurtulmuş wrote:
> On Sunday, 15 March 2020 at 18:45:14 UTC, Steven Schveighoffer wrote:
>> [...]
>
> I refer this ugly site a lot for basics of SDL. Since one could easily convert c code to d, transition is very fast.
>
> My favorite 2d game engine is cocos2dx but it has no support for d. I consider Godot-d offers a similar experience. However, it has almost zero documentation.

https://lazyfoo.net/tutorials/SDL/index.php
March 15, 2020
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?
>
> -Steve

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 ;-)

Jordan

March 15, 2020
On 3/15/20 3:03 PM, Ferhat Kurtulmuş wrote:
> On Sunday, 15 March 2020 at 19:02:11 UTC, Ferhat Kurtulmuş wrote:
>> On Sunday, 15 March 2020 at 18:45:14 UTC, Steven Schveighoffer wrote:
>>> [...]
>>
>> I refer this ugly site a lot for basics of SDL. Since one could easily convert c code to d, transition is very fast.
>>
>> My favorite 2d game engine is cocos2dx but it has no support for d. I consider Godot-d offers a similar experience. However, it has almost zero documentation.
> 
> https://lazyfoo.net/tutorials/SDL/index.php

Thanks, looks useful.

-Steve
March 15, 2020
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
March 15, 2020
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.

March 15, 2020
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.

No resources but I remember the serpent framework mentioned on this forum here recently. It looks pretty decent.

https://github.com/lispysnake/serpent

« First   ‹ Prev
1 2 3 4 5