Coder Social home page Coder Social logo

zigster64 / zig-zag-zoe Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 1.0 934 KB

Multiplayer TicTacToe - in Zig - using HTMX for that zero-javascript experience

Home Page: http://zig-zag-zoe.com

License: MIT License

Zig 76.80% HTML 11.37% CSS 8.71% Dockerfile 0.29% Makefile 2.39% Shell 0.44%
game htmx multiplayer-game tictactoe tictactoe-game zig

zig-zag-zoe's Introduction

๐’€ณ Scribe of the Ziggurat ๐’…†๐’‚๐’‰ช

ziggurat

๐Ÿ”ญ Here is a list of (public) Zig projects Im working on for 2024

  • โšก datastor.zig Very prototype Zig lib for a concept Data Persistence layer suitable for games / IoT

๐Ÿ”ญ Here is a list of Zig projects I have completed (2023)

  • โšก ZTS comptime text templating system, specifically for use in web servers
  • โšก zig-zag-zoe multi-player web based game, using HTMX and SSE
  • โšก zchat Unique chat application, using cuniform over HTTP

๐Ÿ‘ฏ Other Zig projects Im actively using / collaborating on (2023 - 2024)

karlseguin - local forks for development / PRs

Working on libUI-ng stuff for Native UI development

  • โšก Zig libui-ng Zig bindings to libUI-ng
  • C libui-ng Underlying C library that provides a common UI wrapper over native elements (Win32 / GTK / Obj-C Mac)

Others

  • โšก Capy UI Zig native GUI library
  • โšก ZLS ZLS Language Server
  • โšก Zig Language Zig language and compiler

Configs

zig-zag-zoe's People

Contributors

zigster64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zig-zag-zoe's Issues

documentation

  • readmes
  • events.md
  • doc comments on all functions .. many are not right

sound effects

add soundeffects to the app

  • ping when its your turn
  • special tone when its your turn and you hold the flipper
  • explosion sounds
  • victory trumpet vs durge for losers

sometimes login fails

sometimes a login doesnt set the player ID ??

or maybe its just the client i was using was caching an old version - dont know

keep an eye out for it happening again

kill stale event loops

Need a way of signalling all existing event handlers to be terminated

.. i think anyway, might need to check whether this is happening automatically when the client end goes away

teams

be able to group players into teams, so they can collaborate against an enemy team to win

Make it so there are between 0 and 3 teams max

default is 0

If teams is between 1-3, then on choosing a login, choose a team as well

When playing in Team Mode, then denote the boxes with the team color rather than the player color

inactive timeout

Make the game clear itself and restart after an idle timeout

If no incoming traffic with valid X-SESSION ids have been seen for some duration, then kill the game and reset it

card deck

Generate a deck of cards, shuffle them, and hand them out to users

Each user has a hand of cards that are displayed on their console.
When its their turn, they can select to play a card - this removes the card from their hand for the rest of thegame

cards could be things like -

  • uno reverso
  • make next player skip turn
  • get double turn
  • flipper (?) .. this should be very rare, as its a bit overpowered

landmines

some squares can randomly contain landmines that explode when entered

  • effectively skips a turn
  • the resulting explosion may destroy adjacent squares as well

uno reverso

Add special ability to reverse the flow of play

useless in a 2 player game, but useful in 3 or more players

memory leaks

image

There remains 1 teeny memory leak, which I think is related to having the resReqPool growing when the pool is full.

It does correctly free the resources at the end - but maxis remains bumped. Unless there is something else being allocated inside a response or request that is not being freed ? Hard to tell

Running an experiment now with the pool-overflow branch of http.zig, set the pool size to 32, and shrink the audio files down so that the response buffers can be shrunk as well

Experimenting on local, this gives me a build that has zero allocations - even during DOS attack, so lets run this up on AWS for a week and see how it copes

vblog

Do a video blog walkthrough of the code

  • intro to htmx
  • intro to http.zig
  • components .. associates handlers with objects
  • templating using plain old std.fmt.print
  • the magic wand of htmx + SSE
  • thread signals and wait conditions
  • future directions .. maybe pull out the good bits and look at a zone framework or something

Audio borked

On iOS, still getting some audio issues

main screen ting notifications work fine, but zero wing, bomb and victory audio is not playing

more victory conditions

Allow shapes other than simple straight lines to be victorious, as options

  • solid 2x2 block (4 squares)
  • 3x3 hollow square
  • 3x3 solid triangle
  • 5 square X formation
  • 9 square X formation

security

Its a bit lame having a plaintext player_id embedded in the HTML to get the player ID on PUT requests

Change this so that the HTML only stores a single thing - being a UUID generated by the backend

Call this X-SESSION, and include it in all the post headers

Then on the backend, have a hashtable that associates these UUIDs with session details - including the player id, some TTL duration / expiry date, etc

When the game state returns to init, then invalidate all the sessions

That way, a user cant simply replay an old UUID, or try to guess a new valid UUID

Also means that a bunch of state can be attached to the UUID, and only stored at the backend, not placed on the frontend where it can be easily hacked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.