{"author_link":"\/users\/pierre-baudoin","author_name":"Pierre Baudoin","author_uid":"pierre-baudoin","comments":[],"epoch":1665347781,"event":"LD51","format":"md","ldjam_node_id":309780,"likes":7,"metadata":{"p_key":"169184","p_author":"Pierre Baudoin","p_authorkey":"1201827","p_urlkey":"396947","p_title":"Diving into WOOLLY FIRE's grid system","p_cat":"LDJam ","p_event":"LD51","p_time":"1665347781","p_likes":"7","p_comments":"0","p_status":"WAYBACK","us_key":"1201827","us_name":"Pierre Baudoin","us_username":"pierre-baudoin","event_start":"1664496000","event_key":"114","event_name":"Ludum Dare 51"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD51","removed_author":false},"_superparent":296586,"_trust":1,"author":201827,"body":"Hi guys, Pierre here.\n\nI wanted to talk about the way i developped our grid generation tool during the Jam 51. Nothing revolutionary, but I\u2019m sure it will be interesting for some.\nBut first of all, I need to pitch the game since most of you didn\u2019t test it :\n\nA fire has start in the countryside and your job is to manage the firefighters response. EVERY TEN SECONDS, the fire will grow and try to spread through the grid. Fill your trucks and send them on the firefront. Try to understand how the cellular automaton works\n\n(Play and rate us here: https:\/\/ldjam.com\/events\/ludum-dare\/51\/fires-away)\n\nOK, so let\u2019s start with our grid system with a bit of oubviousness\nA grid is a group of connected cells. Those can be the same (like in chess) and be seen as physical container that can be fill by a pawn, an agent or a unit (or whatever, name it as you wish). But it\u2019s not the case in our game, every single cell has in reality a \u2018cell type\u2019 that influence the behavior of fire in it. For instance, a wheat cell burn faster than a forest cell, and water cell just can\u2019t.\n\nIn the curent game, there are 5 different cell type\u00a0: Forest, Plain, Village, Water and Wheat.\nEach of these have an interest in the game. Plain is kind of the base type, Forest and Wheat are reskin with diferent fire propagation values that make fire slow or speed up. Water refill the tanks in  the next cells and villages are a losing condition. I won\u2019t dive into details because it already a long post and I didn\u2019t even start to talk about texture.\n\nSo\u00a0! We want to have a grid containing cells but each of them is one of the 5 types we just saw. We could just create 5 prefabs and smile to the level designer and say\u00a0: \u00ab\u00a0Your turn to place the 256 prefabs\u00a0! Good luck\u00a0! \u2026 And do it well otherwise you\u2019ll have to iterate :D\u00a0\u00bb. But we\u2019re not this kind of person, obviously not. We actualy are the rock of the team, the one without nothing could be done, the all mighty programmer and it is time to be merciful. \n\nIn order to ease their job, I personnaly thought about texture almost instantly. What are texture if it\u2019s not a grid of pixel having each a diferent type (i mean color) ? I paired a cellType with a color, made my very best piece of art in microsoft paint and loop through every pixel comparing the color of it with the types color. If match then cellType prefab instantiation\u00a0! Et voil\u00e0\u00a0! To edit your level, you just have to edit the texture.\n\nIn out game, each cell has an \u2018int\u2019 attribute to discribe the fire state (0 = normal, 1 = low fire, 2 = medium, 3 = high, 4 = burnt). So i used the same technique and paired a fire state with a color. I created a second texture and job\u2019s done.\n\nThe more I look at my code, the more I feel inconfortable. But it\u2019s a jam, that\u2019s OK, i\u2019ll share it\u00a0(if you copy it, please make it clean) :\n\n![LDJam code.png](\/\/\/raw\/364\/13\/z\/52f4d.png)\n\n\n\nNOTE\u00a0: \n- when you import a texture, you have to enable the READ\/WRITE to be able to read the pixel value. Anyway, if not Unity will return you an error. BUT it won\u2019t let you any advice if you let the default parameters for COMPRESSION and FILTER MODE. Deactivate them otherwise the engine will try to smooth your texture and it will modify you pixels color.\n\n- for the fire state, i could have used a RGB chanel wich is already an int. That should saved some memory, but since there are 5 states, I chose to ease the color differentiation while editing the texture and saving others time instead of 5 Vector4 in the RAM.\n\n- To create the diferent cellTypes, FireState, etc. I used the ScriptableObject tool. This allow you to create preset for non MonoBehavior classes and structures in the editor. I won\u2019t dive deeper into it, bur I recommand you to learn, practise and master this tool. Here is what it looks like :\n\n![LDJam scriptable.png](\/\/\/raw\/364\/13\/z\/52f4e.png)\n\n\n\nThank you for reading, I hope this would help someone.","comments":1,"comments-timestamp":"2022-10-10T07:03:15Z","created":"2022-10-09T20:26:20Z","files":[],"files-timestamp":0,"id":309780,"love":7,"love-timestamp":"2022-10-11T18:05:51Z","meta":[],"modified":"2022-10-11T18:05:51Z","name":"Diving into WOOLLY FIRE's grid system","node-timestamp":"2022-10-09T20:36:21Z","parent":302441,"parents":[1,5,9,296586,302441],"path":"\/events\/ludum-dare\/51\/fires-away\/diving-into-woolly-fires-grid-system","published":"2022-10-09T20:36:21Z","scope":"public","slug":"diving-into-woolly-fires-grid-system","subsubtype":"","subtype":"","type":"post","version":965762},"node_metadata":{"n_key":"309780","n_urlkey":"396947","n_parent":"302441","n_path":"\/events\/ludum-dare\/51\/fires-away\/diving-into-woolly-fires-grid-system","n_slug":"diving-into-woolly-fires-grid-sy","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"201827","n_created":"1665347180","n_modified":"1665511551","n_version":"965762","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/51\/fires-away\/diving-into-woolly-fires-grid-system","text":"Hi guys, Pierre here.\n\nI wanted to talk about the way i developped our grid generation tool during the Jam 51. Nothing revolutionary, but I\u2019m sure it will be interesting for some.\nBut first of all, I need to pitch the game since most of you didn\u2019t test it :\n\nA fire has start in the countryside and your job is to manage the firefighters response. EVERY TEN SECONDS, the fire will grow and try to spread through the grid. Fill your trucks and send them on the firefront. Try to understand how the cellular automaton works\n\n(Play and rate us here: https:\/\/ldjam.com\/events\/ludum-dare\/51\/fires-away)\n\nOK, so let\u2019s start with our grid system with a bit of oubviousness\nA grid is a group of connected cells. Those can be the same (like in chess) and be seen as physical container that can be fill by a pawn, an agent or a unit (or whatever, name it as you wish). But it\u2019s not the case in our game, every single cell has in reality a \u2018cell type\u2019 that influence the behavior of fire in it. For instance, a wheat cell burn faster than a forest cell, and water cell just can\u2019t.\n\nIn the curent game, there are 5 different cell type\u00a0: Forest, Plain, Village, Water and Wheat.\nEach of these have an interest in the game. Plain is kind of the base type, Forest and Wheat are reskin with diferent fire propagation values that make fire slow or speed up. Water refill the tanks in  the next cells and villages are a losing condition. I won\u2019t dive into details because it already a long post and I didn\u2019t even start to talk about texture.\n\nSo\u00a0! We want to have a grid containing cells but each of them is one of the 5 types we just saw. We could just create 5 prefabs and smile to the level designer and say\u00a0: \u00ab\u00a0Your turn to place the 256 prefabs\u00a0! Good luck\u00a0! \u2026 And do it well otherwise you\u2019ll have to iterate :D\u00a0\u00bb. But we\u2019re not this kind of person, obviously not. We actualy are the rock of the team, the one without nothing could be done, the all mighty programmer and it is time to be merciful. \n\nIn order to ease their job, I personnaly thought about texture almost instantly. What are texture if it\u2019s not a grid of pixel having each a diferent type (i mean color) ? I paired a cellType with a color, made my very best piece of art in microsoft paint and loop through every pixel comparing the color of it with the types color. If match then cellType prefab instantiation\u00a0! Et voil\u00e0\u00a0! To edit your level, you just have to edit the texture.\n\nIn out game, each cell has an \u2018int\u2019 attribute to discribe the fire state (0 = normal, 1 = low fire, 2 = medium, 3 = high, 4 = burnt). So i used the same technique and paired a fire state with a color. I created a second texture and job\u2019s done.\n\nThe more I look at my code, the more I feel inconfortable. But it\u2019s a jam, that\u2019s OK, i\u2019ll share it\u00a0(if you copy it, please make it clean) :\n\n![LDJam code.png](\/\/\/raw\/364\/13\/z\/52f4d.png)\n\n\n\nNOTE\u00a0: \n- when you import a texture, you have to enable the READ\/WRITE to be able to read the pixel value. Anyway, if not Unity will return you an error. BUT it won\u2019t let you any advice if you let the default parameters for COMPRESSION and FILTER MODE. Deactivate them otherwise the engine will try to smooth your texture and it will modify you pixels color.\n\n- for the fire state, i could have used a RGB chanel wich is already an int. That should saved some memory, but since there are 5 states, I chose to ease the color differentiation while editing the texture and saving others time instead of 5 Vector4 in the RAM.\n\n- To create the diferent cellTypes, FireState, etc. I used the ScriptableObject tool. This allow you to create preset for non MonoBehavior classes and structures in the editor. I won\u2019t dive deeper into it, bur I recommand you to learn, practise and master this tool. Here is what it looks like :\n\n![LDJam scriptable.png](\/\/\/raw\/364\/13\/z\/52f4e.png)\n\n\n\nThank you for reading, I hope this would help someone.","title":"Diving into WOOLLY FIRE's grid system","wayback_source":[]}