You do not need to say window.view
or window.editor
.
If you use an <iframe>
instead of a <section>
then the contents can't leak out, and script tags will work correctly. You can also use srcdoc:
These two changes simplify things greatly (~225 bytes), run()
becomes just:
function run () { view.srcdoc=editor.value }
Here's a live version. It's controlled with the arrow keys and shows the score as well as the game over state ('!' after the score) and the UI mimics the [python version](/r/tinycode/comments/20s9d8/2048_in_533_bytes_of_python/) posted recently. The 529 bytes are without line breaks which are only there to make it a tiny bit more readable.
The code consists of three functions:
I'm happy to answer any questions about the details.
PS: I've also made a JS1K demo that implements a variant of 2048.
EDIT: corrected variable name, updated link
Value ended up in the xmm0
register which happens to be a return register for doubles.
Press "Execute" to view assembly.
http://www.tutorialspoint.com/compile_c_online.php?PID=0Bw_CjBb95KQMeVVTYlEySXdfOE0
I was wondering how to get a tiny 3d engine, here is what i got so far: https://github.com/discoloda/NOS
it starts a OpenGL window, includes some handy input API, and a model decompression library. I plan on adding sound and other things to make it usefull for little games.
it includes 3 examples and a small incomplete modeler (it doesn't save to file or anything) .
Enjoy
Just for the record, here is an implementation of k-means clustering (also for n-dimensional data) in 32 loc of Python that I wrote a few days ago.
Note: The error messages on the page just indicates that ideone doesn't like the random module. There's no error if you run the script elsewhere.
Indeed. Bringing its size further down meant changing the gameplay a little. The remaining parts of the code were crucial to stabilize the issues you mention, and I could only position the apple offset a bit off the wall to compensate.
p.s. Shaved off some more bytes: JSFiddle
232 bytes
https://github.com/darius/miasma/blob/master/python/calc.py
Not small enough for tinycode, but it's a start. Compiles from RPN to x86 machine code in memory and then calls it. (The instructions appear in reverse order because it generates code from back to front.)
> My primary test shell is dash, but it also supports local
as an extension. In fact, I'm not aware of any Bourne shell clone that doesn't support local
. Perhaps that's an argument in favor of its use.
Yes, after I asked my question I went googling and quickly ran into Debian dash and this page that enumerates 3 features deemed too basic to do without -- including local
.
I think I may stick to that. Standards are a foolish consistency. What matters is that the script run on any reasonably extant platform.
(I also just learned in the process that all my testing on Ubuntu has already been on dash. Great!)
Interesting that you've kept it that small with such a sparse coding style
When's the xcb port? At this point you aren't using anything weird. All the functions you're using can be ported with reference to nobox (libX11 is running on xcb now, so you're only wasting memory. Linking with xcb saves quite the space. I'm envying that when I use "-Os -march=native" the resulting binary is 9957B. A slight modification made gcc hurl another K for nobox recently, so I'm at 11144B)
Do you intend to use this as your main desktop? If you keep up on finding those features that are necessary for you (the programs I use couldn't do without configure request handling), you'll find nothing else fits
You're also listening to an awful lot of event types. Similar waste with including stdio. You could allocate the head of the linked list statically. Skip freeing at exit (Really. It's stupid. Very likely the memory manager won't even release the pages back to the kernel). Also noticing that you don't have dwm's sigchld, how are you dealing with zombies?
For giggles I wrote an Ada version after gawking at the C code (also the XCB version)
Really appreciate this great piece of example code!
To answer that one would need to know where you live right?
You might want to start reading this post on ycombinator (TL;DR: Context is important. It's not illegal to spoof your MAC address as it's not illegal to wear a ski mask. But run into a bank with a ski mask on your head and start screaming and you might break a couple laws.) and this wiki article though.