/Craptorio

Primary LanguageLuaMIT LicenseMIT

craptorio_intro_screen2

A de-make of Factorio for the TIC-80 fantasy console.

furnace_stack_demo_4

**Note, this project is a WIP.

  • If you have found this page and would like to contribute to the project, please open a discussion and we can talk about the details.

Core idea for de-make

  • To cover the main factorio game loop, which is mining resources and using belts, inserters, and machines to craft science-packs which are used to research new technologies.

  • This is a passion project for me, and I am putting as much time into this as I can for now. That is between IRL work and daily obligations.

  • Certain game-mechanics will likey be left out, due to the constraints imposed by TIC80. This is the point obviously, (or perhaps not so obvious to some) however I do intend to add as many features and mechanics from the original as technically feasible.

Updates - Will post development and progress updates here

  • Updated palette
  • Added assembly machine
  • Added trees
  • Big updates to worldgen system
  • Added burner mining drill
  • Added stone furnace
  • Added underground belts
  • Research will include upgrades to the player robot, such as increased fly speed, further range, etc
  • You now play as an advanced logistics robot, capable of flying over any terrain or obstacles
  • Working on finishing new splitters Currently working on crafting mechanics, inventory, and item systems. -new_recipe_widgets
  • lab_research_test
  • tech_hover_ex
  • tech_scrn_active
  • furnace_ui_v5
  • new_furnace_ui
  • assembly_ui_layout_4
  • assembly_recipie_overlay_demo
  • screen2
  • worldgen_demo
  • worldgen_update3
  • f4rt-1
  • worldmap_discovery
  • ubelt_test1
  • ubelt_test2
  • forest_demo
  • becoming_the_bot
  • crafting_menu_test
  • ui_test_05
  • craft_menu
furnace_test3.mp4

Transport Belt

  • The idea here is to re-create belts VERY similar to factorio, however there are some differences.
  • The belts in Craptorio are displayed as 8x8 pixel sprites, with 4 animation frames.
  • When watching the belt animation however, it appears as if the belt has 8 animation frames, which makes it seem like the belt is moving 1-pixel per frame. This is by design - due to making the texture x-tileable. Only 4 frames are needed before the texture 'loops'.
  • This behavior is needed due to items on belts needing to shift 1-pixel per game tick to move along the belt.
  • The belts have 2 - lanes, just as in Factorio's belts. Each lane is represented as a table with 8 indices, so 1 item slot per belt pixel, 8 item slots per lane. This means that each belt, when fully compressed can hold 16 items. This is a few more total items per belt than Factorio belts allow (14 I believe), so further optimization will be necessary. Each index corresponds to an item id, which itself is a key/index to a look-up table of item definitions. When the belt updates each cycle, (not every tick), all lane indices values are shifted to the left (towards 0). Index 1 represents the last item slot a belt has, before the item would output to whatever the belt is facing, with index 8 being the last slot to the right (given the belt is facing left). The items are rendered in order from index 1 to index 8, and the belt's themselves are rendered in order of parent->child.

circuits3x_8x copper_iron_items red_green_circuit_demo

  • Items on belts are allowed to 'stack', which practically means that the items can overlap (by 2-pixels in my case). The items are displayed as 3x3 pixel 'sprites', which aren't actually sprites, but a table of 9 colorkey's {1,2,3,4,5,6,7,8,9} with each index representing a palette color. The item's x,y location is computed during rendering, as their 'positions' are relative to the owning belt, and not needing to be stored or known globally. This approach neglects needing another table to otherwise keep track of all items.

  • Curved belts are also implemented, again as in the original game. The snapping behavior has been replicated, as well as the lane priority system, or preference to deposit items to specific other belt lanes depending on both belts rotation. The lane-priority-rotational-preferences also apply to inserters when depositing items onto a belt.

**Update: Right now, the belt system is pretty far along. Most features/mechanics from the original are already implemented, excluding red and blue belts, (which are just faster belts). The 'drag locking' feature has just been implemented, which was an addition to the original from the devs at some point. Players love this feature beacause it locks belt-placing to either x or y, depending on the direction you drag your mouse while placing belts. Helps prevent unwanted belt placement. - Completed!

drag_lock_demo

I plan on polishing the belt and inserter systems heavily before moving on to other entities/game mechanics. - Done! As Harkonnen said, 'belts are the very heartbeat of factorio'. So I want these systems to function exceptionally well before trying to implement additional features. I believe once the core systems are worked out, I will eventually create a list of proposed features, and try to order them by development priority.

belt_snapping

video1

Inserters

Inserters are rendered using 2 8x8 sprites, 1 for base, and 1 for straight arm or angled arm.

inserters_newest

  • Rotation, flipping, and position offsets of the inserters arm sprite's are pre-calculated and indexed to a look-up table (based on inserters current rotation), to avoid having many if statements. This also avoids excessive table look-ups, as the inserter only has to access this LUT when the player manually rotates the inserter, or places a new one down. There may be other situations I haven't thought of, but for now this should do.

inserter_compression inserters

World Generation

  • See more recent updates to worldgen at top ^
  • Skeleton system in place
  • Uses open simplex noise to generate terrain, ore fields, forests, etc
  • Infinite procedural generation - completed
  • Auto-tile system to have smooth borders around 8x8 terrain tiles
  • Generates separate fields for iron, copper, stone, etcetera.
  • Currently focused on ore distrubution and implementing remaining ore types (stone, coal, uranium, oil) - done
  • (TODO) Need to implement similar method above to generate forests - done
  • Still in heavy development

simplex_ore_test worldgen_collision_test