www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Best way to learn 2d games with D?

reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
Mar 15 2020
next sibling parent reply bauss <jj_1337 live.dk> writes:
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.
Mar 15 2020
next sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
Mar 15 2020
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
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.
Mar 15 2020
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
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
Mar 15 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
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
Mar 15 2020
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 15 March 2020 at 18:14:44 UTC, bauss wrote:

 I would recommend using Derelict and SDL with D since it's the 
 most mature.
Please don't recommend Derelict to anyone :-) bindbc-sdl is what folks should be using now. I'm not maintaining Derelict anymore.
Mar 15 2020
parent reply bauss <jj_1337 live.dk> writes:
On Monday, 16 March 2020 at 02:52:56 UTC, Mike Parker wrote:
 On Sunday, 15 March 2020 at 18:14:44 UTC, bauss wrote:

 I would recommend using Derelict and SDL with D since it's the 
 most mature.
Please don't recommend Derelict to anyone :-) bindbc-sdl is what folks should be using now. I'm not maintaining Derelict anymore.
Haven't even heard of that! Does it work in similar fashion?
Mar 15 2020
parent Mike Parker <aldacron gmail.com> writes:
On Monday, 16 March 2020 at 05:45:52 UTC, bauss wrote:

 Please don't recommend Derelict to anyone :-) bindbc-sdl is 
 what folks should be using now. I'm not maintaining Derelict 
 anymore.
Haven't even heard of that! Does it work in similar fashion?
Yes. The loader is nog and betterC compatible, and I've taken a different approach to handling multiple library versions. Other than that, basically the same. https://github.com/BindBC/bindbc-sdl
Mar 15 2020
prev sibling next sibling parent reply Jordan Wilson <wilsonjord gmail.com> writes:
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
Mar 15 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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- ystems-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
Mar 15 2020
parent reply Arine <arine123445128843 gmail.com> writes:
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.
Mar 15 2020
parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 15 March 2020 at 21:33:29 UTC, Arine wrote:

 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.
There's no need for someone just learning 2D games to implement their own OGL/Vulkan/DX renderer. The SDL2 rendering API is plenty fine. And it isn't just for "legacy". It was supposed to be an enhancement over SDL's old SDL_Surface API. When they first implemented it, they restricted it to the features they implemented cross-platform in software. It also didn't do any batching for the hardware rendering. As of SDL 2.10, they have batching for the hardware renderers, which makes it even more usable. The only time I would recommend against the SDL2 renderer for a 2D game is when you A) already have your own renderer implemented anyway, or B) need some fancy shader effect. I've seen people get some decent F/X with the SDL2 renderer, but it's limited in that regard. Still no need to implement a custom renderer, though, as SDL_gpu opens the doors to shaders.
Mar 15 2020
parent reply Arine <arine123445128843 gmail.com> writes:
On Monday, 16 March 2020 at 03:03:15 UTC, Mike Parker wrote:
 On Sunday, 15 March 2020 at 21:33:29 UTC, Arine wrote:

 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.
There's no need for someone just learning 2D games to implement their own OGL/Vulkan/DX renderer. The SDL2 rendering API is plenty fine. And it isn't just for "legacy". It was supposed to be an enhancement over SDL's old SDL_Surface API. When they first implemented it, they restricted it to the features they implemented cross-platform in software. It also didn't do any batching for the hardware rendering. As of SDL 2.10, they have batching for the hardware renderers, which makes it even more usable. The only time I would recommend against the SDL2 renderer for a 2D game is when you A) already have your own renderer implemented anyway, or B) need some fancy shader effect. I've seen people get some decent F/X with the SDL2 renderer, but it's limited in that regard. Still no need to implement a custom renderer, though, as SDL_gpu opens the doors to shaders.
There's no need for someone learning 2D games to even bother with SDL2 to begin with. If you use SDL2 you are going to be using something no one else uses, you'll be wasting your by using something that isn't that good and what you learn from it won't be that useful. I don't know anyone that uses SDL2 actual API for rendering. Using OpenGL and similar API, you'll learn how data actually needs to be processed. If you just want to mess around with making a game, using a game engine like Unity is going to be better for that. No one should waste their time with SDL2's rendering API, it is awful and doesn't actually teach you anything about how rendering actually works. So in either case, whether it be games you want to make, or game engines. You are better off not learning SDL2 rendering, as it would just be a waste of time.
Mar 16 2020
parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 16 March 2020 at 16:19:26 UTC, Arine wrote:

 There's no need for someone learning 2D games to even bother 
 with SDL2 to begin with. If you use SDL2 you are going to be 
 using something no one else uses, you'll be wasting your by 
 using something that isn't that good and what you learn from it 
 won't be that useful. I don't know anyone that uses SDL2 actual 
 API for rendering. Using OpenGL and similar API, you'll learn 
 how data actually needs to be processed. If you just want to 
 mess around with making a game, using a game engine like Unity 
 is going to be better for that. No one should waste their time 
 with SDL2's rendering API, it is awful and doesn't actually 
 teach you anything about how rendering actually works.
