Code Monkey home page Code Monkey logo

rs2048's Introduction

rs2048

rs2048 interface

A clone of 2048 written in Rust. Use the arrow keys to move and R to reset.

This is work in progress but if you want to jump right in, take a look at this demo.

Running the application

  1. Install cargo-web using cargo as
cargo install -f cargo-web
  1. Compile to WebAssembly using Rust's native WebAssembly backend:
cargo web start --target=wasm32-unknown-unknown
  1. Visit http://localhost:8000 with your browser to view the application.

For more information, see the Github repository and documentation of stdweb.

rs2048's People

Contributors

bartmassey avatar crcheng avatar dineshadepu avatar jtplouffe avatar jylee14 avatar kappadistributive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rs2048's Issues

Prevent loss of best score when closing window

Currently, the best score is only stored when the player manually resets the game by pressing 'R'. To avoid data loss, we also store the best score when the browser window is closed.

Add an optional undo feature

At the start of the game, let the player decide whether he wants to enable an optional undo feature and implement this.

Add GUI with stdweb

Using stdweb, create a GUI to replace the current CLI representation.

Bonus: Include transition animations.

Implement a scoreboard

Implement a scoreboard. This can range anywhere from a simple text field displaying the current score to a much wilder system to keep track of the score with flashy animations that trigger whenever the player reaches a new milestone.

Tile is occasionally overwritten by background color

Google Chrome 71.0.3559.6 on Debian Linux. Under some hard-to-define conditions, I'm seeing a white square where one or two of the game tiles should be. This happens both with the online demo and when compiled locally.

Provide a step-by-step manual to get started

While installing rs2048 on my new system today, I've noticed that it does take a number of undocumented steps to even get started working on this.

In particular: Installing cargo web, rustup and the wasm32-unknown-unknown target.

I'd be great if someone could take the time to carefully document how to get this thing started and add that to our README.

Code should be thoroughly commented

The code as it stands has some comments, but a thorough commenting would make it more educational. Probably best to use rustdoc-style comments for top-level stuff: you can get them formatted for a binary with cargo rustdoc -- --document-private-items. Add the --open flag to view the documentation, or just open it with a web browser.

Needs build and run instructions

The README could use instructions on building and running the code, including at least a pointer to the stdweb documentation.

Cargo run fails

Hi,

I tried to run the binary by cargo run. But it fails. The traceback is follows

 ----This is LAPTOP----------------------------------
 dinesh@LAPITOP (master) /home/dinesh/prog/rust/rs2048 $  
|  Dell Laptop=> cargo run
    Updating crates.io index
  Downloaded libc v0.2.46                                                                                
  Downloaded stdweb v0.4.12                                                                              
  Downloaded serde v1.0.84                                                                               
  Downloaded stdweb-derive v0.5.1                                                                        
  Downloaded stdweb-internal-runtime v0.1.3                                                              
  Downloaded serde_json v1.0.34                                                                          
  Downloaded stdweb-internal-macros v0.2.4                                                               
  Downloaded serde_derive v1.0.84                                                                        
  Downloaded discard v1.0.4                                                                              
  Downloaded base-x v0.2.4                                                                               
  Downloaded sha1 v0.6.0                                                                                 
   Compiling proc-macro2 v0.4.24                                                                         
   Compiling unicode-xid v0.1.0                                                                          
   Compiling semver-parser v0.7.0                                                                        
   Compiling ryu v0.2.7                                                                                  
   Compiling serde v1.0.84                                                                               
   Compiling libc v0.2.46                                                                                
   Compiling stdweb-internal-runtime v0.1.3                                                              
   Compiling itoa v0.4.3                                                                                 
   Compiling sha1 v0.6.0                                                                                 
   Compiling base-x v0.2.4                                                                               
   Compiling rand_core v0.3.0                                                                            
   Compiling discard v1.0.4                                                                              
   Compiling semver v0.9.0                                                                               
   Compiling rand_xorshift v0.1.0                                                                        
   Compiling rand_isaac v0.1.1                                                                           
   Compiling rand_hc v0.1.0                                                                              
   Compiling rustc_version v0.2.3                                                                        
   Compiling rand_chacha v0.1.0                                                                          
   Compiling rand_pcg v0.1.1                                                                             
   Compiling stdweb v0.4.12                                                                              
   Compiling rand v0.6.1                                                                                 
   Compiling quote v0.6.10                                                                               
   Compiling syn v0.15.23                                                                                
   Compiling serde_json v1.0.34                                                                          
   Compiling serde_derive v1.0.84                                                                        
   Compiling stdweb-derive v0.5.1                                                                        
   Compiling stdweb-internal-macros v0.2.4                                                               
   Compiling rs2048 v0.1.0 (/home/dinesh/prog/rust/rs2048)                                               
