Making an infinite world with Falling Sand part 2

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

КОМЕНТАРІ • 75

  • @MaxwellCatAlphonk
    @MaxwellCatAlphonk 6 місяців тому +4

    This makes me feel like a "Welcome back, to the SandPond saga. Let's get started."

  • @thomaswalls4188
    @thomaswalls4188 3 роки тому +19

    I have been waiting so long for this! Like 2 days ago when I subbed.... For real tho, your work is amazing

  • @rantan1618
    @rantan1618 3 роки тому +13

    I remember seeing "games" like this in the early 2000s and being extremely interested in how they made it. I think a lot of other people were also curious how about this works.
    The more info the better!

  • @PixelDough
    @PixelDough 3 роки тому +8

    THANK YOUUUU I’ve been working on a game with a falling sand mechanic and was really struggling to find videos covering the more advanced topics the past few days, and just found this

    • @Winterdev
      @Winterdev  3 роки тому +3

      Oh nice! Hopefully this helped, would love to see the results :)

  • @NeoN-bd3so
    @NeoN-bd3so 3 роки тому +5

    Yo, thanks again for the amazing editing and clean Code! Keep it up :D

  • @marf1610
    @marf1610 3 роки тому +2

    Nice simple description of the dirty rects. And it was cool seeing the process of iterating through the methodologies you used and discovered.

    • @Winterdev
      @Winterdev  3 роки тому +1

      Thanks! That part definitely took the longest because there were so many edge cases

  • @apost7200
    @apost7200 3 роки тому +2

    Really good video.I have been introduced to racing conditions and mutex vars in uni but never connected that it could be used for treading.Keep up the good work!!Also sand is satisfying

    • @Winterdev
      @Winterdev  3 роки тому +1

      Sounds typical lol, some cool theories but no real world examples. Idk what you could of been doing besides threading though, as that's like the main point of mutex/race conditions lol.

    • @apost7200
      @apost7200 3 роки тому +1

      @@WinterdevEvery example was about the hard drive ,printer,ram etc.Never on threading.They taught us at a low level how mutex etc work but not when they should be used.But it was an Operating systems course which was not that focused on coding (Mainly used c).So maybe we will be taught in a later course¿

    • @Winterdev
      @Winterdev  3 роки тому +1

      @@apost7200 Oh that makes sense, I took a similar class, you'll prob end up doing some pthread stuff at some point. Threading unlocks some of the coolest parts of code, but is hard to wrap your head around at first. It's basically like the software version of multiple devices though

  • @fudgeracoon2529
    @fudgeracoon2529 3 роки тому +3

    Finally!

  • @dandymcgee
    @dandymcgee 3 роки тому +3

    The diff animation is interesting.. I'm not sure how useful it is for readability or being able to follow along, but it definitely looks cool and lets you briefly describe the code changes very quickly.

    • @Winterdev
      @Winterdev  3 роки тому

      I'll have to figure out what the best animation is, I think the fade might be a little distracting but it does give me some more time to talk over it. Thanks for the comment!

    • @santitigre
      @santitigre 3 роки тому +1

      I think the fade happens too quickly to follow along, maybe with a background highlight of lines that are 'about to be replaced' ala GitHub's diff could improve readability!
      Love the quality of the videos, keep it up!

    • @Winterdev
      @Winterdev  3 роки тому +1

      @@santitigre oo that's a good idea actually, it would fade a background on the lines to be removed and then fade them out. I'll try that out. Thanks for the comment!

  • @Vextrove
    @Vextrove 3 роки тому +3

    Awesome!
    I challenge you to do it in 3D!
    You could use cubes, or the marching squares algorithm

    • @Winterdev
      @Winterdev  3 роки тому +3

      I’ve been thinking about that haha I think I am going to try for the next project.

  • @drollestprawn
    @drollestprawn 3 роки тому +3

    Thanks for these videos, their really good. I have a suggestion for a 3rd or 4th video. Adding velocity because right now each partical moves one cell per frame so if the frame rate is lower then it will fall slower. By making cells move more than one space per frame based on the velocity cells would fall at a fixed rate and the water would be able to flow faster like in real life. I have a similar simulation as this so I’m wondering how you would do this. Thanks 😀

    • @Winterdev
      @Winterdev  3 роки тому +2

      That's a good idea, I was trying to do something similar but I couldn't figure out how to make water slosh around. The main problem I was having was that if a particle collides then it needs to remove its velocity, so they would fall in weird ways.

    • @drollestprawn
      @drollestprawn 3 роки тому +1

      @@Winterdev Yeah, I would be interested to see how you would implement it. I figured out how to make it move multiple spaces per frame but I still don't have the number of spaces it moves change based on the frame rate.

    • @Winterdev
      @Winterdev  3 роки тому

      You gotta multiply by the frame time and have the velocities be in the hundreds from what I can tell

    • @drollestprawn
      @drollestprawn 3 роки тому +1

      @@Winterdev oh thanks

    • @Winterdev
      @Winterdev  3 роки тому +1

      Ye it’s a little hard to get it perfect but that’s the idea and it looks ok. I’m not sure what the powder toy is doing. I think if you double buffer it instead of doing this list thing I’ve done you can get better looking movement, I’ve been looking into it... Gl with the velocities!

  • @Bonfere
    @Bonfere 3 роки тому +1

    Another Great Video

  • @willd2609
    @willd2609 8 місяців тому

    This is SO cool

  • @Tigrou7777
    @Tigrou7777 2 роки тому +1

    Have you ever considered using compute shaders for sand logic simulation ?

    • @Winterdev
      @Winterdev  2 роки тому

      I did, but didn't have the time to go down that route. I can imagine that the way it would work is instead of looking from the POV of the filled cells, you would look from the POV of the destination and check the 8 surrounding cells. It might be the case that the fps is so high that you don't need more than a 3x3 convolution.

  • @player210
    @player210 3 роки тому +2

    finally!

  • @Temulgeh
    @Temulgeh 3 роки тому +1

    i don't know how hard that would be to implement, but the water seems to be going too slowly compared to the sand?
    maybe do two updates per frame (but that might be bad for the framerate) or have more movement possibilities (but that might be too complex/too big)?

    • @Winterdev
      @Winterdev  3 роки тому +3

      Yeah I was trying to find a way to make it not look like goo, but in these vids I was just focusing on the engine bits. It seems like if you make it check 3 away, then 2, then 1, you get less viscous liquid, but I'm not sure if that's the real solution. i.gyazo.com/3760bbd2b0d41794376463aed0cab5ba.mp4

  • @amishpatel7794
    @amishpatel7794 2 місяці тому

    I'm having trouble adapting the dirty rectangle, 99% of particles move between the chunks (when it changes dirty rectangles to the other chunk's dirty rectangle) however there are a few particles that don't get added the rectangle so it just floats in the air. I don't know where im missing a call to the keepAlive method

  • @arieyorsson3191
    @arieyorsson3191 3 роки тому +1

    How do you not have more views and subs? Amazing video! I hope you make a channel discord, I'd so join

    • @Winterdev
      @Winterdev  3 роки тому

      Thanks! I might make one over the summer

  • @ziggyzoggin
    @ziggyzoggin 3 роки тому +1

    i was wondering how you could make a space game with sand, it being on the ground makes a lot more sense.

    • @Winterdev
      @Winterdev  3 роки тому

      It makes much more sense but the game that I started on fell into a space shooter lol

  • @volpo5046
    @volpo5046 3 роки тому +2

    9:44 happens every time when planning a project hahaha

    • @Winterdev
      @Winterdev  3 роки тому +1

      So many little things popped up that I realized it was all over. Something as simple as rotation is made super complicated by the fixed grid :(

  • @elietheprof5678
    @elietheprof5678 3 роки тому +1

    Are the threads limited to CPU cores (usually 8) or can some of this code run on the GPU for even more power?

    • @Winterdev
      @Winterdev  3 роки тому

      Yes there is prob a way to put it onto the GPU. You’d need to double buffer it but I bet it wouldn’t be too hard/different

  • @zin2341
    @zin2341 3 роки тому +2

    yeeey thanks for not disappearing

    • @Winterdev
      @Winterdev  3 роки тому +1

      May have taken a while but I haven’t disappeared!!

    • @zin2341
      @zin2341 3 роки тому +1

      @@Winterdev :D

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

    how do you handle updating the dirty rect if two particles want to occupy the space but only one gets chosen?

    • @Winterdev
      @Winterdev  8 місяців тому

      its based on the final list of submitted moves

  • @averysumner1369
    @averysumner1369 3 роки тому +1

    Have you ever thought about optimizing this using compute shaders?

    • @Winterdev
      @Winterdev  3 роки тому +1

      Yes but it looked like a lot of work lol. I was thinking that if you used compute shaders then you could basically just render the tiles into the textures for super fast / big sprites as well.

    • @averysumner1369
      @averysumner1369 3 роки тому +1

      @@Winterdev it definitely is, I was able to get the game of life running on a computer shader. But, falling sand, especially with multiple types of cells would be a whole other beast.

    • @Winterdev
      @Winterdev  3 роки тому +1

      @@averysumner1369 idk about shaders to fix the issue of two particles moving to the same space, maybe you could use a 3x3 pass and test from the empty spaces, it would be much more complicated

    • @averysumner1369
      @averysumner1369 3 роки тому

      @@Winterdev yeah, even games like noita where most of the gameplay is falling sand opt for CPU calculations.

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

    So I have a question. Can't you just have a class that handles sand chunks, and just use a vector to contain all chunks and have a function to convert world coordinates to a position in the vector. This might be a bit biased as I am doing the same thing but my world is not infinite.

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

      You could but you would have to reindex the array every time a new chunk is added so you'd end up basically with just a map.

    • @tundera1297
      @tundera1297 2 місяці тому

      @@Winterdev I've done a bunch of stuff, and I implemented dirty rects and chunks. Movement between chunks and the dirty rects work. And while I can simulate more particles the simulation is still pretty slow. I have an 800 x 600 windows. And each sand particle is the size of a pixel. Dirty rects work by each chunk maintaining an update list and containing each particles old position and possible new position(s). I don't really know where I went wrong. Are there any suggestions you can make? Is this just because I haven't multithreaded it, or perhaps something I messed up in the code?

  • @Poly_0000
    @Poly_0000 Рік тому

    A saga perhaps?

  • @joshuamora411
    @joshuamora411 3 роки тому +1

    How to you run the code you have on github

    • @Winterdev
      @Winterdev  3 роки тому +1

      I’ll make some documentation once I’m back at the computer in a couple days. But basically you need to run premake5 on the main folder to gen the build files and then compile the extern libs and then the main solution. I wouldn’t even try tho lol, I’ll make a proper steps list in a few days

    • @joshuamora411
      @joshuamora411 3 роки тому +1

      @@Winterdev thank you so much, gl with all your projects!

    • @Winterdev
      @Winterdev  3 роки тому

      @@joshuamora411 ok I took a stab at making some directions. Let me know if you have any questions! winter.dev/engine/

    • @joshuamora411
      @joshuamora411 3 роки тому

      @@Winterdev Amazing, is there anywhere I can share with the community any experiments/debug/etc Ive done?

  • @tsunamio7750
    @tsunamio7750 2 роки тому +1

    1:15 Maybe is just me but... Watch out? You are mixing Lists and Arrays! Lists are often called that as they are linked, in opposition to arrays, which are not.

    • @Winterdev
      @Winterdev  2 роки тому

      I could see that but they are interchangeable. In Java arrays are called ArrayList, C# has List for everything related to lists and python calls them lists too. I think it's the concept of having a collection of items vs the implementation details, which are up to you

  • @Peach_Lobot0my
    @Peach_Lobot0my 2 роки тому

    i cant figure out how to make a falling sand simulator in luau

  • @yesimwood3094
    @yesimwood3094 3 роки тому +2

    wasup

  • @SomethingExtra
    @SomethingExtra 3 роки тому +1

    yeah I'm making something like this but 3d, really gets laggy if you do that lmao

    • @Winterdev
      @Winterdev  3 роки тому

      I REALLY want to see what that would look like I might explore that in the future

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

    why use a map when you can use a 2d array?

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

      If your world is static a 2d array is better, but a map allows for expansion without a lot of reallocation

  • @oamioxmocliox8082
    @oamioxmocliox8082 Рік тому

    ;)