import { HCenter, Main, styles } from "./common.tsx"; import { debug_render } from "./html.ts"; import { Component } from "./jsx/jsx-runtime.ts"; const Eggbug: Component = () => ( ); function health_style(current: number, last: number, max: number) { const inc_width = 100 / max; const dhealth = last - current; console.log(inc_width, dhealth); return styles({ transform: `translateX(${-(inc_width * dhealth)}%)`, width: `${last * inc_width}%`, }); } // could be generalized // might be worthwhile later since is BAN const Health: Component = ({ current, last, max }) => ( console.log({ current, last, max }), ( {Math.floor(current).toString()} /{max.toString()} ) ); // one-time animations of hit numbers of health flying off the screen const BattleFrame: Component = ({ health, last_health, max_health, msg }) => ( ); const Defeated: Component = ({ last_health, max_health }) => ( eggbug is physically unharmed, emotionally destroyed ... ok eggbug is fine now "re bug" to "killbug" ); const DamageNumber: Component = ({ n }) => ( {Math.round(n).toString()} ); const Battle: Component = ({ max_health = 100, health = max_health, last_health = health, damage_multiplier = 10, damage_bonus = 1, ...rest }) => health > 0 ? ( {health < last_health && ( )} ) : ( ); const Timer: Component = () => ( click this when done (HONOR SYSTEM) (EVEN AMONG EGGBUGS THERE CAN BE HONOR) {[ ...new Array(601).fill(undefined).map((_, i) => `${i}s`), "∞s", ]} ); // a timer would be flippin rad // (it would look like an actual scrolling clock thingie) // (because it would have to) debug_render( {/* */} );