2048 written in C and compiled to WebAssembly

Overview

2048.wasm

2048 written in C and compiled to WebAssembly

Play

  • Use the arrow keys ( ) to slide the tiles.
  • press n to play over.

Usage

  • Compile C code
$ cd src
$ make game
$ ./play

Note: Make sure you add the appropriate path to SDL2 headers and libs under Makefile.

  • Compile C code to WASM via emscripten
$ emcc -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 --preload-file src/Nunito-ExtraBold.ttf -O3 -I include -L lib src/main.c -o docs/2048.js

But Why?

why not? Took this up as an experiment; This is just 300 lines of really poor C code which took forever to compile to wasm (rip sdl font).

You might also like...
cServe : mean and lean web server written in c

cServe =========== cServe is a web server written in c for POXIS compliant operating systems cServe is planned to be [ ] Supporting HTTP/1.x and HTTP/

QuantumGate is a peer-to-peer (P2P) communications protocol, library and API written in C++.
QuantumGate is a peer-to-peer (P2P) communications protocol, library and API written in C++.

About QuantumGate is a peer-to-peer (P2P) communications protocol, library and API. The long-term goal for QuantumGate is to become a platform for dis

Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)
tiny HTTP parser written in C (used in HTTP::Parser::XS et al.)

PicoHTTPParser Copyright (c) 2009-2014 Kazuho Oku, Tokuhiro Matsuno, Daisuke Murase, Shigeo Mitsunari PicoHTTPParser is a tiny, primitive, fast HTTP r

A network library for client/server games written in C++

yojimbo yojimbo is a network library for client/server games written in C++. It's designed around the networking requirements of competitive multiplay

A simple web browser written for learning purposes in C++
A simple web browser written for learning purposes in C++

AWB: Abbix's web browser pls send help AWB is a simple web browser written for learning purposes in C++, it features a custom engine named orca render

Pipy is a tiny, high performance, highly stable, programmable proxy written in C++

Pipy is a tiny, high performance, highly stable, programmable proxy. Written in C++, built on top of Asio asynchronous I/O library, Pipy is extremely lightweight and fast, making it one of the best choices for service mesh sidecars.

zrp is a nat-passthrough reverse proxy written in modern c++.

zrp is a nat-passthrough reverse proxy written in modern c++. A major use case is to expose a local server via a remote server with public IP.

Professional ARP Spoofer written with C
Professional ARP Spoofer written with C

professional-arp-spoofer Professional ARP Spoofer written with C Note: You can sniff the traffic between any two machines in the network with the help

Comments
  • Version Update

    Version Update

    I made lots of modifications to the code without affecting the output. Also, the README.md file needed to be renewed too, so did it. Checking the commit messages would be helpful.

    opened by rohanbari 1
  • [wasm] Compilation issues

    [wasm] Compilation issues

    2048.js:3948 emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up.
    
    2048.js:1377 Uncaught RuntimeError: abort(Runtime error: The application has corrupted its heap memory area (address zero)!) at Error
        at jsStackTrace (http://127.0.0.1:5500/web/2048.js:1685:19)
        at stackTrace (http://127.0.0.1:5500/web/2048.js:1702:16)
        at abort (http://127.0.0.1:5500/web/2048.js:1371:44)
        at checkStackCookie (http://127.0.0.1:5500/web/2048.js:1164:46)
        at Browser_mainLoop_runner (http://127.0.0.1:5500/web/2048.js:4063:9)
        at abort (http://127.0.0.1:5500/web/2048.js:1377:11)
        at checkStackCookie (http://127.0.0.1:5500/web/2048.js:1164:46)
        at Browser_mainLoop_runner (http://127.0.0.1:5500/web/2048.js:4063:9)
    
    opened by inishchith 1
  • New tiles should not appear if no changes occur

    New tiles should not appear if no changes occur

    Nice project, love the game! Going off of other versions of 2048 that I've played (e.g. 2048.io), if an attempted move doesn't slide any tiles then no new tile should spawn. This makes the game a bit more challenging, forcing the player to move tiles each turn.

    Looks like the easy fix would be to copy the grid in loop before a key event tries to modify it, then only call add_value if the grid has changed.

    opened by tcsullivan 1
Owner
Nishchith Shetty
Computer Programmer
Nishchith Shetty
Chocolate Doom WebAssembly port with WebSockets support

Wasm Doom This is a Chocolate Doom WebAssembly port with WebSockets support. Requirements You need to install Emscripten and a few other tools first:

Cloudflare 191 Dec 31, 2022
A Hidden and Undetectable Remote Access Tool written in C++ and Server in Python3

Spyware-RAT A Hidden and Undetectable Remote Access Tool written in C++ and Server in Python3 This program utilizes the standard winsock library for s

null 44 Dec 25, 2022
:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

uriparser uriparser is a strictly RFC 3986 compliant URI parsing and handling library written in C89 ("ANSI C"). uriparser is cross-platform, fast, su

uriparser 260 Dec 28, 2022
An easy to use and powerful open source websocket library written in C.

libwebsock Easy to use C library for websockets This library allows for quick and easy development of applications that use the websocket protocol, wi

Jonathan Hall 47 Nov 13, 2022
BingBing 60 Dec 15, 2022
Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services.

Pushpin is a reverse proxy server written in C++ that makes it easy to implement WebSocket, HTTP streaming, and HTTP long-polling services. The project is unique among realtime push solutions in that it is designed to address the needs of API creators. Pushpin is transparent to clients and integrates easily into an API stack.

Fanout 3.2k Jan 2, 2023
A Rust crate that simplifies the integration of Rust and eBPF programs written in C.

This crate simplifies the compilation of eBPF programs written in C integrating clang with Rust and the cargo build system with functions that can be

Simone Margaritelli 19 Mar 16, 2022
Enabling services on your device 81 Jan 6, 2023
WSServer is a fast, configurable, and extendable WebSocket Server for UNIX systems written in C (C11).

WSServer a C WebSocket Server WSServer is a fast, configurable, and extendable WebSocket Server for UNIX systems written in C (C11). As of version 2.0

Morten Houmøller Nygaard 170 Dec 8, 2022
Micro http server and client written in C++

httpp Micro http server and client written in C++ The motivation behind this little piece of code is to provide a really simple, yet efficient HTTP se

Thomas Sanchez 158 Nov 28, 2022