[
  {
    "path": "README.md",
    "content": "[START HERE](https://github.com/bigrando420/resources/wiki)"
  },
  {
    "path": "attack_animation.jai",
    "content": "// This whole thing is run each frame in the rendering loop of the game.\r\n//\r\n// https://easings.net/ to grab the easing funcs\r\n//\r\n// (pseudocode)\r\n\r\nen: *Entity; // this is just the player\r\nheld_item := just_some_other_structure_i_have_for_storing_item_data;\r\nlength := 0.2;\r\n\r\ndo_flip := en.x_dir == -1; // for flipping around on the X when the player turns around to move the other way\r\nis_up := en.attack_count % 2 == 0; // up and down flip flop. Incremeted for every attack.\r\n\r\n// attack_timer plays out for something like 200ms\r\n// the timer_alpha just maps 0 -> 200ms down to a 0.0 -> 1.0\r\n// now we've basically got the progress of the attack animation (which I like to call the alpha)\r\nalpha := timer_alpha(en.attack_timer, length);\r\n\r\nxform := Matrix4_Identity;\r\n\r\n// the pivot point of all of this starts at the base of the player.\r\n// + 18.0 to get up to the chest-ish area\r\nxform *= xform_translate(.{en.pos.x, 18.0});\r\n\r\n// X flip. Self explanatory.\r\nif do_flip then xform *= make_scale_matrix4(xyz(-1, 1, 1));\r\n  \r\n// Y flip flop\r\nif !is_up then xform *= make_scale_matrix4(xyz(1, -1, 1));\r\n\r\n// rotate the arm, around the torso centrepoint\r\narm_rotation := 160.0 + (1.0-ease_out_back(alpha)) * -90.0;\r\nif !is_up then arm_rotation += 35.0; // if we're down, do a bit more of a rotation since it looks better\r\nxform *= xform_rotate(arm_rotation);\r\n\r\n// this gives us our radius of 8.0 for the rotation above\r\nxform *= xform_translate(xy(0.0, -8.0));\r\n\r\n// now we rotate the grip\r\ngrip_rotation := (1.0-ease_out_circ(alpha)) * -90.0;\r\nxform *= xform_rotate(grip_rotation);\r\n\r\n// apply a grip rotation and translation for each item. That way we can have every item coming from a nice pivot point where the grip should be.\r\nxform *= xform_rotate(-held_item.grip_rotation);\r\nxform *= xform_translate(-held_item.grip_offset);\r\n\r\n// go behind the player when up\r\nz_layer := Z_PLAYER + ifx is_up then 0.1 else -0.1;\r\n\r\n// DRAAAAAAAAAAAAAAW\r\ndraw_sprite_with_transform(held_item.id, xform, z_layer=z_layer);"
  }
]