How I made a world with trillions of gems in C with Raylib

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 106

  • @lingonstudios
    @lingonstudios  11 місяців тому +6

    Help support me and the channel by Wishlisting Moose Miners on Steam: store.steampowered.com/app/2591410/Moose_Miners/?

    • @plasma1492
      @plasma1492 8 місяців тому +1

      please add reset to game demo i finished it in 2 days also should find way to reduce lag when lots of minecarts on screen :)

    • @lingonstudios
      @lingonstudios  8 місяців тому +1

      @@plasma1492 There is an option to reset the progress of the demo in the settings screen from the main menu. What cpu and gpu do you have? I have worked quite a bit on the performance for rendering the carts, but it will stil need decent enough hardware to run well when there are a lot of minecarts with a lot of gems. I will probably add some graphics options in the full game that will help it a bit, until then you can try running the game in a lower resolution that should help a bit

    • @Robert-pl1gd
      @Robert-pl1gd 6 місяців тому

      I there an email or something where we can offer suggestions on improving the game

  • @ernesto_torres
    @ernesto_torres 11 місяців тому +53

    This is a great example of a game that really benefits from a custom game engine. Looking forward to more of your videos

  • @BlueprintProgrammer
    @BlueprintProgrammer 11 місяців тому +40

    Aa a raylib developer I would love if you would talk with ray about adding your custom functions into raylib proper, and adding your optimizations to existing ones. Thank you very much for your impressive work.

    • @lingonstudios
      @lingonstudios  11 місяців тому +18

      I'm not sure if those function would fit with the simplicity that Raylib strives for to keep. But I'll try to find some time at some point to package them together so they can be used as an extension to Raylib for those who want them

    • @linuxrant
      @linuxrant Місяць тому +1

      oh, that sounds like making history, guys. Just don't be silent about this.

  • @Trupen
    @Trupen 26 днів тому +1

    I've played the demo and it was great
    great to hear how it was made!

    • @lingonstudios
      @lingonstudios  25 днів тому

      Oh I recognize you! I watched a lot of your factorio content, it's really entertaining. I'm glad you liked the demo, just let me know if you would like a key to try out the full game sometime.

    • @alexsohn310
      @alexsohn310 14 днів тому

      didnt expect to see you trupen here, funny!

  • @CarlsSimGuides
    @CarlsSimGuides 6 місяців тому +3

    I had a lot of fun with your game. I didn't play optimally at all and it's the first idler where I feel like I'd want to go back and try another save file to see if I could create a better flow. As a dev myself i was constantly thinking of how you must have achieved all of this and I really appreciate the explanation as a result. I knew just drawing all these gems had to be taxing let alone all the moose and their AI. You did a good job explaining just how all that works and I respect you sharing those secrets. You definitely deserve praise for your hard work and making a game I can enjoy for a dozen hours at least for such a low price. Thanks for that. Please make it possible to toggle mine cart lanes and/or wand makers though. it'd be a big improvement for those of us who made mistakes but might not want to start over entirely :)

  • @ghostpeppered4524
    @ghostpeppered4524 10 місяців тому +4

    This is incredible! I can't believe how underappreciated the programming work is here. I must know more about this data-oriented approach!

    • @lingonstudios
      @lingonstudios  10 місяців тому +1

      Thanks! I hope to get some time to do a few more videos about the different parts of it

    • @kulkalkul
      @kulkalkul 3 місяці тому +3

      I wouldn't say first decision is data oriented, I'd say it is rather a trade-off. Altough the second decision about gem colours, extracting static data with low variation, is a data-oriented approach. So, in a nutshell, you organize your data with data access patterns in mind and take recent hardware changes into mind. For example, more than two decades, consumer CPUs have cache; so learning how it works helps for start. For the general idea, you can watch famous Mike Acton talk "CppCon 2014: Data-Oriented Design and C++" for the idea and Andrew Kelley's "Practical Data Oriented Design" for some examples with linear access. There is also Casey Muratori's "Performance Aware Programming" course, which delves into detail and shows how CPUs work, which I think is in line with the "Data-Oriented" philosophy on taking advantage of the hardware you are working on.

  • @GonziHere
    @GonziHere 11 місяців тому +6

    Hey, about the limitation you've mentioned: I did something similar for my minecraft and my way of doing it was to only store the modification. I've asked my procedural function "what's here" and it first checked the handcrafted content and then the procedural algorithm. And the best part was that handplaced content that was the same as the procedural output was simply removed from the save file.
    Like in your case, I'd store only the modified lanes, for them, I'd store what's the first gem in the line (everything before is empty) and last space (everything after is procedural), inbetween, I'd only store where the missing/touched gems are and how touched they are.
    I'm not saying that you should do it, it's pointless for your game, I'm just mentioning that it's exteremely flexible way of storing even big changes without effort.

    • @lingonstudios
      @lingonstudios  11 місяців тому +3

      Yeah I was thinking about a system like that at the start of development. The issue is that will still result in a lot of data needed to be stored if you start mining a substantial part of the map and mine horizontally at multiple places. Still of course nowhere near the data needed to store everything as a unique gem instance, but would end up being much more than what is needed with this simpler version.
      The solution you describe works really well in a game like minecraft where you have a really big world but you are only loading a limited area around the player at a time. Then you only need to worry about the data fitting on disk. In my game the whole world is simulated all the time, even if you don't see the miners they are still mining. So I am much more limited in how much of the data I can just leave on disk and pretty much need to have all in ram. It is also really beneficial to keep the data describing the game as small as possible so it better fits in the cpu cache when working on it, since having to grab the data from ram is quite expensive

  • @Razvvannn
    @Razvvannn 7 місяців тому +4

    Very nice video, liked and subscribed!

  • @l_t_m_f
    @l_t_m_f 11 місяців тому +1

    love C, such easy to grasp the code in one glance

  • @ahmedsat4780
    @ahmedsat4780 11 місяців тому +1

    man, I really love your videos

  • @AGamerPS3
    @AGamerPS3 4 місяці тому

    The game is fun, a few more updates such as having smarter AI so the moose don't all go to the same gem only to move to the next one after realizing it's occupied, more camera movement just so you can see the full length, and a more unique upgrades for more unique mining.

  • @ThePotOwl
    @ThePotOwl 6 місяців тому

    i cant stop moose-ing i love this game. i need to be able to zoom out more out and a button to select all moose

  • @samdavepollard
    @samdavepollard Місяць тому

    very impressive; great work

  • @linuxrant
    @linuxrant Місяць тому

    I did not understand 90% of what you said. but I believe someday I will. Anyway the result is impressive, you have done something not many games ever done. Maybe none.

  • @nowheremap
    @nowheremap 25 днів тому

    if you wanted to allow horizontal mining, a hybrid approach might hold up: something like saving how many gems there are in a column without interruptions, then the length of the first interruption, and so on
    at this point it becomes a cryptography problem and optimization depends on how predictable gem arrangements will end up being

  • @fmilioni
    @fmilioni 11 місяців тому +2

    Your game looks amazing. 🎉

  • @SystemsDevel
    @SystemsDevel 8 місяців тому +3

    Hello, amazing work and optimizations, really a lot to learn from this video. Looking forward to playing the final game!
    I have two questions:
    1) Have you considered adding a minimap?
    2) Have you used any Assembly mixed with the C code for this game?

    • @lingonstudios
      @lingonstudios  8 місяців тому +2

      Thanks!
      1. No haven't thought about it actually. But now that I think about it, the world is too large to display in a minimap. So it would have to just cover a part of the world and then it does not feel that useful anymore since you can zoom out the game quite far already. What might work would be something like the zoom in Supreme commander where the whole screen basically turns into a minimap when you zoom out far enough. But that is not something that would be high on the priority list atm.
      2. There is no raw assembly in this project, but I do use intrinsics in a few areas, for example to speed up matrix multiplications. Intrsinsics are basically assembly since the intrinsic functions do directly correspond to assembly instructions.

  • @jogos_all
    @jogos_all Місяць тому

    mano c e brabo irmao, so sucesso pra voce mano

  • @Robert-pl1gd
    @Robert-pl1gd 10 місяців тому

    I got soo hooked on the demo that I cleared the whole board. Can't wait for the full release. I wish I could start the demo over again but unfortunately even uninstall won't fix that. Guess I have to wait

    • @lingonstudios
      @lingonstudios  10 місяців тому

      There is a button in the settings screen from the main menu to reset the game

  • @TECHNOBOG
    @TECHNOBOG 10 місяців тому

    Your work is inspiring.
    It would look cool if the trail of carts had an increasing offset in its motion to simulate inertia. Think snake instead of the solid line you have right now.
    You should also have avoidance (not necessarily collision) so objects do not pass through each other.

    • @lingonstudios
      @lingonstudios  10 місяців тому

      Yeah I have plans on adding some physics to the carts so they won't be a rigid line, I just haven't prioritized that yet since in the demo there is only one cart anyways. I would like to have avoidance as well, but I'm not sure it is going to be worth first the development effort and secondly the cpu time. I'll have to see how much time the rest of the things planned takes first

  • @blueboy3990
    @blueboy3990 11 місяців тому +1

    RCE played your game!

  • @gwentarinokripperinolkjdsf683
    @gwentarinokripperinolkjdsf683 3 місяці тому

    if you wanted to allow mining horizontally, I think instead of storing the number of gems mined, I would use run length encoding along the column, yeah you'd have to store that in some sort of dynamic container but it should work very well

    • @lingonstudios
      @lingonstudios  3 місяці тому

      The data needed to allow mining horizontally would be so much larger than it is now that it would be way too much after you have mined very deep. It would also complicate the pathfinding logic and mining logic so that part of the system would take much longer to compute. So it really would not be feasible without limiting the world size much more than it is currently.
      You need to keep in mind that even though only the parts visible on the screen is rendered the whole world is active at the same time. So all the data for the world is kept in ram all the time.
      While it would be possible to only load the data that is needed around where there are currently moose, it might still become an issue since with a current max of 32k moose they could spread out quite a lot and force a lot of areas to be loaded still.

  • @ryonagana
    @ryonagana 6 місяців тому

    i love raylib. it's like DOS BGI but modern

  • @pr0r1der
    @pr0r1der 7 місяців тому

    Looks great! Inspired me to finally install raylib and give it a go after not really feeling godot and giving up on blueprints only approach in UE! :D A bit of a noob question - how do you define a map so big? Does it load in chunks as you move the mouse, or are there some fancy optimizations like this. I am thinking about having a big map with all kinds of BOIDS doing their own thing in different places of the map and was curious about your approach.

    • @lingonstudios
      @lingonstudios  7 місяців тому +3

      The data for the map is explained in the video and then when it comes to rendering I just calculate what part of the map is visible on the screen and get the needed data to render that. Basically just view frustum culling. Same goes for the moose and the base, I just render what is actually visible to the camera. However I do process everything regardless if it is visible or not, so the moose and the part of the base that is not visible operates just the same way as the ones that are currently visible. Otherwise the game would not work. So it is only the rendering work that can be lowered based on what is visible. To handle a large base and many moose it is just written with decently optimized data oriented code and it is multithreaded running at 30 ticks per second

  • @Benox-Dev
    @Benox-Dev 10 годин тому

    Nice video !! Pls I don't know what to choose raylib or godot for my 2d Metroidadvenia like game I don't know what to choose. Can you help me

  • @steveskeletonneii6336
    @steveskeletonneii6336 11 місяців тому

    this is amazing wow

  • @Tottelbe
    @Tottelbe 11 місяців тому

    Very cool stuff! And definitely loving the data-oriented approach.
    Do you know if my progress in the demo can carry over to the full game?

    • @lingonstudios
      @lingonstudios  11 місяців тому

      Thanks! The plan is to carry over the progress from the demo to the full game. But I am planning a rather large addition to the full game that might make it tricky so can't promise 100 %, but I will do my best to design the new stuff in a way that allows the demo progress to carry over.

  • @Mitch_Crane
    @Mitch_Crane 3 місяці тому

    Why do you need to store rocksRemaining if you store rocksCleared? Is rocksRemaining not just maxRocks - rocksCleared?
    Thank you

    • @lingonstudios
      @lingonstudios  3 місяці тому

      Each gem on the map holds a certain number of smaller gems that can be mined from it (the ones that appear in the moose's carts) The rocksRemaining is storing how many of these are left for the exposed gem in each column

  • @gryasl6231
    @gryasl6231 11 місяців тому +1

    Sidestep Legends wasn't suitable to me but I'm waiting very excitedly for this game. But I have 2 questions
    1- could you make a video about raylib+shaders? would be greatly appreciated if it can be much more like a tutorial.
    2- I got so many bug on demo of Moose Miners, is there anywhere to submit these videos/screenshots? or is it even important right now, because its already a demo and ofc it will be have bugs?

    • @lingonstudios
      @lingonstudios  11 місяців тому

      I'm glad you're excited for the game!
      1. I don't think there is much gain from this since there are a lot of great shader videos on youtube already and using shaders in Raylib is no different than using shaders in pure OpenGL
      2. I'm happy to take bug reports for the demo. The best way is to send an email to support@lingonstudios.com and if it is something that is actively happening in your save file please include the save file as an attachment (you probably need to zip it so it fits in the email). And any pictures or videos of it would be helpful as well

  • @Mitch_Crane
    @Mitch_Crane 3 місяці тому

    How are all active miners stored? Is there a maximum number of miners I can have?
    Thank you for this tremendous video

    • @lingonstudios
      @lingonstudios  3 місяці тому

      Yeah there is a max of 32768 miners. They are stored in a bunch of arrays for the different data that each miner needs

  • @CYXXYC
    @CYXXYC 7 місяців тому

    0:51 the virtual functions bit is probably the only questionable, maybe premature optimization also (when its actual premature optimization; profiling is much better though)

  • @anzhel3268
    @anzhel3268 11 місяців тому +6

    finally a based programmer on youtube 🥰
    let's show those pOOPheads that we are not just control freaks!!
    love your content

  • @empireempire3545
    @empireempire3545 11 місяців тому

    Would you consider open sourcing your custom Raylib functions? I love them

    • @lingonstudios
      @lingonstudios  11 місяців тому +1

      Yeah sure, I'll try to find som time to do that at some point

  • @sevvalpamuk1505
    @sevvalpamuk1505 6 місяців тому

    Hello, I am trying to make Angry Bird in C language with raylib, but I had difficulty in making the sticks fall over in relation to each other and kill the pig. What should I do for this? Can you help me? This is my project assignment. 🥺

  • @liamcarter1322
    @liamcarter1322 9 місяців тому

    I LOVE how this game looks but unfortunately I can’t get it because I don’t have a pc… for now but if I ever get a PC this is the first game I get :)

  • @NNM42
    @NNM42 6 місяців тому

    more devlogs

    • @lingonstudios
      @lingonstudios  6 місяців тому

      Yeah I hope to get some time for more devlogs at some point. Currently it is very hectic with getting out updates for the game

    • @NNM42
      @NNM42 6 місяців тому

      ​ @lingonstudios i'm will wait and logs and updates. Now need give last 3rd achieves on 10k.

  • @TheBeardedAtheist
    @TheBeardedAtheist 11 місяців тому

    I want to play this so bad

    • @lingonstudios
      @lingonstudios  11 місяців тому

      You can try the demo on Steam if you haven't already!

  • @jurusco
    @jurusco 5 місяців тому

    Let me ask you a weird question, do you think this kind of optimization would be possible using like just blueprints in unreal engine, or for this kind of optimization it must be done in code.
    Sorry if this is a dumb question i'm not a programmer.

    • @lingonstudios
      @lingonstudios  5 місяців тому

      I don't think a visual scripting language like unreal blueprints would be able to achieve this. Blueprints are more suitable for setting up gameplay code for more traditional games where you already have components that handle the more expensive logic. But since the actual gameplay code of a game like this is quite simple compared to the simulation and by necessity quite heavily integrated into the simulation code it would not really make much sense to try to make it using blueprints. Maybe setting up the upgrades and UI stuff with something like blueprints would work after you have written the heavy simulation systems and gameplay in c++.
      In general if you want to get away with using only blueprints in Unreal, I think you'd need to make a first person game, preferably a first person shooter. Since then Unreal will have a lot of things ready to use for you to call from blueprints.

  • @paraxodondev
    @paraxodondev 11 місяців тому

    is it possible to make the carts that follow the moose be more dynamic? i wonder if the optimization makes this impossible.
    Your work is incredible, i hope to become an engineer such as you to be able to come up with such complex optimization techniques (when i say complex i mean for me).

    • @lingonstudios
      @lingonstudios  11 місяців тому

      Thanks, I'm glad I can be an inspiration. Yeah I will make the carts move behind each other with some physics so they are not all one rigid train. It would be quite the optimization task to do that for all 32k miners where each can have maybe 5-10 carts (have not decided on the actual max number of carts yet). But fortunately the movement of the carts have no impact on the gameplay it will only be a visual one so I only have to calculate the physics of the visible carts so that should be doable.

  • @noobandfriends2420
    @noobandfriends2420 9 місяців тому

    This explains why the moose cannot mine adjacent gems.

  • @skwayesahmed5818
    @skwayesahmed5818 6 місяців тому

    amazing game
    thanks

  • @michaeloconnell145
    @michaeloconnell145 7 місяців тому

    How do you handle animations in Raylib, do you use iqm/gltf? Or did you write your own shader using your own model loader?

    • @lingonstudios
      @lingonstudios  7 місяців тому +1

      I use the iqm format, but I have written my own code to handle the animation on the GPU by baking the animation data as a texture

    • @michaeloconnell145
      @michaeloconnell145 7 місяців тому

      That's so cool! So each pose or boneTransform is performed from a lookup similar to 2d animations with sprite sheets vs passing a boneTransform uniform for every mesh per evaluated frame?

    • @lingonstudios
      @lingonstudios  7 місяців тому +1

      @@michaeloconnell145 Yeah sort of, but the pixels in the texture holds the data for the transforms for each frame. So if you draw the texture to the screen it would just be a bunch of seemingly random colors. It is a very common technique, if you search gpu skinning you will find a bunch of explanations and tutorials about it

    • @michaeloconnell145
      @michaeloconnell145 7 місяців тому

      ​@@lingonstudios Thank you!! Also congrats on Moose Miners it is insanely fun can't wait for the full release!

  • @o_glethorpe
    @o_glethorpe Місяць тому

    they should have made rimworld this way

  • @jeromeugray
    @jeromeugray 11 місяців тому

    Hello, i m sorry for asking for this under this video, but when you made a game in assembly, how did you managed to draw pixels on screen ? because i would like to make a 3D game in C and using assembly, to make it a bit faster and to learn . Thank you.

    • @lingonstudios
      @lingonstudios  11 місяців тому

      I use directX11 in my assembly projects. You can link any C api to assembly code really. But if you are going to use C and assembly you might as well communicate with DirectX or whatever graphics API you choose through C and use assembly for the most performance critical logic parts of the game. I have a video on the channel where I show how I setup DirectX11 with assembly if you are interested in that

    • @jeromeugray
      @jeromeugray 10 місяців тому

      thank you very much@@lingonstudios

  • @madboxtv6853
    @madboxtv6853 11 місяців тому

    Do you use an ECS lib like FLECS or Entt ? Cuz i want to try to use Flecs but i think my programming skill are to low to implement this and use this. I saddly need vidz tutorial (youtube or udemy) for going forward. But i will try at least and spend some hundres hrs on it and see where i can go.

    • @lingonstudios
      @lingonstudios  11 місяців тому +2

      Nope I don't use ECS so no library like that is needed. I don't think ECS is that useful really if you are writing your own "engine" for your game. It makes more sense in a general engine like Unity, but if you are not using anything prebuilt like that ECS is not helping much really and is mostly just going to be in the way. Just thinking data-oriented and keeping the architecture of the game simple and straight forward will get things done both quicker code wise and usually with better performance in the end as you can make more specialised solution to the problems. I would suggest to just look at the problems you need to solve for your game as a transformation of data since that is really what all computer problems boils down to in the end. And really think about what data is actually needed and try to find the simplest and smallest form of it to solve the problem.

    • @madboxtv6853
      @madboxtv6853 11 місяців тому

      thx for this light. I was thinking that data oriented is automaticly ECS but seems i was wrong. Maybe i was induced buy the Unity Dot stack hipe. But i will make some research and read more about DO @@lingonstudios

  • @noobandfriends2420
    @noobandfriends2420 9 місяців тому

    People have cleared all of the gems in the Demo in just over an hour. Whatever you think, people will clear all 64 trillion gems in a couple hours once the full game releases.

    • @lingonstudios
      @lingonstudios  9 місяців тому +2

      I think those scores are done by using memory editors to cheat or something similar, but it does not really matter since there is quite the difference between the about 400 thousand gems in the demo and 64 trillion in the full version. Even if you had a moose that mines 10 gems per second, which is much faster than what the current upgrades in the game can allow, it would still take over 6 years for that moose to reach the end and that is if it did never have to turn around to leave the gems. And that is just for one column. Even just moving the camera to the end would take over 9 days of moving the camera with max zoom and increased camera speed button pressed.
      The good thing about it is that there is room for some crazy upgrades in the game to allow the moose to come a bit closer to the 10 gems per second I used in the example

  • @stank_it8114
    @stank_it8114 11 місяців тому

    Have you considered streaming? People might find it pretty interesting. Also if you cut the vlogs in parts it’s “free” YT videos ready to go.

    • @lingonstudios
      @lingonstudios  11 місяців тому

      Yeah I have though about it. I did do a stream explaining the code of my previous game Sidestep Legends, there is a vod of it on the channel. For more daily streams, maybe I'll try it at some point, I just have to get used to the idea of people watching me work live first and I think it might reduce the productivity for me quite a bit so we'll see if I find the time and courage to try it out sometime

  • @dryoldcrabman6890
    @dryoldcrabman6890 10 місяців тому

    no git hub!? :(

  • @azhr9266
    @azhr9266 10 місяців тому

    When is the early access i have mined everything so far 😂😂😂
    I am ready to buy the game.

    • @lingonstudios
      @lingonstudios  10 місяців тому +1

      There won't be an early access for the game, but the full game will come out sometime in Q2 this year

    • @azhr9266
      @azhr9266 10 місяців тому

      @@lingonstudios so there is no way to play the game till then :L
      sad so fun tho

  • @derfiete111
    @derfiete111 10 місяців тому

    will the full game cost?

    • @lingonstudios
      @lingonstudios  10 місяців тому

      Yeah, the full game will be a paid game

    • @derfiete111
      @derfiete111 10 місяців тому

      do you already know the price@@lingonstudios

    • @lingonstudios
      @lingonstudios  10 місяців тому +1

      @@derfiete111 No, I haven't decided on the price yet. I will probably announce it together with the final release date when that is decided

  • @MHGames03
    @MHGames03 5 місяців тому

    Has anyone mined the whole map, is it even possible xD I am only 2k depth at the minute

    • @lingonstudios
      @lingonstudios  5 місяців тому

      It is very much possible at the current release, and I would guess that there are probably at least someone that has done it already based on how far some of the saves I've gotten from bug reports have been. But that is because the current depth limit is 4800 right now as I there is not any interesting content after that limit as of now. After a few content updates where I extend the depth limit it should be much harder clearing the map or even reaching the max depth

    • @MHGames03
      @MHGames03 5 місяців тому

      @@lingonstudios How wide is the map?

    • @lingonstudios
      @lingonstudios  5 місяців тому +1

      @@MHGames03 32768 columns wide

    • @MHGames03
      @MHGames03 5 місяців тому

      @@lingonstudios a long way to go then haha

  • @chrisflory1268
    @chrisflory1268 10 місяців тому

    he spelled color wrong

    • @chrisflory1268
      @chrisflory1268 10 місяців тому

      colour

    • @lionzzz
      @lionzzz 10 місяців тому

      ​@@chrisflory1268same thing you can write both ways

    • @lingonstudios
      @lingonstudios  10 місяців тому

      Found the American ;)

  • @StitchesForScars
    @StitchesForScars 11 місяців тому

    🏳️‍⚧️ trans flag spotted ❤