I just disagree completely. You'll find people in the SDL forums using it. I've used it. I've seen open source games using it. It's simple for someone just beginning to get started with. No need to muck about with the details of OpenGL, or with the complexities of a full-scale game engine. For Steve's purposes, it's just fine.
Mar 16 2020
parent Arine <arine123445128843 gmail.com> writes:
On Monday, 16 March 2020 at 16:42:56 UTC, Mike Parker wrote:
 On Monday, 16 March 2020 at 16:19:26 UTC, Arine wrote:

 There's no need for someone learning 2D games to even bother 
 with SDL2 to begin with. If you use SDL2 you are going to be 
 using something no one else uses, you'll be wasting your by 
 using something that isn't that good and what you learn from 
 it won't be that useful. I don't know anyone that uses SDL2 
 actual API for rendering. Using OpenGL and similar API, you'll 
 learn how data actually needs to be processed. If you just 
 want to mess around with making a game, using a game engine 
 like Unity is going to be better for that. No one should waste 
 their time with SDL2's rendering API, it is awful and doesn't 
 actually teach you anything about how rendering actually works.
I just disagree completely. You'll find people in the SDL forums using it. I've used it. I've seen open source games using it. It's simple for someone just beginning to get started with. No need to muck about with the details of OpenGL, or with the complexities of a full-scale game engine. For Steve's purposes, it's just fine.
Yes, I see youtube tutorials that tend to use it and the quality of the tutorial usually reflects that. I didn't say no one uses, merely the individuals that tend to gravitate towards it. Just as I would say with smoking a cigarette. Not sure what you mean by complexities of a full-scale game engine. The complexity is almost entirely removed, to the point that you could use a visual scripted language like blueprint in UE4 if you wanted to. Yah it's fine for his purposes, it's just a waste of time to use it. If you want to make a game, using something like Unity is going to be better for you. If you want to learn how game engines work, actually using OpenGl and such is going to be better for you. Just like not smoking a cigarette, there are better options.
Mar 16 2020
prev sibling next sibling parent Sebastiaan Koppe <mail skoppe.eu> writes:
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
Mar 15 2020
prev sibling next sibling parent dwdv <dwdv posteo.de> writes:
On 2020-03-15 18:58, Steven Schveighoffer via Digitalmars-d-learn wrote:
 I'd prefer to do it with D.
How about raylib in conjunction with thin d bindings? I prefer it over sdl, sfml and the like. https://www.raylib.com/examples.html (make sure to enable js for embedded examples) https://code.dlang.org/packages/raylib-d https://github.com/raysan5/raylib/blob/master/BINDINGS.md
 Should I just start with another language and then migrate to D later? 
If you can stomach lua(jit), check out love2d. Docs and provided game tutorials are super easy to follow: https://love2d.org/ https://love2d.org/wiki/Category:Tutorials Lastly, if you're more interested in the gamedev aspect, there's also the option to pick your poison from this curated mixed list of slim and fat 2d game engines: https://thomasgervraud.com/best-2d-game-engine/
Mar 15 2020
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
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?
You can have a look at the SpriteKit framework [1]. Although it will only work on Apple’s platforms. [1] https://developer.apple.com/spritekit/ — /Jacob Carlborg
Mar 16 2020
prev sibling next sibling parent SashaGreat <s g.com> writes:
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 problem of developing with D are the Libs. Someone recommended Derelict but like Mike said:
 Please don't recommend Derelict to anyone :-) bindbc-sdl is 
 what folks should be using now. I'm not maintaining Derelict 
 anymore.
