- 博客(45)
- 收藏
- 关注
转载 Unity 异步网络方案 IOCP Socket + ThreadSafe Queue
Unity IOCP Socket + ThreadSafe Queue1.Socket.BeginReceive系列接口在unityweb下是不正常的,页面刷新会导致问题2.自己维护线程,会带来一点小麻烦3.下面采用iocp+threadsafequeue 来实现异步网络```public class UserToken{ public ...
2015-06-03 14:49:00
318
转载 unity 四元数, 两行等价的代码
Vector3 tmpvc;1. tmpvc = Quaternion.Euler (new Vector3 (0, 30, 0)) * new Vector3 (0, 0, 1);2. tmpvc = new Vector3 (sin (30.0f), 0, cos (30.0f)); transform.position = target.tra...
2015-02-09 15:29:00
124
转载 golang的项目结构 相关知识
### 项目结构```├── bin│ ├── login│ └── main├── pkg│ └── darwin_amd64│ └── login│ └── auth1.a├── src│ ├── cfg│ │ └── testcfg.go│ ├── db│ │...
2015-01-31 16:48:00
122
转载 stencil in unity3d
Pass { Stencil { Ref 1 Comp Always Pass REPLACE } AlphaTest Greater 0 Blend Sr...
2015-01-29 17:04:00
97
转载 一段tcl代码
#!/usr/bin/wishproc icanspeak {} { set name [.ent get] if {[string length $name] != 0} { exec s $name }}label .lab -text "Enter word:"entry .entbutton .but -...
2015-01-26 23:16:00
124
转载 16_游戏编程模式ServiceLocator 服务定位
####简单说,就是某个系统作为一个服务,对全局系统可见.Service Locator (服务定位)```//简单粗暴的代码, 使用声音系统// Use a static class?AudioSystem::playSound(VERY_LOUD_BANG);// Or maybe a singleton?AudioSystem::in...
2015-01-21 15:09:00
71
转载 15_游戏编程模式EventQueue
#### 两个例子1.GUI event loop```while (running){ // 从事件队列里获取一个事件 Event event = getNextEvent(); // Handle event...}```2.Central event bus 不同系统公用的通信中心 #### ...
2015-01-21 13:31:00
72
转载 14_ Component 游戏开发组件模式
# component不同作用的程序需要保持互相隔离我们不想ai 物理 渲染 声音 等等功能 耦合在一起,像下面这样```//bad if (collidingWithFloor() && (getRenderState() != INVISIBLE)){ playSound(HIT_FLOOR);}```一个 e...
2015-01-20 18:17:00
154
转载 11-13 游戏编程行为模式
### Behavioral Pattern#### interpreter pattern string -> code instruction set: 提供基本操作virtual machine: 执行指令front-end: 生成效率更高的字节码```void setHealth(int wizard,...
2015-01-20 17:38:00
68
转载 MonoBehavior lifecycle
awake 只调用一次, awake在所有obj都初始化之后被调用. 用途: 初始化游戏状态 设置脚本间的引用 ### ExecuteInEditMode 编辑模式下```这个模式下,脚本编译,会自动reload[ExecuteInEditMode]public class Lif...
2015-01-20 15:38:00
87
转载 8_游戏循环
```while (true){ Event* event = waitForEvent(); dispatchEvent(event);}while (true){ processInput(); update(); render();}```游戏循环在游戏运行期间一直执行,每次循环,会处理用户输入,更新...
2015-01-20 14:22:00
134
转载 rust ownership 系统
### 对象销毁规则1 未被使用的函数返回值2 被let绑定的值, 在函数末尾销毁,除非被moved```let v = obj::new("a");other_fun(v); // v被move了, v在other_fun里面销毁,而不是当前函数的结尾```3 被替换的值将销毁```let mut v = obj:new("a");v...
2015-01-19 18:01:00
96
转载 7_DoubleBuffer 游戏编程中的双缓存模式
### double buffer 双缓存简单说: 当一个缓存被读取的时候,往另一个缓存里写入, 如此交替#### the pattern有两个缓存实例,一个是 current buffer, 一个是next buffer从current buffer读取信息, 往next buffer里写入信息.swap操作,进行两种buff的身份切换#...
2015-01-17 17:24:00
172
转载 docker 基本概念
image 操作系统 应用registeries image 的远程仓库containers 类似一个目录,一个容器包含了 应用运行所需要的一切东西, 容器之间互相独立 image包换一系列的层,使用Union file systems把这些层组合在一起,对image的修改,只用修改层,不用重新构建...
2015-01-17 11:20:00
74
转载 6_State 游戏开发中使用状态机
### State不好的代码```//处理玩家输入的代码void Heroine::handleInput(Input input){ if (input == PRESS_B) { if (!isJumping_ && !isDucking_) { // Jump... } ...
2015-01-16 18:08:00
90
转载 5_Singleton 游戏开发中的单例模式
1 强制类只有一个实例2 提供全局的访问###为什么使用:```1 如果没有地方访问这个类,则不会创建实例2 静态类在main之前实例化, 可以尝试Lazy initialization3 派生单例类, 获得单例能力```###缺点:```1 代码变得难懂, 上下文切换等等2 增加了耦合度3 并行不友好4 惰性初始化 ...
2015-01-16 17:48:00
78
转载 4_Prototype 原型
#Prototype```// 不好的做法 monster ghost demon sorcerer class Spawner{public: virtual ~Spawner() {} virtual Monster* spawnMonster() = 0;}...
2015-01-16 17:20:00
67
转载 3_observer
#Observer成就系统achievements system玩家完成某种成就后,通知监督者,监督者做出相应出来```//简单来说就是事件触发的时候, 通知监督者class Observer{public: virtual ~Observer() {} virtual void onNotify(const Entity&...
2015-01-16 16:54:00
97
转载 2_flyweight, 轻量化模式
### instanced rendering.send shared data to gpu just once mesh, texture, leavespush every instance’s unique data position, color, scaleWith a single draw call, an entire fores...
2015-01-14 17:05:00
94
转载 1_Command 游戏开发命令模式
A dead simple implementation looks like:```// simple void InputHandler::handleInput(){ if (isPressed(BUTTON_X)) jump(); else if (isPressed(BUTTON_Y)) fireGun(); else if (isPr...
2015-01-14 16:24:00
237
转载 unity3d: how to display the obj behind the wall
透墙显示,遮挡显示,使用ztestTags { "Queue"="Overlay+1" "RenderType"="Transparent"} Pass { // 透视效果,关闭cull Cull Off // 不记录深度值 ZWrite Off ...
2015-01-14 08:29:00
94
转载 unreal network
frame move buffer: save move positionrecive server sync:All moves earlier than the ClientAdjustPosition() call's TimeStamp are discarded. All moves that occurred after TimeStamp are then re-run...
2015-01-13 18:22:00
122
转载 rust borrow and move
extern crate core;#[deriving(Show)]struct Foo { f : Box<int>}fn main(){ let mut a = Foo {f: box 0}; let y : &Foo; // out(&a); { ...
2015-01-12 18:43:00
186
转载 erlang的map基本使用
maps 适用于需要在运行时改变数据结构(record则不行)的场景,可以动态增加key 数据量不宜过大,具体多大没有实际数据, maps from_list 如果list表很长,则相应的耗时时间会很长,此时最好用lists模块。 由于map是动态结构,速度上必然无法匹敌record。内存大小介于tuple与list之间...
2015-01-12 11:52:00
348
转载 unity3d mvvm c#
using UnityEngine;using System.Collections;public interface IState { void BeforEnter(); void BeforLeave();}public interface ISceneState: IState {}public class GenF...
2015-01-06 23:21:00
114
转载 dead reckoning variation
TargetingA target is a structure of information that describes the state, and change of state, of an object that exists in a remote person's instance of a game.When you fire your laser, you s...
2015-01-05 16:11:00
101
转载 关于游戏网络延迟的资料
client-serverthe server takes snapshots of the current world state at a constant rate and broadcasts these snapshots to the clients.server -> snapshot -> clientserver <- userin...
2015-01-04 14:40:00
128
转载 u3d 多线程 网络
开启一个线程做网络连接,和接收数据, 用event进行广播using UnityEngine;using System;using System.Threading;using System.Net;using System.Net.Sockets;using System.Collections;using System.Collections.Gene...
2014-12-23 11:10:00
118
转载 尽量写纯函数
尽量写纯函数, 不纯的容易产生bug.转载于:https://www.cnblogs.com/lightlfyan/p/3912119.html
2014-08-14 11:18:00
99
转载 音频知识1
采样频率: 每秒采样次数, 记录声音的音高采样质量: 用多少字节来表示音高, 16位可以表示256中音高analog: 模拟digit: 数字adc: 模拟-数字转换dac: 数字-模拟转换关于44100hz早期的录像带, 没每个视频帧有245条扫描线, 红绿蓝3个样本, 每秒60帧245 * 3 * 60 = 44100...
2014-08-12 15:25:00
71
转载 逃出认知偏差
那么多的认知偏差,如何避免呢. 首条原则是 要反对自己,然后反对认同自己的人, 思考相对立的观点. 这样可以避免一大批认知偏差. 转载于:https://www.cnblogs.com/lightlfyan/p/3833232.html...
2014-07-09 11:36:00
88
转载 怎么面对游戏延迟
看过一些相关的文章还有书籍, 得到一个原则。a与b 进行对战,尽量采取双方都满意的结果。a攻击b, 发送攻击信息,而不是结果,由b来判断时候击中a给b加血,不管怎么样,都给他加上转载于:https://www.cnblogs.com/lightlfyan/p/3788548.html...
2014-06-14 18:54:00
71
转载 Where to Go From Here
Where to Go From Here转载于:https://www.cnblogs.com/lightlfyan/p/3784479.html
2014-06-12 18:35:00
102
转载 julia
版本还不成熟,等成熟了再完整的看看吧.转载于:https://www.cnblogs.com/lightlfyan/p/3780361.html
2014-06-10 17:17:00
68
转载 逻辑移位和算术移位
没学过汇编的估计都没听说过,学过没怎么用过的,过一阵就好记不清了...r-right l-left算术移位 sar - 保留最高位不变,其他的数移位逻辑移位 shr - 无视最高位循环移位 - ror rcr 分带进位与不带进位(cf) 两种移位,移除的数字都会进入cf, 带进位的操作相当于把c...
2014-06-05 09:33:00
79
转载 求向量投影
(复习一下)向量a, n, b, cb为a在a上的投影a与b夹角为zb = n*(b/n)cos z = b/ab = cosz*ab = n*(cosz*a/n)b =n*(cosz*a*n/n*n)b = n*(a.n/n*n)c = a - ba.b = a*b*cosZz = arccos (a*b/a.b)...
2014-06-04 20:45:00
262
转载 swift的泛型貌似还差点意思
protocol Container { typealias ItemType mutating func append(item: ItemType) mutating func removelast() -> ItemType var count: Int {get} subscript(i: Int) -> Item...
2014-06-04 17:28:00
89
转载 swift的arc 是不是有问题?
class Arctest { let name: String = "Arctest" @lazy var ret:() -> String? = { [weak self] in return self!.name } @lazy var ret2:() -> String =...
2014-06-04 14:59:00
72
转载 next enum in swift
enum Iter: Int{ case s1=0, s2, s3, s4 mutating func next(){ if self == .s4 { self = .s1 return } self = Iter.fromRaw(self.toRaw()+1)! }...
2014-06-04 11:45:00
53
转载 关于编程语言类型系统
动态 变量类型在运行期间确定下来静态 在编译期确定下来强类型 类型不会发生自动变换,弱类型 类型会自动变,比如double+int -> double类型安全 类型对数据访问有严格控制类型不安全 ...Well-typed programs cannot "go wrong" ...
2014-06-03 21:23:00
68
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人