Better HN
topnewbestaskshowjobs
Log inSign up

billnreed

10 karma · joined Oct 31, 2017 (9y ago) · 4 submissions

Submissions

comment 1y ago · link · parent

I've seen this engine before and thought it was really cool!

I've been playing around with writing my own turn-based game engine with TypeScript: https://github.com/snowbillr/turn-based-game-engine

It's a WIP still, but what's really been the struggle for me is coming up with a data structure and traversal algorithm for the turn order. I wanted that to be extremely configurable by whoever uses the library.

```

engine.defineFlow((f) => {

  f.node({
    actions: f.actions(WelcomeMessage),
  })

  f.node(
    {
      actions: f.actions(RoundStart),
      cleanups: f.cleanups(RoundEnd, TestLog),
    },
    players.map(player => f.node({
      playerId: player.id,
      actions: f.actions(TurnStart),
      cleanups: f.cleanups(TurnEnd),
    })),
  )
});

```

This example shows a TicTacToe game defined like this:

```

- welcome

- round

  - player 1 turn

  - player 2 turn
```

What I ended up with was essentially a tree that's traversed depth-first to enter each node, and then goes back up the same traversal path until a sibling node is found to dive into.

That lets the user define rounds/turns/phases as children of each other in whatever shape they want.

It's been a real fun project!

comment 2y ago · link · parent

Thank you! No license or anything, just go for it if you want to use them.

comment 2y ago · link · parent

I made a few CSS-only single `div` loaders a while back, it was a fun challenge to make them interesting while only using a single div.

https://codepen.io/snowbillr/pen/QEagmW

comment 9y ago · link · parent

That's super cool! The `:checked` and `:valid` and `:invalid` selectors are really powerful tools when it comes to CSS. This is a real fun use of clever CSS selectors.

I was doing something similar the other day with toying around trying to come up with an HTML/CSS only game. I ended up with this: https://codepen.io/billnreed/full/boXrVr