I was using Derelict because back in the day it was recommended here until to find out it was not supported anymore. As I am game developer hobbyist, who likes to explore and recreate games and implement engines algorithm myself to mimic games like: Mario, F-Zero (Mode-7), Wolf3D (Raycasting), Doom and so on, I would recommend you to look over SDL (OpenGL is a plus), and the rest is just Math. Sasha.
Mar 16 2020
prev sibling next sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/15/20 1:58 PM, 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?
Thanks everyone for all the suggestions. I'm probably going to start with SDL2 and try and get to the point where I understand and can use the lispysnake stuff. I can probably follow any C++/SDL2 tutorials and just do it in D instead. Just getting the understanding of the lingo and the standard game design is really what I need to start with. -Steve
Mar 16 2020
prev sibling next sibling parent Murilo <murilomiranda92 hotmail.com> writes:
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
Hi Steve, I have written a nice tutorial on that. Here is the link to it: https://themindofmurilomiranda.blogspot.com/2020/01/beginning-multimedia-with-arsd.html I have also written a very elaborated Space Invaders game as an example of how to use what you will learn in the tutorial above, here is the link to it: https://themindofmurilomiranda.blogspot.com/2020/01/space-invaders-game-example-to-learn.html
Mar 16 2020
prev sibling next sibling parent aberba <karabutaworld gmail.com> writes:
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
Over the years, I've seen so many 2d game frameworks/engine get started and abandoned here. I would recommend DSFML if you can get it to work. I really like the SFML API design. With that said, here are some I looked at: https://code.dlang.org/packages/d2dgame (based on SDL2 by WebFreak001, not sure how mature it is though, see a demo at https://github.com/WebFreak001/D2DGame/blob/master/example/source/app.d) https://code.dlang.org/packages/dagon (Mostly 3d, but can do 3d/2d games too. The most advanced of any D game engine/framework. Tonne of work poured into it) https://code.dlang.org/packages/pixelperfectengine (retro games, I have seen several YouTube demos by the dev) https://code.dlang.org/packages/godot-d (Godot is quite popular..used in commercial game. Not sure how good and easy to use this binding is though) https://themindofmurilomiranda.blogspot.com/2020/01/space-invaders-game-e ample-to-learn.html (Murilo Miranda has this tutorial he pulled together after working tirelessly and asking many question on using Adam's arsd package here, I like this guy's tenacity)
Mar 16 2020
prev sibling next sibling parent aberba <karabutaworld gmail.com> writes:
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
Its sad we still don't have a really great framework/engine for developing 2d games in D...even with many options in C available. It seems the casual game community/fan is missing here.
Mar 16 2020
prev sibling next sibling parent reply aberba <karabutaworld gmail.com> writes:
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
https://github.com/DerelictOrg/DerelictSFML2 is the most up to date D binding to SFML library. Now that the maintainer is saying bindbc is better, I'm not sure the way to go. Will we ever get a bindbc-sfml? By the way, the maintainer of DSFML went very far by creating a great website with docs and tutorials at http://www.dsfml.com/
Mar 16 2020
parent reply aberba <karabutaworld gmail.com> writes:
On Tuesday, 17 March 2020 at 03:13:02 UTC, aberba 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?

 -Steve