error: linking with `cc` failed: exit code: 1                                                            
  |                                                                                                      
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.12u98qmvxgwnb5l3.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.19xpla8x56q4x3uy.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1eeqhwt0hdiln5gf.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1jmdhwum4l7bnc8s.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1k8ew3uzcpb2w6dv.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1p0xsdrepbnv3s7g.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1qrgxd2x6qxdyqwt.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1vao612ogiap2lbn.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1wem7hx59rk2ugfh.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.1zj1uzxbf4l4vn3v.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2314dpb7u48w8lfx.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2erkxheehgtxa4uq.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2evx48xqd6vxh8uw.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2fxx578y2ahc2ltf.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2jicpf9col1c7kam.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2js0uj3zapl0cs4g.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2myl9sjbw5pc9cig.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2so994dn3e1jzk7t.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.2tv679fz1z02uzjr.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3116t76qbma3i75n.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.32ofkvmdtxir2c4d.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.33cprtwjg9mjyeca.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.39uegg6d8be63xy3.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3fmhvr69cw2slh36.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3g3jbf4vzy3sh8f5.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3gznyv3gwpsv5m7z.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3jgyp5ogcf8mvfov.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3nkh67hz4qo7gpbg.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3nppd1cep9w07wwd.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3r4oitlprtngs2hp.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3rdeoy9r43ls34tq.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3rozt1vzz5ovg96j.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.3yrknmk35s3abvoa.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.43vh0tb0yzhkj3fo.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.44ydvk1p7hwrzwy5.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.44z4w073vk9z8pa2.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.490yh413guee162q.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4awscvw9ylvy6xca.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4cixibn6eo2qodv9.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4ftzc5ypqhbi9sik.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4lxxnj9vkdz6jhpe.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4p9lgakxtjnbtfwf.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4rhqvgjd8mqzbqom.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4rkve1z0wi419duv.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4rnewjpc5gqvrgg8.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.4ypxvoq5zi3klqrx.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.50kmppcuqgi6p3vc.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.51igxnwhsf5l9m2t.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.52up1kiuoqz99ocd.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.52w1yt4s0mnz3ery.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5bk00cz7f1rrbto9.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5c15q3hzt9lsjp9k.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5egzrlmjqz1npldb.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5fgap0qhbdo0aeku.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5gkyiieuqpexzy0u.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.5t1c9hvpi4i2tk.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.9kxs7sonqdsh6tk.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.alyn3c6sli2lgey.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.dmuzvo0d5od97ai.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.dn2qezq4k3252kv.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.frl9pe6kck1nl9z.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.gp8ogjtn1xxj7jw.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.j0xv48csg7wwmf6.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.qf2har8gisgguma.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.tj1sxyhagfkp26a.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.wa32w204ptoaej4.rcgu.o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.yvf1f8ek0bo0vwm.rcgu.o" "-o" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4" "/home/dinesh/prog/rust/rs2048/target/debug/deps/rs2048-d084f6410e6901e4.8yvpy1tr2hvdneg.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/dinesh/prog/rust/rs2048/target/debug/deps" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libdiscard-81ca2f28c1335aa3.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb_internal_runtime-397a8413a6138326.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libserde_json-bca01b302ec69ee1.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libryu-b3f9e4b1eb2ad31a.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libitoa-25eebd7e9d447b49.rlib" "/home/dinesh/prog/rust/rs2048/target/debug/deps/libserde-1a27ab045957b5a5.rlib" "-Wl,--start-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-52f862a21e09568c.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-b89f1a9b548bfef9.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-a7f738f7aa980965.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-4c9cbe622de116ab.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-48c8a8552cff934e.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-517830e9d56bab97.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-2d44723f32308cf8.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f2133e8b70369157.rlib" "-Wl,--end-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-71671e8958739d51.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o): In function `_$LT$stdweb..webapi..rendering_context..CanvasRenderingContext2d$u20$as$u20$stdweb..webcore..instance_of..InstanceOf$GT$::instance_of::snippet::__cargo_web_snippet_89611721005b3de331324f19bedec5df179862e4::h9ad44b6f965f4e00':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:32: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o): In function `_$LT$stdweb..webapi..rendering_context..CanvasRenderingContext2d$u20$as$u20$stdweb..webapi..rendering_context..RenderingContext$GT$::from_canvas::snippet::__cargo_web_snippet_49ae24e0f2d690c290030200ef793256363af281::h07f856d87533d99b':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:101: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o): In function `stdweb::webapi::rendering_context::CanvasRenderingContext2d::set_fill_style_color::snippet::__cargo_web_snippet_7e69871d2f0243bddcb8cffc809fd6fb5fb78697::h98bdd2e04749ca52':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:91: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o): In function `stdweb::webapi::rendering_context::CanvasRenderingContext2d::set_font::snippet::__cargo_web_snippet_8c8a0fd988218bf31fae8adc33f715997855bce8::h5a5897f33dd5027e':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:91: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o): In function `stdweb::webapi::rendering_context::CanvasRenderingContext2d::set_text_align::snippet::__cargo_web_snippet_1d3f576eb597a51bb802c752d3cfc29389445412::hd616a8213030030b':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:91: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.0.rcgu.o):/home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:91: more undefined references to `emscripten_asm_const_int' follow
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.2.rcgu.o): In function `stdweb::webcore::ffi::emscripten::event_loop::h911bec9781a5883c':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/ffi/emscripten.rs:9: undefined reference to `emscripten_pause_main_loop'
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/ffi/emscripten.rs:11: undefined reference to `emscripten_set_main_loop'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.6.rcgu.o): In function `_$LT$stdweb..webapi..dom_exception..SyntaxError$u20$as$u20$stdweb..webcore..instance_of..InstanceOf$GT$::instance_of::snippet::__cargo_web_snippet_7c8dfab835dc8a552cd9d67f27d26624590e052c::h2520b7c8b24f98c2':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:32: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.8.rcgu.o): In function `stdweb::webcore::value::Reference::from_raw_unchecked::snippet::__cargo_web_snippet_9f22d4ca7bc938409787341b7db181f8dd41e6df::h6e9dbb9cae386b94':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:32: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.8.rcgu.o): In function `_$LT$stdweb..webcore..value..Reference$u20$as$u20$core..ops..drop..Drop$GT$::drop::snippet::__cargo_web_snippet_80d6d56760c65e49b7be8b6b01c1ea861b046bf0::hc3b3b99a8c16767e':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:32: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.8.rcgu.o): In function `stdweb::webapi::parent_node::IParentNode::query_selector::snippet::__cargo_web_snippet_a152e8d0e8fac5476f30c1d19e4ab217dbcba73d::h2bbae721ad67fc58':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:101: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.8.rcgu.o): In function `stdweb::webapi::parent_node::IParentNode::query_selector::snippet::__cargo_web_snippet_b06dde4acf09433b5190a4b001259fe5d4abcbc2::h63a6611d0e12ce70':
          /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:101: undefined reference to `emscripten_asm_const_int'
          /home/dinesh/prog/rust/rs2048/target/debug/deps/libstdweb-6dba54f1e1ea13d5.rlib(stdweb-6dba54f1e1ea13d5.stdweb.1w2t1392-cgu.8.rcgu.o):/home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.12/src/webcore/macros.rs:101: more undefined references to `emscripten_asm_const_int' follow
          collect2: error: ld returned 1 exit status                                                     
                                                                                                         
                                                                                                         
