Skip to main content

Posts

Gleitschirmfliegen The Game

Overview Because of reasons, I felt that I have to materialize my ideas before they drive me crazy. Gleitschirmfliegen The Game is one of my biggest projects in the past few years. In total it took me ~270 hours for editing, plus ~400 hours for rendering (including tests). The development process is a mixture of learning, having fun and self torturing. Quite a few things should be worth a few notes. Intro & Credits Intro and Credits are the easiest and most fun sections to make. Shotcut is my video editing tool of choice, because it's free and it supports webvfx. Since last year I've been experimenting with webvfx for the telemetry overlay of my pargliding videos. There are issues here and there, but overall it's a great tool. I tried two new video filters, Sketch and Cartoon. Sketch worked well, and I applied it to the video. Cartoon didn't. Spiral The spiral scene is apparently the most important one. At some point I came up with this joke id...

记忆中的音乐寻宝

编程的各个环节中,我最喜欢的恐怕是调试,尤其是调试不熟悉的代码,比如逆向工程。从某些方面来说,调试就是侦探的工作,慢慢收集线索,整理思绪,利用推理和想象力找到真相。我很享受收集情报,然后逐渐从无序变成有序的过程。 而音乐搜索则对我一直是一大难题,想起一段熟悉的旋律,或者听到陌生而优美的曲子,我总是很急迫的想知道曲子是什么,找到完整的曲子,或者乐谱。但是音乐搜索恰恰又很困难,有歌词还稍微好一点,没有歌词有主旋律也可以试试哼唱检索。但是一些多声部,或者复杂一些的曲子就没办法了。随着时间推移,有时连旋律都忘了,只记得“有那么一段优美的旋律,而我不知道它叫什么”,如鲠在喉。 前阵子同事跟我提到Google App的音乐搜索功能,虽然之前也知道这个功能,但其实都是偶然触发,并没有想搜音乐。后来去麦当劳时,觉得BGM挺好听,就用Google App搜了一下,虽然由于周围环境噪音的原因总是不能捕捉到声音,不过最后我像傻子一样把手机高举过头顶,还是一次就找到了结果:  Lianne La Havas - Lost & Found 话说到这,就刚刚我又想起另一个麦当劳放的曲子,由于有歌词,没花多久就找到了: Alex Winston - Sister Wife 前几天别人发我一个Youtube视频,我对BGM很感兴趣,也是很容易就搜到了:Dr Dre - The Next Episode。跟她提起这个音乐时,我猛然想起自己的一个“有那么一段优美的旋律,而我不知道它叫什么”的回忆。然而我已经完全不记得曲子的旋律,以及在哪里听到这个曲子了。当然一旦听到曲子我肯定能发应过来。我总觉得人的记忆是单向hash,比如四句的唐诗,给出第二句背第三句就很容易,反过来就难很多。 决定试一下再次挑战,因为我觉得如果能再次找到这个音乐,Google App八成能搜出来名字。 一开始发散思维,回想是哪里听到的。这是最难的一步。冷静了一会儿想到那是一个找不同的游戏。于是第一反应是去Kongregate上找,搜到的找不同游戏只有三个(别的都不太像),为了找到BGM也只能全都通关一遍。好在游戏都不太长,并且游戏也不错。顺便也搜了一下游戏的BGM,很有趣。不过不幸的是那段音乐不在这几个游戏中。 说到这种枚举的事情我也不是第一次做了。小时候玩的FC游戏Moon Crystal...

变色龙代码

最近的新玩具: https://github.com/coolwanglu/quine-chameleon 受mame的100个语言的quine-relay的启发,我想可否做一个完全图,即多个语言互相转换。 这样的程序英文叫multiquines,Wikipedia上有介绍,程序运行时需要指定一个参数,比如输出语言,然后程序会输出自身代码的对应那种语言的版本。如果指定参数就是这个程序源代码所使用的语言,那就是quine了。 网上有一个5种语言的multiquines,我看了看,不是太优美。我一开始就是朝着multiquines的方向写。然而后来注意到,不指定任何参数的时候对multiquines来说是没定义的(或者什么都不应该输出),这个有点浪费,于是我做了ouroboros(就像quine-relay那样)和随机转换两种模式。 再后来我注意到反而是不指定参数这部分更有趣,而且为了同时支持带参数和不带参数,需要各种判断,造成代码臃肿。于是我就把这两部分拆开,目前在源码中分别叫chameleon.*和multiquines.*。分别进行优化。 写这个东西最大的乐趣当然是不断加入新的语言。我开始不久就把自己熟悉的语言放进去了,然后慢慢添加新语言,不会的就现学现卖。基本上需要的语言特性和函数有如下几个 - 支持双引号定义的字符串,支持反斜杠转义 - 将字符串按分隔符切成数组 - 生成随机数 - 支持命令行参数 - 数组查找 - 字符串转义,或者json输出,或者字符串/正则式替换 - 输出(不带换行) 按目前的设计,第一条决定了一个语言是否能很容易的加入。这里比quine-relay难的地方在于,任何两个语言都要互相输出,所以最好能有一个公共的转义和还原的标准。而quine-relay中每个语言只需要考虑下一个语言的转义就好了,更方便预处理,支持新语言(比如whitespace,brainfuck)以及其他特性(比如字符串压缩) 我在写这个玩具的过程中也很自然的学习了一些新语言。之前为了写dunnet.js而研究了emacs lisp,这里还加入了其他lisp系列比如clojure,racket,发现写写脚本也还挺顺手的。只可惜scheme由于标准库太小以及srfi实现不统一没能加入。另外就是接触了之前完全不想接触的perl和aw...