https://github.com/DerelictOrg/DerelictSFML2 is the most up to date D binding to SFML library. Now that the maintainer is saying bindbc is better, I'm not sure the way to go. Will we ever get a bindbc-sfml? By the way, the maintainer of DSFML went very far by creating a great website with docs and tutorials at http://www.dsfml.com/
You can still use DSFML with an older compiler by installing and using with something like DVM (https://code.dlang.org/packages/dvm)
Mar 16 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/16/20 11:19 PM, aberba wrote:
 On Tuesday, 17 March 2020 at 03:13:02 UTC, aberba 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?
https://github.com/DerelictOrg/DerelictSFML2 is the most up to date D binding to SFML library. Now that the maintainer is saying bindbc is better, I'm not sure the way to go. Will we ever get a bindbc-sfml? By the way, the maintainer of DSFML went very far by creating a great website with docs and tutorials at http://www.dsfml.com/
You can still use DSFML with an older compiler by installing and using with something like DVM (https://code.dlang.org/packages/dvm)
Thanks for all your tips! It looks like the dsfml author is still active as of June last year. It sounds like it's possible to have it updated to work with the latest compilers (I can probably help with that), and hopefully he is not totally inactive. Seems like SFML is a really common way to get started. I think I have enough info in this thread to at least get something to play with. It's not something I'm intending to create professionally, really the impetus is my son wanting to do more significant game coding. -Steve
Mar 17 2020
next sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 17 March 2020 at 15:38:55 UTC, Steven Schveighoffer 
wrote:
 It's not something I'm intending to create professionally, 
 really the impetus is my son wanting to do more significant 
 game coding.

 -Steve
How old is he? I find something simple like gamemaker works well with 12-16 olds.
Mar 17 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/17/20 2:22 PM, Sebastiaan Koppe wrote:
 On Tuesday, 17 March 2020 at 15:38:55 UTC, Steven Schveighoffer wrote:
 It's not something I'm intending to create professionally, really the 
 impetus is my son wanting to do more significant game coding.
How old is he? I find something simple like gamemaker works well with 12-16 olds.
He's done a lot of stuff in Scratch. I taught him and a whole group of other homeschoolers a class on javascript and this year (up until this whole virus thing) we were working in Roblox (lua). So far I try to make the lessons not so much about the language or the environment, but the code concepts. I don't really love the scratch methodology of dumbing down everything, I feel like it limits too much and doesn't help you enough to learn necessarily the parts of programming that transfer to all other programming languages. Yes, it has loops, yes it has data (though it's really convoluted), but it's not going to transfer to real-world coding. It looks like gamemaker is along the same lines "write games without ever having to code" seems like it defeats the purpose of what I'm trying to do ;) Essentially I want to turn his drive to "make a game" into giving him a good background in programming. And of course I want to use D here! Why start them on a lesser language. -Steve
Mar 17 2020
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Tuesday, 17 March 2020 at 18:55:08 UTC, Steven Schveighoffer 
wrote:
 He's done a lot of stuff in Scratch. I taught him and a whole 
 group of other homeschoolers a class on javascript and this 
 year (up until this whole virus thing) we were working in 
 Roblox (lua). So far I try to make the lessons not so much 
 about the language or the environment, but the code concepts.

 I don't really love the scratch methodology of dumbing down 
 everything, I feel like it limits too much and doesn't help you 
 enough to learn necessarily the parts of programming that 
 transfer to all other programming languages. Yes, it has loops, 
 yes it has data (though it's really convoluted), but it's not 
 going to transfer to real-world coding. It looks like gamemaker 
 is along the same lines "write games without ever having to 
 code" seems like it defeats the purpose of what I'm trying to 
 do ;)
Dont trust that marketing, there is actually decent scripting in gamemaker, which you'll need if you get creative. Plus plenty of good example games that are also quite playable.
Mar 17 2020
parent reply Dennis <dkorpel gmail.com> writes:
On Tuesday, 17 March 2020 at 22:47:43 UTC, Sebastiaan Koppe wrote:
 Dont trust that marketing, there is actually decent scripting 
 in gamemaker, which you'll need if you get creative.
Second that. GameMaker is how I got into programming at age 12, and look where I ended up ;)
Mar 17 2020
parent reply bauss <jj_1337 live.dk> writes:
On Tuesday, 17 March 2020 at 23:09:32 UTC, Dennis wrote:
 On Tuesday, 17 March 2020 at 22:47:43 UTC, Sebastiaan Koppe 
 wrote:
 Dont trust that marketing, there is actually decent scripting 
 in gamemaker, which you'll need if you get creative.
Second that. GameMaker is how I got into programming at age 12, and look where I ended up ;)
Similar for me but not GameMaker but RPG Maker.
Mar 17 2020
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/18/20 1:37 AM, bauss wrote:
 On Tuesday, 17 March 2020 at 23:09:32 UTC, Dennis wrote:
 On Tuesday, 17 March 2020 at 22:47:43 UTC, Sebastiaan Koppe wrote:
 Dont trust that marketing, there is actually decent scripting in 
 gamemaker, which you'll need if you get creative.
Second that. GameMaker is how I got into programming at age 12, and look where I ended up ;)
Similar for me but not GameMaker but RPG Maker.
I've seen all your work on the language, and this is a pretty good endorsement. Not sure if I'm ready to pay for it though, I want to make sure his motivation/drive is not going to fizzle out ;) -steve
Mar 19 2020
parent Kagamin <spam here.lot> writes:
On Thursday, 19 March 2020 at 13:10:29 UTC, Steven Schveighoffer 
wrote:
 Similar for me but not GameMaker but RPG Maker.
I've seen all your work on the language, and this is a pretty good endorsement. Not sure if I'm ready to pay for it though, I want to make sure his motivation/drive is not going to fizzle out ;)
IME RPG Maker has bad support for animations and shines in mostly static turn based RPG battles. Some games try to do nontrivial animations, but they become very slow slideshows with many seconds between slides. Not sure which game he would prefer to make.
Mar 19 2020
prev sibling parent German Diago <germandiago gmail.com> writes:
My two cents doing some 2D stuff for a while (a cards game).

