01 2013 档案
摘要:游戏中经常需要玩家与环境互动,比如开门动作、射击动作等。常用的互动方式有三种,碰撞检测、光线投射和碰撞检测触发器。以开门这个简单动作为例, 碰撞检测(Collision detection) 当玩家与门的碰撞体发生物理碰撞时触发开门动画。若门的碰撞体与门一样大,这会导致玩家贴着门时门才会打开,感觉门是被撞开的。若门的碰撞体比门大,使得玩家与看不见的碰撞体发生物理碰撞,...
阅读全文
摘要:在C#和Python中都有GC,但是它们的实现完全不同。C#用的是传统的垃圾回收机制,主要是寻找能够从根集达到的对象,把这些对象标记为活的,然后清理其余对象;Python由于支持扩展模块(C/C++等),他的根集很难找全,因此Python使用引用计数机制来做垃圾回收。引用计数就存在循环引用的问题,参见How Python GC deal with reference-cycles? ...
阅读全文
摘要:Python的super()在多继承下的方法推导顺序(MRO, Method Resolution Order)涉及到C3线性化算法(C3 linearization wiki)。其中关键是, children precede their parents and the order of appearance in __bases__ is respected. 例子, ...
阅读全文
摘要:>>> def a():... print "a executed"... return []... >>> >>> def b(x=a()):... x.append(5)... print x... a executed>>> b()[5]>>> b()[5, 5]Actually, this is not a design flaw, a...
阅读全文
摘要:The supplemental garbage collection facility, however, is enabled by default and should be able to free that structure, if none of its components are reachable from the outside anymore and they do not...
阅读全文