error: aborting due to previous error                                                                    
                                                                                                         
error: Could not compile `rs2048`.                                                                       

To learn more, run the command again with --verbose.
 
 

Needs license

This code should be placed under an open source license, so that folks can legally contribute to it.

Enable input from mobile devices

Good job, unfortiunately I can't try it out, since I am using my tablet. As a modern web APP, consider using a mobile first approach, i.e. enabling mobile input and using it as the primary target device.

Code needs unit tests

Testing for GUI code with randomization is hard, but some basic unit tests for the other functions would give more confidence that all is well. See issue #10 for where some doctests might come from.

Wrapping game in Rc<RefCell> ?

I don't see any reason why the game needs to be wrapped in Rc<RefCell> in main.rs? All those calls to .borrow() and .borrow_mut() in main.rs would then be unnecessary. Removing this compiles under all the different stdweb versions.

Create rudimentary CI/CD pipeline

Create a rudimentary CI/CD pipeline.

Steps to include:

  • Build the WASM version of rs2048
  • Deploy the new version of the demo when merging with master

Extend tile color palette

Right now, tile color information only exists up to a tile of size 2048. Extend this color palette up to 2^17 -- the maximal possible tile.

Multiplayer support

Multiplayer support in 2048?! Damn right!

Here's the elevator pitch:

Two players play 2048, with the usual rules, on their own board while observing the opponent's board. Whenever a player completes a combo, a random tile on the opponents board of lowest current value (excluding tiles whose current value is 1) is transformed to a tile of value 1 and, if there are any spots left, an additional tile of value 1 is randomly spawned in an empty spot. Those tiles behave like any other tiles, i.e. you can merge two tiles of value 1 into a tile of value 2.

A combo can be completed in two ways:

  • Merging at least 4 tiles in one move,

  • after having merged at least 4 tiles in one move, every consecutive move that results in a merge extends the combo.

The player with the highest current score after both players have no legal moves left wins. (In particular, if one player has no legal moves left and the other player exceeds that player's current score, they win. Thus eliminating the need for the users to stick around while the winner completes their game.)

I envision this to become a game with rapid pace, similar to Tetrisfriend's Battle 2P.

In order to figure out whether this is a desirable game mode, I'd suggest first implementing a very rough, local multiplayer only mode with the intention to pinpoint and resolve issues with the actual gameplay mechanics.

Arrow keys don't work on iPad Pro

I discovered that the arrow keys on my iPad Pro's smart cover keyboard don't work (neither in the current version of Safari nor Chrome).

Since resetting the board with 'R' does work, I suspect that the arrow keys simply present themselves under a different name to the event handler.

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.