1. stick to SDL2 if you want to have something that will work in 
many places. SFML AFAIK is not so compatible.

 From there, maybe I would start by mixing SDL2* libraries and 
using D with extern(C) interfaces if needed unless there is a 
well-maintained wrapper.

The rest of the alternatives just brought trouble to me when 
trying to run in many systems.
Mar 19 2020
prev sibling next sibling parent reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
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
Years ago I wrote this unfinished 2D platformer engine on D: https://github.com/denizzzka/Platformer It ises SFML (graphics and sound), Spine (animation engine) and dchip (2d physics engine)
Mar 16 2020
parent reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
On Tuesday, 17 March 2020 at 04:17:41 UTC, Denis Feklushkin wrote:

 Years ago I wrote this unfinished 2D platformer engine on D:

 https://github.com/denizzzka/Platformer

 It ises SFML (graphics and sound), Spine (animation engine) and 
 dchip (2d physics engine)
Physics engine used only for ragdoll animation. So, if you want to learn how to programm 2D platformer just look into main loop - It is really simple! https://github.com/denizzzka/Platformer/blob/master/source/app.d#L44
Mar 16 2020
parent Jan =?UTF-8?B?SMO2bmln?= <hrominium gmail.com> writes:
I made a similar search two months ago as well.

I recommend a simple library.
I landed with https://code.dlang.org/packages/raylib-d
It is supposed to be for learning how to do 2d games.
It is easy to work with, which was my main search parameter.
I need to figure out the logic, physics, client-server first, 
before I do some fancy-pants graphics.
Mar 17 2020
prev sibling next sibling parent Dennis <dkorpel gmail.com> writes:
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 haven't seen anyone mention Dgame yet: https://github.com/Dgame/Dgame It's not maintained anymore since last November [1], but is seems pretty mature and it has a tutorial: http://dgame-dev.de/index.php?controller=learn&mode=tutorial&version=0.6 [1] Searching for Dgame Maintainer - https://forum.dlang.org/post/mkobhebqxcfytkgaldis forum.dlang.org
Mar 17 2020
prev sibling next sibling parent =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= writes:
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
Writing own framework - is the best !
Mar 18 2020
prev sibling next sibling parent reply dangbinghoo <dangbinghoo gmail.com> writes:
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
there's a youtube channel teaching 2D game dev. using dlang: https://www.youtube.com/channel/UCK3fxU3_7tzBhZZ_6rljAQA/videos
Mar 18 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 3/19/20 2:22 AM, dangbinghoo 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?
there's a youtube channel teaching 2D game dev. using dlang: https://www.youtube.com/channel/UCK3fxU3_7tzBhZZ_6rljAQA/videos
Oh wow, that is awesome! I'll take a look. Thanks. -Steve
Mar 19 2020
prev sibling next sibling parent Gregor =?UTF-8?B?TcO8Y2ts?= <gregormueckl gmx.de> writes:
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
Back in the 90s, when I was young, I learned a lot about game programming on MS DOS using allegro. That library is wonderful in that it allows you a lot of things that you need in a simple 2D game in a pretty straightforward fashion. It's really easy to get pleasing results with it. And it's still around, has become cross platform without losing its focus. And it has really decent D bindings. The other library that comes close in both completeness and ease of use is PyGame, but this is Python only. It's a wrapper around all the SDL_* libraries (image, ttf, mixer, etc..), but done in such a nice way that it's usable in a very neat way from Python. In response to Arine, I have to disagree regarding big hulking game engines. Learning how to properly use one of these game engines for a simple game is about as much effort as coding it from scratch and the later is much more useful as it teaches you the fundamentals of what is going on inside these big, scary monsters. The abstractions that Unity and UE4 build upon are useful for creating something fast, but you still require a really deep understanding to use them properly. These are tools for (semi-)professionals and there's an implicit expectation that you are at a pretty high proficiency level.
Mar 21 2020
prev sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
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 just leave this here: https://github.com/aferust/drawee My hobby game has been implemented using just SDL and OpenGL (WIP). betterC, no game engines used, no bitmap textures (but planned). There is only one c linkage dependency (chipmunkd) for physics. I was planning to use only SDL, but I had to include OpenGl due to some performance reasons.
Mar 22 2020