NetHack 网页移植

最近在试图把NetHack移植到网页上,名曰 BrowserHack 。目前功能上基本完成了,还剩下界面调整和修复bug。 NetHack我很早就有耳闻,简单尝试一下不太喜欢它的字符界面。其实我小时候很喜欢玩SuperZZT,现在也还行,不过比较来看SuperZZT还是象形,而NetHack的字符界面就是会意了,还是蛮需要想像力的。 NetHack自然也有各种图形界面移植。以前也是没有深入尝试过。这次移植正好也研究了一番,没想到很快就入迷了,令我之前玩过的RPG游戏顿时黯然失色。 这游戏有两个特点,其一是系统和操作非常复杂,各种奇怪的命令,让我不禁想起了文字冒险类游戏。不过配合地图和帮助,这不是问题。里面物体和各种交互也非常复杂,武器放水里会生锈,地面上各种暗门陷阱,怪物的AI,无不体现出设计者的用心。另一个特点是,按Wiki的说法是这个游戏最难在于初期,这在现代游戏里也是不多见,这可能让我一开始有点望而却步,但是熟悉了几本操作以后,每次重玩都能很快上手进入状态,开始刺激的冒险。专门有一片文章讲“为什么我死了又死还是死?”,按现代游戏的玩法,一上来就横冲直撞,很快就死了。如果考虑现实生活中的探险,每一步前进必定是小心翼翼。 反观现代游戏,显示技术不断提高,似乎大多数游戏都把精力放到显示效果去了。虽然显示技术能极大提高游戏吸引力,NetHack换了几个主题我也是非常兴奋,但是玩家不是傻子,游戏本质如果弱智还是没法玩。此外,现在游戏的难度与老游戏也是没有可比性。大多数游戏难度都是循序渐进的,各种教学关卡。当然这是改进了,可是很多游戏设置了各种弱智的成就,欺骗大脑的奖励系统,感觉是把玩家训练成傀儡。 NetHack也有各种不错的移植,比如Steam上的Vulture for NetHack。有如此强大的游戏核心,再辅以美观的画面和易用的操作,真是绝了!

Studying Metal Slug's Engine

There's a Debug Menu in many titles from the Metal Slug series. Today I played around with that debug menu in Metal Slug X, especially I turned on 'body rect' and 'attack rect', which revealed how the game works. Now not only did I have tons of hours of fun, I also studied a lot from this amazing game! Of course the following are only my observations, or my best guess on how they have been implemented the game. Although I think my interpretation should work, but it's definitely not the only way, and it's quite possible that the developers have achieved the same effect with another (maybe better) method. First Impression At the first glance, the debug drawing is far cleaner than I had expected, it seems that it's not tiled based physics at all. But note the thin shadowed area below the line, which may imply that it's still using tiled based calculation somehow. Edges The ground is described as line segments, from the way the ...

Notes

surface pro stylus calibration http://www.reddit.com/r/Surface/comments/18cd96/improved_pen_accuracy_with_a_100_point/ http://www.reddit.com/r/Surface/comments/1cy8hn/this_pen_calibration_is_so_far_the_best_solution/ Search for 'UserLinearityData' in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet and remove 'devicekind=pen'   merge tool: meld   linux虚拟机的硬盘大小不够,扩容以后又调整了分区,于是grub就不能进入了。启动说unknown filesystem然后进入grub rescue。 根据 http://askubuntu.com/questions/142300/fixing-grub-error-error-unknown-filesystem 在grub rescue输入 set prefix=(hd0,5)/boot/grub insmod linux linux (hd0,5)/boot/vmlinuz-3.11.0-15-generic initrd (hd0,5)/boot/initrd.img-3.11.0-15-generic boot 然后grub这步正常了,但是会卡到initramfs/busybox,说找不到init 于是在linux命令后面加上root=/dev/sda5就可以正常进入系统 进入系统以后赶紧用grub-install和update-initramfs再修正一下。

Converting synced C/C++ into asynced JavaScript

Emscripten is a C/C++ -> LLVM -> JavaScript compiler. It's useful and interesting, but one of its biggest limitations is about the sync/async model: JavaScript is single-threaded event-driven languages, therefore you cannot do a sleep() in the hope of receiving and processing extra events. Demo First of all, please enjoy this demo , on which I really spent some time. tl;dr Motivation: to make `sleep` and other similar functions actually work in our Runtime, without lots of labor work porting the C/C++ code I actually made it worked  `sync->async` is doable and I think it's not too hard - there are already implementations for JS I think this is a feature that cannot be supported by merely an external library Does it fit emscripten? Or is it possible to write a plugin for emscripten? Demo explained(?) The demo is basically a stop-time animation: //draw something //wait for some while //draw something else //wait... You can verify this ...