Тёмный
Dylan Falconer
Dylan Falconer
Dylan Falconer
Подписаться
The Artisanal Programmer.
Building game programming resources.
Videos about how to improve your game programming skills.
5 Things Every Game Programmer Should Know
14:42
2 месяца назад
Dynamic Arrays in C
11:46
8 месяцев назад
A to Zig | 03 Arrays
2:14
2 года назад
A to Zig | 02 Values
1:48
2 года назад
Комментарии
@allNicksAlreadyTaken
@allNicksAlreadyTaken 5 часов назад
Love this video. I recently did something very similar and implemented a few different architectures like this for a simple asteroid game on GitHub pfirsich/game-architecture-comparison. I implemented pretty much the alternatives you presented and some more.
@dawill5217
@dawill5217 11 часов назад
Am i the only one who thought this was about Amazon ecs?😅 Great video either way. Always nice to learn more about game dev👍.
@orterves
@orterves 13 часов назад
I think the key idea is to know your constraints and build only what you need. General purpose systems and large teams have very different constraints and requirements compared to a small team and highly specific system. The real trick is building only what you need, minimally and effectively, but in such a way that it leaves room to expand in the future if necessary - you have to keep the bigger picture and future in mind even if you're not yet building it, or there is a risk of painting yourself into a corner and having to rewrite
@vantadaga
@vantadaga 20 часов назад
Great video, what editor theme is that?
@LuizMoraes-xb7qj
@LuizMoraes-xb7qj 23 часа назад
I believe Odin's [dynamic] has stable pointers so even if it grows you don't have the problem of losing the reference to it
@jeisonsantiago1735
@jeisonsantiago1735 День назад
Spot on explanation, I would love to see more of those. Great channel btw!
@jonas.1110
@jonas.1110 День назад
Nice video, Dylan!
@nommos
@nommos День назад
Very good advice for general game programming, and nice to have the example in Odin. Megastructs are not for game programming only, I think most software would benefit from this approach. Instead of classes, object instances and their methods, you just have chunks of data that allow for a large set of behaviour, and functions operating on that data.
@GingerGames
@GingerGames День назад
Brilliant video!
@DylanFalconer
@DylanFalconer День назад
Thanks, Bill :)
@sanderbos4243
@sanderbos4243 День назад
Great video!
@DylanFalconer
@DylanFalconer День назад
Thanks!
@Veeq7
@Veeq7 День назад
How do you multithread it? If you can't reason about your data it's hard to scale multithreading (especially deterministically). I get most games don't need multithreading, but for something like mass scale rts it would be nice..
@DylanFalconer
@DylanFalconer День назад
Yeah, for multithreading, you'd be looking at bespoke systems that don't fit here I've only multithreaded rendering before, so I'm only speculating here... You could split routines into threads if they don't affect each other Let's say physics in one, updating status effects in another Or you could use some spatial data structure to query entities nearby each other and send results to a job queue
@marcsh_dev
@marcsh_dev 8 часов назад
(Messed up the sizes, which is really important for this, so changing it. I said it was 7 megs, but it 28 megs (7*4)) How to scale it depends on needs (which youve supplied). So, for a mass scale RTS, I built a prototype of a chunk based "ECS" (though, this idea would work for the other 2 options also). So, each block of data was a compile time constant size, 4096 being really solid. My ECS was also double buffered, and allowed reads from last frames data by any thread AND made things faster for me (bonus!) Then, for my systems I basically did: foreachcore( process chunk_stride_start+core_i ) {I say "ECS" but it was a chunked structure of arrays system per archetype (much like most ECSs are under the hood)} Its part of my billion active entity updates / second (prototype) project. I got there on my AMD 5950x + 3090 (though the video card was just mostly idling). The only entities I had in at the time however was projectiles flying all over, and so more experimentation is needed. { I dont personally care about strict deterministic behaviour (which is a long story), but given storing both old and new states, it should be very doable. I havent put a huge amount of thought into it yet though } A couple of big takeaways. Gameplay data is very often (even for an RTS) a very small portion of all the data a game needs to deal with. So, doing things like double buffering of it (or potentially even more) is very often not a huge deal. Lets say you had a million units, like actual individually instructable units (not like what Total War does). Even at full res for position, youre going to have 3 floats for position, and 2 for orientation (4 of you must). So thats 7*4 or 28 megs on the outside and can absolutely be shrunk if you need more units/less data, so 56 megs for updating its Pos+Orient data. 1 2048x2048 texture is 16 megs by itself (granted, youll be storing that as something like DXTC<blah bla> or whatever, but still) Going >1million units is still doable to about 10million, but over 10 or 20 million Id start coming up with ways to process groups of them more like particles than units.
@Veeq7
@Veeq7 8 часов назад
@@marcsh_dev My units were easily 2kb in size for a basic unit implementation (for a game with mechanics, not a battle demo. ofcourse this is not including game date which was just a pointer/unit id to another table somewhere), not even with all the behaviors I currently support in Cosmonarchy Not sure about chunks btw, I have not tried/seen such implementation. I tried making an ecs, but got pretty complicated pretty quickly when I wanted to start implementing deterministic multithreading (which I need for lock step multiplayer)
@marcsh_dev
@marcsh_dev 8 часов назад
2kb of dynamically changing data per frame? Thats the data Im talking about. You can have all sorts of static / per unit data, and only occasionally changing data in different spots. The point of the double buffering is solely for the small per frame subset of data.
@marcsh_dev
@marcsh_dev 8 часов назад
Re Chunks: If you have a flat array, its relatively simple. You can even just do it with a single command on many different languages and systems. Ie they often have a 'parallel_for( my_huge_array, num_cores )'. Its also easy enough to go from something like std::vector to motive::vector_chunk, and just have a set of pointers to vector chunks It is slightly tricky to add and remove entities from the chunk, but not hugely different than doing it from a big array
@RockTo11
@RockTo11 День назад
I believe the "distinct int" can be done in C, by just wrapping an int in a struct. typedef struct { int id; } Entity_Id; void do_something_with_an_entity(Entity_Id eid) { for (Entity_Id i = {0}; i.id < 10; ++i.id) { //... } }
@Veeq7
@Veeq7 День назад
potentially enum EntityId : int {} don't recall if it works well in plain C though
@snesmocha
@snesmocha 12 часов назад
You don’t even need to do this typedef int entity;
@Veeq7
@Veeq7 11 часов назад
@@snesmocha no, that's a still int, i.e. weak type. compiler won't help
@marioigkiempor6579
@marioigkiempor6579 День назад
Very clear video thank you. The examples make it easy to follow. Maybe the code samples could be larger for us mobile watchers though 😅
@DylanFalconer
@DylanFalconer День назад
Thank you! I'll make sure they are larger next time
@MrSomethingdark
@MrSomethingdark 6 дней назад
General Programming!
@igorthelight
@igorthelight 9 дней назад
We need Loki programming language! With as many tricks and "what you see is not what it is" moments! Just for lulz ;-)
@101graffhead
@101graffhead 9 дней назад
in the normalize example why is deltaframetime added instead of just speed? thanks
@shadownight2248
@shadownight2248 10 дней назад
I really like all variables having zero types
@KristinMurray-t6g
@KristinMurray-t6g 12 дней назад
Thomas Margaret Williams Jennifer Jackson Patricia
@nomadtrails
@nomadtrails 16 дней назад
I'm using Raylib to learn Go, Zig, and Odin. Programming just got fun again. Its hard to go back to work building web stuff in typescript hahaha.
@diegofloor
@diegofloor 17 дней назад
I'm laughing at the font bit. "No"
@aylazer23
@aylazer23 17 дней назад
You've left the C gang i guess 😔
@DylanFalconer
@DylanFalconer 16 дней назад
Yeah, it was tough I won't lie! C will always have a special place in my heart
@wiktorwektor123
@wiktorwektor123 6 дней назад
@@DylanFalconer It was hard for me too. But slices, custom allocators, "batteries included", defer, array programming, context etc. were too good to not swich.
@josephferano
@josephferano 17 дней назад
My almonds are fully active learning about raylib shaders now...
@josephferano
@josephferano 17 дней назад
My almond got activated, now I'm learning about shaders in raylib...
@DylanFalconer
@DylanFalconer 16 дней назад
Giving me ideas of using simple shapes with a bunch of post processing
@sanderbos4243
@sanderbos4243 17 дней назад
Great showcase! Definitely activated my almonds
@DylanFalconer
@DylanFalconer 16 дней назад
Glad you enjoyed!
@Unavailable8923
@Unavailable8923 18 дней назад
What are the pros and cons of using Odin+raylib vs. Odin+SDL2?
@LeoAzul-xo7fy
@LeoAzul-xo7fy 18 дней назад
Raylib is simpler to use out of the box as the API handles most things you would need to program a game on the graphics side, while, SDL is more flexible and, is designed in a way to be easily integrated with other libraries and APIs
@budgetjim
@budgetjim 18 дней назад
Raylib also provides functions for 3D graphics (model loading, animation, rendering) that SDL does not.
@KodosUnofficial2-jq5oo
@KodosUnofficial2-jq5oo 17 дней назад
Raylib have built-in camera and collision system, in SDL you should implement that from scratch.
@DylanFalconer
@DylanFalconer 16 дней назад
Good question, I think everyone else already covered it so thanks guys!
@CoolestPossibleName
@CoolestPossibleName 18 дней назад
CloseWindow function should be called before ending the program
@LeoAzul-xo7fy
@LeoAzul-xo7fy 18 дней назад
No, when the program exits, the OS itself destroys the window and clears it's memory, which is more efficient than doing it yourself
@CoolestPossibleName
@CoolestPossibleName 17 дней назад
@@LeoAzul-xo7fy won't there be a memory leak?
@LeoAzul-xo7fy
@LeoAzul-xo7fy 17 дней назад
@@CoolestPossibleName The OS clears the memory, as stated
@DatBoi_TheGudBIAS
@DatBoi_TheGudBIAS 19 дней назад
@ 1:00, im pretty sure it will display 420, IF it reaches the printf. It either overwrites that place of memory and prints it, or u get an access violation by accessing invalid memory. *maybe* it can happen that the piece of memory being written is volatile and somehow changes value in the nanosseconds that are between the instructions
@hromska6955
@hromska6955 26 дней назад
I seem to be able to successfully build and run but the game immediately closes similarly to other here. My issue is that I get this error Error reading file: ./shaders/default.vert. errno: 2 Error reading shader: ./shaders/default.vert I've try soling it but I'm at a loss here :(
@kcvinu
@kcvinu 27 дней назад
How do you manage memory for short lived objects ? Community says that use temp allocator and flush everything when the message loop exits. But that's entire program's life time! is there any best strategy to manage memory for short living objects ?
@wiktorwektor123
@wiktorwektor123 22 дня назад
You can do like community said (per frame/cycle) if this is not what you want create new scope with curly braces, allocate memory and defer it's release
@kcvinu
@kcvinu 22 дня назад
@@wiktorwektor123 Solved with a heap living array which has the lifetime of entire program's life time. So it's faster and safer now.
@wiktorwektor123
@wiktorwektor123 21 день назад
@@kcvinu I tought you needed some object of unknown size. If size is known then heap allocation is best way. No allocators and no need to free used memory. It will be done automaticly.
@kcvinu
@kcvinu 21 день назад
@@wiktorwektor123 I have questions about temp_allocator. Because, 'free_all' is called at the end of the program. So the memory blocks are being remained in leaked state. That's my concern.
@kcvinu
@kcvinu 21 день назад
So I changed my function a little bit. Instead of using 'make' to create a dynamic array each time, I used a permanent heap allocated array with enough size.
@Unavailable8923
@Unavailable8923 Месяц назад
For a paid Odin gamedev course, say on Udemy, I would want to see in the "syllabus" that "shipping a game" was covered which would include at least: providing the player with control customization and other settings, using the Steam API and deploying to other platforms such as iOS and Android.
@DylanFalconer
@DylanFalconer 29 дней назад
Thanks for the suggestions!
@TonyShasta
@TonyShasta Месяц назад
Wow, that fast forward bit was lame..no thanks
@Skytrias
@Skytrias Месяц назад
Great video!
@DylanFalconer
@DylanFalconer 29 дней назад
Thanks!
@eduardabramovich1216
@eduardabramovich1216 Месяц назад
Please continue making more Odin tutorials. I would awesome to have something like "Odin by example", where the complexity of each tutorial increases slowly.
@DylanFalconer
@DylanFalconer 29 дней назад
Thanks for the idea!
@theaveasso
@theaveasso Месяц назад
Sir when you start to build a odin raylib tutorial series 😅
@DylanFalconer
@DylanFalconer Месяц назад
Already made one and working on another! Check the link in the description (there's a free Pong course available) I'm working on my paid course right now as priority, but I'll be making Odin + Raylib videos every so often on YT as well
@wChris_
@wChris_ Месяц назад
I would define the Header like so, to avoid any alignment issues: struct array { size_t capacity; size_t length; T data[]; } you would then initialize it all the same, except you would return &h->data; Also you can use designated initializers: h = {.capacity=capacity, .length=length}; This is more efficient since this allows padding to be explicitly overwritten with 0.
@AlessandroStamatto
@AlessandroStamatto 15 дней назад
Nice, it also makes it a conformant Flexible Array
@holleey
@holleey 2 месяца назад
3:09 oh yeah it's "all you need", except that you can spend pretty much an infinite amount of time on any one of those things if you want to get them on a level anywhere close to being marketable. looking at the Hollow Knight example analytically, there's a ton of particle and lighting effects stacked on top of each other. if you were to develop all of those systems from scratch it would take months if not years and at the end it would still look worse. making your own game engine is great for learning (spent a decade building engines in JS, C, and Nim myself), but just don't expect anything marketable will come out of it.
@DylanFalconer
@DylanFalconer Месяц назад
There are tons of games that didn't use a 3rd party engine and look great. Tooth and Tail, Stardew Valley, Teardown to name a few. Also, pretty much every game before the 2000s used in-house custom engines. I don't know you but I'd bet you suffer from the same thing I did which is lack of focus. If you spent that time working towards one game or a series of games, it'd be nearly impossible to have a bad looking game after 10 years. Just because you didn't do it doesn't mean others can't. Also doesn't mean you can't - you just chose not to.
@holleey
@holleey Месяц назад
@@DylanFalconer please note that I did not say that custom-engine games never look great. the point is that you shouldn't expect to achieve something marketable anywhere near a comparable time frame - repeatedly. we actually want to try making some money here, right? replace "tons of" with "tiny few", especially in relation to the amount of marketable games that are not using a custom engine. sure, it's theoretically possible, like have your girlfriend fund you for a decade like Stardew Valley guy, but these really are exceptions, sorry to say. and yes, if everybody would make their own engines like back in the day then that would be what you had to compete against, and so naturally it would be viable. as for the focus, yeah, certainly, if one is capable to consistently work on only the most essential features, then they'd make fast progress. but honestly, is that realistic? I don't think that this is how our brains work in general, and if you are accountable only to yourself there's no way you'd maintain that. again - speaking generally. I am sure there are some prodigies.
@lordofthe6string
@lordofthe6string 2 месяца назад
In the description it says free course, but when I look it's not free. Am I missing something or is it a mistake?
@DylanFalconer
@DylanFalconer 2 месяца назад
Thanks for letting me know. The homepage changed to promote the paid course. The free one is at programvideogames.com/pong.html
@lordofthe6string
@lordofthe6string 2 месяца назад
@@DylanFalconer thanks 👍 the paid course looks good too
@VerlaBerinyuy
@VerlaBerinyuy 2 месяца назад
@rohandvivedi
@rohandvivedi 2 месяца назад
Good design, but this design also requires handling cases when the reference itself is invalidated after a resize.
@Bl0xxy
@Bl0xxy 2 месяца назад
This tutorial is not helpful at all. I need the links, nothing i'm getting is the same. all i want is to setup sdl and a simple text renderer that's IT why can't it be that simple omfg
@DylanFalconer
@DylanFalconer 2 месяца назад
I agree, the setup stage for these projects can be frustrating. The links have changed since a few years ago. Is there a specific reason want to use SDL for your text renderer?
@Bl0xxy
@Bl0xxy 2 месяца назад
@@DylanFalconer tbh I js want a text renderer, whatever works. Also the reason I want to use Sdl is because I'm challenging myself to make a 3d raycaster
@Bl0xxy
@Bl0xxy 2 месяца назад
@@DylanFalconer oh by the way it WAS helpful, i was just upset with all the errors i got. Its just that I'm struggling and idk what to do
@DylanFalconer
@DylanFalconer 2 месяца назад
Gotcha, in that case have you considered something like Raylib? It's pretty flexible, you can still write shaders but it has a bunch of built in functionality (including text rendering)
@packmandudefake
@packmandudefake 2 месяца назад
10:34 That’s why you use WireShark to check on what gets sent and received without interrupting the execution with breakpoints to inspect things.
@jumbledfox2098
@jumbledfox2098 2 месяца назад
really really cool stuff, im really falling behind with my rust programming haha and this was a great bit of inspiration for me to keep going
@DylanFalconer
@DylanFalconer 2 месяца назад
Keep going - you got this. Something that helps me is to focus on actions I can perform each day/week that get me closer to the outcome I want. I try not to compare myself to other people anymore, just focus on consistency
@danieleccleston7928
@danieleccleston7928 2 месяца назад
I have a long way to go
@DylanFalconer
@DylanFalconer 2 месяца назад
Me too brother. One step at a time
@danieleccleston7928
@danieleccleston7928 2 месяца назад
@@DylanFalconer Thanks, I'll be working through your pong course. I'm sure I'll learn a good amount
@Nezteb
@Nezteb 2 месяца назад
I like your content a lot; if your videos also had accompanying text/screenshots/slides it'd be easier for me to follow. Or you could even just share your screen while you go through docs/code/demos/etc. Just an idea. 🤩
@DylanFalconer
@DylanFalconer 2 месяца назад
Thanks for the feedback! I was thinking some things are getting a bit complex for just hand signals haha I'll see about adding some visuals :)
@Tezla0
@Tezla0 2 месяца назад
Does it have something similar to Zig meta programming?
@DylanFalconer
@DylanFalconer 2 месяца назад
There is a bit of compile time code execution using the "when statement" - I haven't tried it out and can't speak to the full utility of it as I haven't found a use for comptime in my own projects. What are you using comptime for in Zig?
@Tezla0
@Tezla0 2 месяца назад
@@DylanFalconer I use comptime to implement serialization, lookup tables and RTTI, but the latter is not very convenient to use. I hope they implement at least type id in the future, because it requires some hacks to implement at the moment.
@10aded
@10aded 2 месяца назад
I'm building my largest game, from scratch, in my own programming language in Zig, and I agree with everything in this video. Some people use commercial game engines because they come with level editors... but if your game is simple enough, and you're a competent enough programmer, you can just create your own editor. Are there are huge positives: I know exactly how my editor works, and it is minimal since it only does what it needs to do. It also only took 1 month to program. Why spend years "learning" how to make a game in Unity when you can just make your own level editor in a month lol.
@DylanFalconer
@DylanFalconer 2 месяца назад
Yeah, at the time I made this video the general online landscape was "What? Make a game engine? Are you insane? What a waste of time." So I just wanted to provide a counter argument. I still maintain that people who aren't interested in programming should NOT try to make their own engines. Good luck with your game :) Will you release a demo?
@10aded
@10aded 2 месяца назад
@@DylanFalconer Absolutely, but not until after I've announced the game. (Which I intend to do this year, for a possible 2025 release.) It's gonna be big. (At least for a puzzle game.)
@10aded
@10aded 2 месяца назад
Great video, I really like your description of Odin as "modern and minimal". Odin's easily the best-designed programming language I've ever used. Something that didn't make the top 11 in the video that I love about Odin is the quality of the compiler error messages, which I've found to be quite high. When I recently learned the bare-basics of Vulkan, I used Odin to go through the 40-ish hour tutorial, full-well knowing that if I had used the language the tutorial was written in (C++), the tutorial would have taken more than 100 hours.
@DylanFalconer
@DylanFalconer 2 месяца назад
That's a good point. The compiler errors usually tell you exactly what went wrong and how to fix it. It's quite nice.
@KodosUnofficial2-jq5oo
@KodosUnofficial2-jq5oo 2 месяца назад
Also, i can easily read odin code that written by other people. With that, i can know how to use undocumented library by reading the source code.
@DylanFalconer
@DylanFalconer 2 месяца назад
Yeah, that's absolutely a boon! I didn't even think about it, but it's a huge benefit. I often read the standard library without hesitation. Can't say the same for some other languages, unfortunately...
@solitary200
@solitary200 2 месяца назад
Happy to see new uploads, hoping to see many more!
@DylanFalconer
@DylanFalconer 2 месяца назад
Thank you very much :) Indeed there will be
@minibubblegum5108
@minibubblegum5108 2 месяца назад
Reading comments does sound painful.
@DylanFalconer
@DylanFalconer 2 месяца назад
Yeah but I'm going to do it anyway 🤠