- Видео 52
- Просмотров 557 832
Dylan Falconer
Австралия
Добавлен 30 сен 2018
The Artisanal Programmer.
Building game programming resources.
Videos about how to improve your game programming skills.
Business: dylan@programvideogames.com
Building game programming resources.
Videos about how to improve your game programming skills.
Business: dylan@programvideogames.com
Grouped Lifetime Thinking
Learn game programming: programvideogames.com/free
Join the discord: discord.gg/jDm8uCPYwD
Join the discord: discord.gg/jDm8uCPYwD
Просмотров: 2 688
Видео
LDtk Level Designer's Tool Kit Crash Course
Просмотров 64014 дней назад
Learn game programming: programvideogames.com/free Join the discord: discord.gg/jDm8uCPYwD
ECS Alternatives
Просмотров 4,2 тыс.21 день назад
Learn game programming: programvideogames.com/free Join the discord: discord.gg/jDm8uCPYwD
10 Raylib examples to activate your almonds
Просмотров 1,2 тыс.Месяц назад
Learn game programming: programvideogames.com Join the discord: discord.gg/jDm8uCPYwD
11 Reasons to Program using Odin in 12 Minutes
Просмотров 6 тыс.3 месяца назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) X: x.com/falconerd Odin: odin-lang.org Raylib: raylib.com 00:00 Intro 00:25 Header Files 01:03 Math Types (Vectors, Matrices, etc) 01:55 Ambiguous Types, Integer Promotion 03:33 Memory Allocators 04:34 Multiple Return Values 05:35 Slices and Dynamic Arrays 05:53 Strings 06:19 Context 08:10 Untyped Types 09:04 Co...
5 Things Every Game Programmer Should Know
Просмотров 7 тыс.3 месяца назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) X: x.com/falconerd Newsletter: bytesbeneath.com Odin: odin-lang.org Raylib: raylib.com Liberal was totally the wrong word, you get what I mean.. 0:00 Intro 0:33 Hot Swapping of game code 1:47 Drawing Shapes / General Rendering 2:25 Linear Algebra / Learning math for games 6:48 Memory Management 10:17 Debugging 1...
Dynamic Arrays in C
Просмотров 69 тыс.8 месяцев назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Sorry about the nose-whistle. I'll have to wear one of those nose holder-opener-things next time I record. Tools used for video: Slides/Animations: animotion.pages.dev Editing: github.com/WyattBlue/auto-editor Shotcut Audacity Canva
Unity Game Ended Themselves - A different take
Просмотров 4,4 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd #unity #unity3d #godot #gamedev #gamedevelopment #programming
Weapon System | C Game + Engine From Scratch 18
Просмотров 6 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd
Enraged Enemies | C Game + Engine From Scratch 17
Просмотров 2,3 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check...
Spawning Enemies | C Game + Engine From Scratch 16
Просмотров 2 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check...
How NOT to Develop a Game (A Gamedev Story)
Просмотров 3,8 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Apparently everyone (every indie gamedev, anyway) is making their "Dream Game". It's just marketing! Though, I do this game will be very cool and I have been thinking about it for ages. #gamedev #rust #devlog #zig #gameengineprogramming #rustl...
Level Setup | C Game + Engine From Scratch 15
Просмотров 3,8 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check...
Playing Audio | C Game + Engine From Scratch 14
Просмотров 3,1 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd Code used in recording: github.com/Falconerd/engine-from-scratch Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/ Background pixel art for this series is Kings and Pigs by Pixel Frog. Check...
"Make a Game not an Engine" (Just use Unity/Unreal/Godot bro)
Просмотров 20 тыс.Год назад
Learn game programming: programvideogames.com/free (free course using Odin Raylib!) Programming newsletter: dylanfalconer.com/articles X: x.com/falconerd "Make games, not engines" is often misunderstood to mean that one should not create games from scratch but rather use third party engines like Unity, Unreal, or Godot. I have a little rant about how building specific engines for games is the w...
Trigger Events | C Game + Engine From Scratch 13
Просмотров 2,4 тыс.Год назад
Trigger Events | C Game Engine From Scratch 13
Animated Sprites | C Game + Engine From Scratch 12
Просмотров 3,7 тыс.Год назад
Animated Sprites | C Game Engine From Scratch 12
I Made an Image Loader in 15 Lines for My Game Engine
Просмотров 4,4 тыс.2 года назад
I Made an Image Loader in 15 Lines for My Game Engine
Batch Rendering Sprite Sheets | C Game + Engine From Scratch 11
Просмотров 8 тыс.2 года назад
Batch Rendering Sprite Sheets | C Game Engine From Scratch 11
Entities and Collision Layers | C Game + Engine From Scratch 10
Просмотров 6 тыс.2 года назад
Entities and Collision Layers | C Game Engine From Scratch 10
2D Collision Response | C Game + Engine From Scratch 09
Просмотров 12 тыс.2 года назад
2D Collision Response | C Game Engine From Scratch 09
Swept AABB Collision Detection | C Game + Engine From Scratch 08
Просмотров 14 тыс.2 года назад
Swept AABB Collision Detection | C Game Engine From Scratch 08
AABB vs AABB Collision Detection | C Game + Engine From Scratch 07
Просмотров 8 тыс.2 года назад
AABB vs AABB Collision Detection | C Game Engine From Scratch 07
Point vs AABB Collision Detection | C Game + Engine From Scratch 06
Просмотров 7 тыс.2 года назад
Point vs AABB Collision Detection | C Game Engine From Scratch 06
Can Copilot build a library in C? Well...
Просмотров 3,8 тыс.2 года назад
Can Copilot build a library in C? Well...
Physics: Integration | C Game + Engine From Scratch 05
Просмотров 11 тыс.2 года назад
Physics: Integration | C Game Engine From Scratch 05
Input and Config | C Game + Engine From Scratch 04
Просмотров 12 тыс.2 года назад
Input and Config | C Game Engine From Scratch 04
Shaders and Reading Files | C Game + Engine From Scratch 03
Просмотров 14 тыс.2 года назад
Shaders and Reading Files | C Game Engine From Scratch 03
Rendering a Quad | C Game + Engine From Scratch 02
Просмотров 30 тыс.2 года назад
Rendering a Quad | C Game Engine From Scratch 02
How to make a GAME ENGINE | SDL2 Setup and Window | C Game + Engine From Scratch 01
Просмотров 117 тыс.2 года назад
How to make a GAME ENGINE | SDL2 Setup and Window | C Game Engine From Scratch 01
i got stuck for days on it, glad i found your channel, thanks for the help
Just came across your channel, I hope you do more unity videos!
Very useful tutorial! Thank you
when i do the "build && mygame" it says 'CL' is not recognized as an internal or external command, operable program or batch file. Have any idea why?
0:00 General Kenobi
69420
What is this language?
Odin
Recently, I was just exploring LDtk for my mini-training-game on Odin + Raylib, wondering "Well, I need to learn this stuff" and then I have noticed your video. Is this magic?
The universe provides
I know this is a toy example, but can't appending a node potentially cause all of the pointers to be invalidated if the dynamic array needs to allocate a bigger chunk of memory?
Yes, unless Odin does something truly wild(!) behind the scenes like mmap a terabyte of virtual memory for every [dynamic] array or something. Even worse if the video author themselves didn't realize -- my guess is the author is mostly familiar with garbage collected environments, isn't used to working with pointers, and just want to encourage memory pooling or arena allocation in general and picked an unfortunate way to show it. Instead of returning pointers, one way to solve it would be to just return opaque IDs or something like that (indices into the array, for example) that act like Node pointers -- if the language provides the option to overload "dereferencing" (like in C++/Nim/Rust/etc., I don't know if Odin can do this).
@@frankhestvik9859 I imagine the video maker is very familiar with manual memory environments, but mapped an example that used an arena or bump allocator onto a dynamic array for simplicity of explanation.
Yes, in that case, you can use ids rather than pointers, or make sure not to keep pointers across calls that may realloc, or use a larger preallocated pool, etc
This also explains why Rust's philosophy is not so great since it is focused on managing individual lifetimes.
This seems nonsensical or a misunderstanding. The "individual" in "individual lifetimes" that Rust focuses on is a completely different concept than the "individual malloc()/free() calls can cause fragmentation"; that's like conflating the size of a for loop in the source with the number of iterations during run-time. In practice it might actually be the opposite: Rust's type system is such a pedantic pain in the ass that people end up "giving up" on their (usually bad) linked list/heap-node strategies and instead just go back to using a vector/ECS/data-oriented approach, e.g. backed by vector storage or an arena/pool allocator, which tend to be much simpler to do in Rust -- and which is exactly what this video seemingly would argue for... I mean this is why I don't like Rust either, but to say it doesn't encourage data-oriented design seems wrong. The main problem you would have in Rust with this code tho is that it would (correctly) tell you that what you're doing is bullshit because you're returning pointers into a seemingly dynamically allocated array that may move around on the heap (unless Odin does something truly wild like map every dynamic array to its own terabyte of virtual memory).
i have been playing with arena allocators in C for a month now, i even built some data structures on top of them like "vectors" but i am starting to feel like these types of allocators are mostly powerful for game development and not so much systems programming (which is what i mainly do) i say this because i only hear game developers talking about this, and from my little experience im not entirely sold on them right now, maybe i'm just using them badly but i feel like there is some mental overhead and rewriting with this paradigm
It's interesting that you say that because I feel the exact opposite way Once I started thinking in groups, it became much easier to program What do you usually do in systems programming?
@@DylanFalconer i'm a student taking a class on low level programming in C in which we are asked to frequently write console applications for linux/unix systems, i just came back to this video because today i received an assignment in which grouped lifetime thinking is probably the best way to solve my problem efficiently. so i guess i was totally wrong because i actually did exactly what you described in your video, we had to implement a kind of stack that rotates and in which you had to pop and push elements sometimes. i used a memory pool with a free list to keep track of which elements were popped so i can reuse their slots and it worked wonderfully!
isn't what you showed basically a pool allocator? and what's the point of using a linked list when using vectors in the background anyways? (I'm just curious)
Maybe educational purposes, Idk.
You still keep the properties of why you want a linked list. It allows you to add and remove items faster, because you don't need to moving memory around. Arrays/Vector/dynamic arrays are just blocks of memory.
I am more of an array person myself, you often do not need to store pointers. But grouped lifetime thinking can also be applied to tree like structures (and if you are weird you can see a link list as a tree where every node only has at most one child). Linked lists have some advantages over array,s especially in the functional programming realm where they are a persistent data structure.
Yeah it is basically a pool allocator The linked list example is just as an example - because that's something we learn very early and it's usually the individually allocated elements way That said, you can still back a linked list with a pool (probably different to this one so you don't get reallocations) and get decent cache locality while maintaining characteristics you want from the list (->next, ->prev) Why you'd want that just depends on what you are working on
Same, in practice I usually use arrays for most things unless there's some good reason not to
Also, I like the fact that we don't need a build system such as cmake.
Absolutely
Cache coherence is king, also neat to use linear/pool allocators whenever possible. I am somewhat fond of realizing I can do that in modern C++ anyways, while avoiding most of the oop nonesense.
Also neat to sometimes leverage globals, const or not, for static storage. And stack too.
Somehow I also became a huge fan of templates, something I once sought to destroy.
It is really good for performance and I find it to be much easier to reason about
you might be the only newsletter i subscribed to that i actually read. Amazing articles and video explanations
That means a lot! Thank you
1:60 oh that's a new feature! very useful too.
Hey Diego 👋
Seems pretty cool, will try it out
Yeah, it's quite nice!
glad.obj : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64' does anyone know how to fix?
Even if you don't use an ECS, it is still probably a good idea to follow "composition over inheritance" as a design rule. That gives most of the non performance related benefits of ECS without ECS. ECS is more or less just a specific optimization you can choose to do if you follow that design rule. If it later turns out you have performance problems, you can pretty easily transition to an ECS (or directly perform the "array of struct" -> "struct of array" transformation yourself)
odin mentioned!!! lets go
I infinitely prefer calling a dynamic array - "ArrayList" or maybe just "List", as it should be the case
I dont use header files but just include/use .c files
Could you make the code a bit bigger in next videos? It's hard to read on mobile screens.
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.
Am i the only one who thought this was about Amazon ecs?😅 Great video either way. Always nice to learn more about game dev👍.
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
Great video, what editor theme is that?
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
Spot on explanation, I would love to see more of those. Great channel btw!
Nice video, Dylan!
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.
Brilliant video!
Thanks, Bill :)
Great video!
Thanks!
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..
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
(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.
@@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)
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.
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
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) { //... } }
potentially enum EntityId : int {} don't recall if it works well in plain C though
You don’t even need to do this typedef int entity;
@@snesmocha no, that's still an int, i.e. weak type. compiler won't help
wish typedef covered this case
@@snesmocha That's just an alias for an int. A struct is a complex type, and the type checking will work.
Very clear video thank you. The examples make it easy to follow. Maybe the code samples could be larger for us mobile watchers though 😅
Thank you! I'll make sure they are larger next time
General Programming!
We need Loki programming language! With as many tricks and "what you see is not what it is" moments! Just for lulz ;-)
in the normalize example why is deltaframetime added instead of just speed? thanks
I really like all variables having zero types
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.
I'm laughing at the font bit. "No"
You've left the C gang i guess 😔
Yeah, it was tough I won't lie! C will always have a special place in my heart
@@DylanFalconer It was hard for me too. But slices, custom allocators, "batteries included", defer, array programming, context etc. were too good to not swich.
My almonds are fully active learning about raylib shaders now...
My almond got activated, now I'm learning about shaders in raylib...
Giving me ideas of using simple shapes with a bunch of post processing
Great showcase! Definitely activated my almonds
Glad you enjoyed!
What are the pros and cons of using Odin+raylib vs. Odin+SDL2?
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
Raylib also provides functions for 3D graphics (model loading, animation, rendering) that SDL does not.
Raylib have built-in camera and collision system, in SDL you should implement that from scratch.
Good question, I think everyone else already covered it so thanks guys!
CloseWindow function should be called before ending the program
No, when the program exits, the OS itself destroys the window and clears it's memory, which is more efficient than doing it yourself
@@LeoAzul-xo7fy won't there be a memory leak?
@@CoolestPossibleName The OS clears the memory, as stated
@ 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
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 :(