从制作一个自行车公里计数器说方法莫道不消魂

我主要想focus在思路上,

这其实是一个方法莫道不消魂论的问题,抽象到更高一层可应用到其它很多的场合中,决定于抽象的程度

直观Focus型

我们会很直接的将目光聚焦到事物表面上,很自然的会想到(这仅仅是我的猜测而已)

  • 路程=周长*转数

周长直接可得,设置一个记录转数的装置,至于这个装置应该怎么设计呢?

方式可以有很多,譬如前架上设置一个装置,车轮的杆上也设置一个装置,类似光学接收仪, 每转一圈就会记录一次

当然,还有很多种入手的方式,譬如从车轴入手,用一些电板

再或者,将想法脱离事物的直观层面外,即到车轮之外,

譬如从脚踏板入手,脚踏板每转一圈都与车轮相关,这里也有着某种想法,

譬如记录脚踏板的转的次数,怎么记录?同样有着车轮的构造,很多想法可以借鉴过来,

抽象来说:

可以说是寻找我们需要的变量(这里是公里数)影响到的参数,包括所有周边环境的所有参数、因数,无论是正相关抑或是负相关,又或者是影响我们所求的参数的可能性

Details »

Small snippet code and techni I used for a recent project

Function Reduction:
Here's a situation,I have to play a sound while 2 objects is in a collision,the problem is that there's plenty of objects in collision at the very same time,We want the sound to be played one by one
So,I have to cancle the previous(the excuting function)

function reduceFunc(func,context){
  clearTimeout(func.methodID);
  func.methodID=setTimeout(function(){
    func.call(context);
  },20);
}

Garbage Optimization:
While reset the an array , I tend to make it as usual like

arr=[]

Because everytime we restart a game , every global array will have to be reset to empty,
So , with the aim of reducing the garbage,Instead ,I set

arr.length=0

Similarly,while we have to new an object ,I learned from Box2D

Box2D.Common.Math.b2Vec2.Get = function(x, y) {
    if (Box2D.Common.Math.b2Vec2._freeCache.length > 0) {
        var vec = Box2D.Common.Math.b2Vec2._freeCache.pop();
        vec.Set(x, y);
        return vec;
    }
    return new Box2D.Common.Math.b2Vec2(x, y);
}; Details »

Wake up 5.XX am to code

Recently,I decided to redesign PangTingMe--a project I was started while I first learned javascript,I was first inspired by a post from HN,the guy wake up 5 am to start his personal project.So,I try it on my own!

check it out from github
Reindeer
and check for the static demo :
PangTing.me

A small tech summary of building the prototype of PangTingMe:
About the server side:
I used Rails to build a simple RESTful Service,return JSON format data by different URL
It's simple but I learned a lot these days,rails is awesome!
About the client side:
This is where heavy works happen,I make myself a small MVC front-end architeture
The whole logic can be divided to 4 main object

--DataContorller
--UI
--Functionality
--pangting

I defined some basic URL router in Funtionality Details »

After Guangzhou Triennial Round one ...

这次的作品很多我都非常喜欢
仅仅对于作品设计本身,本身就有很多的想法都是可以相互转化的,很多时候我都努力透过事物现象看本质,每次看着不同作者制作出来的不同作品的时候,我都尝试着通过他们的作品走进他们的精神领域,了解他们的想法

关于民瑞脑消金兽

首次看的时候感到教有点软,我是有点晕血的...很多时候都发现自己很难了解他们的想法,有想到:怎么他们会有这种想法的,太有“趣”了。
(此处貌似被和谐掉巨多部分,不解释
看来还是得找个国外的空间,自己搭建一个)

金玉其外败絮其中 Details »