Sunday, December 30, 2012

Design Patterns-Object Oriented Design

Oject Orient Design:提到SOLID(WIKI)

包含了6個原則,原則通常會隨著專案可能會違背這些原則,但這些原則可以幫助你在設計時所要考慮因素,為何要違背某一原則?是為了其他類別?在這專案下違背了影響層面很小?

Saturday, December 22, 2012

Desing Pattern–Overview

Design Pattern:

    如果發現處於某種情境下,面對著一群限制的問題,正影響著所欲達成的目標,然而,你能夠採用某個設計,克服這些限制並達到該目標,將你領向某個解決方案。
問題
情境
解決方案
模式是一種被證實過的設計經驗,可以避免某些常見的錯誤。
模式是共通詞彙,能夠讓我們和其他開發者之間,針對設計進行溝通。

Saturday, December 15, 2012

Design Patterns-Command Patterns

將一個請求封裝為物件,讓你可用不同的請求對客戶進行參數化。對請求排隊或記錄請求日誌,以及支援可取消的操作。

Wednesday, December 12, 2012

Windows Socket & C++ Basic UDP Socket

UDP Socket

1.之間不用建立連線

2.對客戶端來說建立socket後,直接把資料丟向Server

Monday, December 10, 2012

Windows Socket & C++ Basic TCP Socket

TCP server/Client Basic

TCP

TCP連線

重構-Code Refactoring-Vol.2

1.Replace Temp with Query

2.Introduce Explaining Variable

3.Split Temporary Variable

4.Remove Assignments to Parameters

5.Replace Method with Method Object

6.Substitute Algorithm

Design Patterns-Singleton Pattern& Thread

Singleton Patterns

保證一個類別僅有一個Instance,並提供一個全域訪問點。

1.該物件自行決定是否被Instance,而不是靠其他物件初始化。(將該物件的Constructor需告成Private)。

2.因建構子私有化,所以產生一個Method為公有化(物件為Publuc 、Static)。

Sunday, December 9, 2012

Windows Sockets & C++

網路程式-C/S、B/S

Client/Server:C/S

1.Client將需求傳遞給Server,再將Server回傳的結果已一定形式提供給使用者。
2.Server通常處於休眠狀態,直到客戶端對該伺服器發出連線請求,將其喚醒。

Browser/Server:B/S

1.客戶端執行瀏覽器,瀏覽器以超文字形式向Web伺服器提出存取資料庫請求。
2.Web瀏覽器是客戶端主要的軟體,系統功能實作的核心部分集中到伺服器上。

Friday, December 7, 2012

Component-based Development & XNA & Design Patterns

他強調把程式碼的功能性分開的軟體開發過程。

Component based Programming在遊戲引擎裡被廣泛得運用,如Unity3D:

ComponentUnity

Component Based Programming由三個主要構成:

System: 處理Render、Physics、Particle。

Entries:又稱為GameObject,出現在遊戲引擎畫面上的物件(游標、地板…等)。

Component:一個Entries可能會包含數個Componets,為這物件添加功能如Box Collider(物件碰撞網格)、Mesh Renderer(Render畫面)。

Thursday, December 6, 2012

Design Patterns-Memento Pattern

備忘錄模式-在這如果我想做一個遊戲,以RPG來說,在進入遊戲戰鬥時我可以讓玩家選擇重新開始這場戰鬥,就像FFXIII玩家可以在戰鬥中隨時重新挑戰怪物更高分數、不同打法,

那該如何儲存腳色能力?

Monday, December 3, 2012

重構-Code Refactoring Principles


Why Code Refactoring Work:

1.難以閱讀的程式,難以修改。
2.邏輯重複,難以修改。
3.添加行為時需要修改現有程式碼,難以修改。(同時違反Desing Patterns:Open Close Principle)
4.複雜條件邏輯程式,難以修改。



Indirection and Refactoring:

1.Enable sharing of logic

一個sunmethod在兩個不同的地點被呼叫,或是superclass中的method被subclasses共享。

2.To explain intention and implementation separately:

選擇每個Class和Method的名字,來解釋自己意圖的機會。Class或Method內部解釋和實現這意圖的做法。

3.To isolate change:

在兩個不同地點同時使用同一個物件,其中一個地點想改變物件行為,則產生"同時影響兩處"的風險。為此可做出一個subclass,並在需要修改處引用這個subclass,這樣就不必承擔這風險。


4.To encode conditional:

利用polymorphism,可以靈活彈性而清楚地表達條件邏輯。(Desing Patterns:strategy pattern)。

重構是為了"未來"而不是為了"當下"。


Don't Do Code Refactoring when Project is reach Deadline.

從重構過程贏的生產力只有在最後期限過後才能夠體現出來,所以當專案已近最後期限,避免重構。

Tuesday, November 20, 2012

C++&CLR&CLI&MFC


CLR 共通語言執行環境:

1.提供一個標準化且提供 Visual Basic、C#、C++多種高階語言撰寫之程式執行環境。
2.可以使用.Net Framework相關的DLL,CLR一定要裝.Net Framework。

3.寫出得Dll 可以直接被 Visual studio參考。

CLI共通語言規範:

1.CLR就是實作Microsoft的 CLI。
2.CLI 實質上是一個 Virtual machine,讓高階語言撰寫的應用程式,可以在不修改及重新編譯原來的原始程式碼之情形狀況下,於不同的系統環境中執行。

3.CLI 可以開發有關 CLR和MFC得技術。

MFC Microsoft Foundation Classes:

1.不需要安裝.Net Framework,換句話說不能使用 .Net Framework 的Dll

CLR

using namespace System: //使用.Net Framework的DLL
Console::Write(L"ASD");

int^ 、String^
可追蹤的Handle: (C++/CLI 環境下)
儲存位址,並且當堆積(Heap)做記憶體空間重整,移動其所參考的物件時,記憶體回收機制會自動更新儲存的位址。
CLR陣列跟C++陣列不同。
array^
也可
array^ 字串陣列,其元素是Handle 可追蹤。


C++


nullptr 常用於把指標指定成null。(指定成0,其不夠直觀)

int* pNumber(nullptr);




Friday, November 16, 2012

C++ & MFC Practice


MFC 應用程式

建立應用程式類別

1.繼承CWinApp
2.直接使用CFrameWnd 類別產生視窗


專案設定:

MFC的使用 : 使用MFC靜態程式庫
字元集:使用多位元組字元集
#include

class MyApp: public CWinApp
{
public :
BOOL InitInstance()
{
CFrameWnd *Frame = new CFrameWnd();
m_pMainWnd = Frame;

Frame->Create(NULL,"Hello MFC");
Frame->ShowWindow(SW_SHOW);
return true;
}
};
MyApp a_app; //Build Application

---------------------------------------------------------------------------------------

VC++ Window API

                                WindowAPI
                                   |           |
                       WinMain()      WindowProc
                                                          程式起始                                 訊息


WNDCLASSEX: 定義視窗。
ZeroMemory:設定應用程式位址。
決定視窗所有屬性。
處理視窗訊息。WindlwProc
Ready to initialize DirectX 3D.



#include
#include

LRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrvInstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hWnd;

WNDCLASSEX wc;

ZeroMemory(&wc,sizeof(WNDCLASSEX));

wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.hInstance = hInstance;
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszClassName = L"WindowClass1";

wc.cbClsExtra = 0;
wc.cbWndExtra = 0;


RegisterClassEx(&wc);

RECT wr = {0,0,500,400};
AdjustWindowRect(&wr,WS_OVERLAPPEDWINDOW,false);
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hIcon = LoadIcon(0,IDI_APPLICATION);

hWnd = CreateWindowEx(NULL,
 L"WindowClass1",
 L"Our First Windowed Program",
 WS_OVERLAPPEDWINDOW,
 300,300,
 wr.right - wr.left,
 wr.bottom - wr.top,
 NULL,NULL,
 hInstance,NULL);

ShowWindow(hWnd,nCmdShow);

MSG msg;

while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch (message)
{
case  WM_PAINT:
HDC hDC;
PAINTSTRUCT PaintSt;
RECT aRect;
hDC = BeginPaint(hWnd,&PaintSt);
GetClientRect(hWnd,&aRect);

DrawText(hDC,L"First Window SDK Programing With D3D",
-1,&aRect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hWnd,&PaintSt);
return 0;

case  WM_LBUTTONDOWN:
break;

case WM_LBUTTONUP:
break;

case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}break;
}
return DefWindowProc(hWnd,message,wParam,lParam);
}

-----------------------------------------------------------------------------------------------------------------------

Design Pattern & Software development


Inversion of Control

創立一個Interface 讓高階模組和低階模組可以共同存取溝通所需要的值。

Test Drive Development
Visual studio 2012 用法:
http://channel9.msdn.com/Events/TechEd/Europe/2012/DEV214







Sunday, November 11, 2012

OOA&D and sofeware development-Note


A.Unit Test:

Test Drive Development,TDD:1.先了解User Case、User Stroy,其結果。2.Unit Test 不包含邏輯。3.測試成功在實作程式碼。4.程式測試其結果而不是Developer做測試。5.Code Refactroing。

B.(Inversion of Control,IoC)

1."降低類別或模組間的耦合度"。2.Dependency Injection。
3.Game Development: Reference Manager。
4. Low Coupling。

Memory Leak:
C/C++並沒有Garbage Collection,手動釋放資源 Null、移除參照。
C#、Java也可能會發生。
1.
宣告指標變數時一律給予初值。2當delete某指標後,其務必將其內容設為NULL。

Thursday, October 4, 2012

Appendix A-Import Custom Model With Script

1.SetUp CustomGameInfo.
2.Using RestartPlayer(Controller) Function.
3.Seting variable(SkeletalMesh MaterialInterface
   AnimTree array<AnimSet> AnimNodeSequence PhysicsAsset).
4.Call the function.

Wednesday, October 3, 2012

Tuesday, October 2, 2012

UDK-Toturial-CH6.UnrealScript-Enemy And GUI

1.Expand Our Enemy.
2.Write Score on Screen.(Dont Use Scaleform now)
3.Spawn Actor(Enemy).

Friday, September 28, 2012

UDK-Toturial-CH5.UnrealScript-GameRule

1.End the game rule.
2.Simple Enemy.(Static)
3. Expand Player Pawn.
4.Expand Enemy,Bump Event

Thursday, September 27, 2012

UDK-Toturial-CH4.UnrealScript-Weapon


1.CustomWeapon
2.Weapon Projectile
3.Upgradeable Weapon
4.Class Modifier
5.Show/Hide Categories

Tuesday, September 25, 2012

UDK-Toturial-CH3.UnrealScript-Camera

1.SetingUp GameInfo.
2.Get Viewport.
3.Dissable Crosshair,default gun,fix rotation to fit Pawn angle.
4.CustomPawn,Isometric Camera.
5.Top-Down Camera.

Monday, September 24, 2012

UDK-Toturial-CH2.UnrealScriptBasic

1.How to Print a log
2.Script Usage
3.Unreal Game Flow

UDK-Toturial-CH1.UDKSettingUp

UDK_Toturial Serial  it would be updated slowly.......
This is talking about how to set up script and some tool.

1.Download UDK.
2.ConTEXT and set up environment.
3.Setting Script Package Path.

Saturday, July 7, 2012

PlayStation Mobile SDK–Draw Texture

If i dont use “GameEngine2D”(Sce.Pss.HighLevel.GameEngine2D) ,then i need serveral steps to do.

PlayStation Mobile SDK

最近Sony 發佈了PlayStation Moblie SDK,所以就來快速的試用一下吧。

Wednesday, March 28, 2012

UDK-Kinect Using OpenNI for UDK

When we use Kinect,there are two choose,one is openNI another is Microsoft Kenect for Window

Saturday, March 17, 2012

Unreal Development Kit–Basic 1– Book Note

UnrealDevelopment Kit Game Programming with UnrealScript: Beginner's Guide

ISBN:9781849691925

Thursday, March 15, 2012

Farseer Physis Engine-Installation Note

Farseer Physis Engine 是一個可以適用在XNA 和 Window Phone 的物理引擎

Wednesday, March 14, 2012

Tutorial-Draw A Line At XNA(Window Phone)

如果沒有使用 DrawPrimitive Methods做的話,XNA 並無提供簡單產生出一個線段,因此在這裡提供一下簡易 2D線段的方法。

 

Friday, March 2, 2012

Books

UDK:

Unreal Development Kit Game Programming with UnrealScript: Beginner's Guide
ISBN-13: 978-1849691925
http://www.amazon.com/dp/1849691924/?tag=packtpubli-20

Kinect:

Beginning Kinect Programming with the Microsoft Kinect SDK (Paperback)
ISBN: 1430241047

Chinese

半路叛逃-App 遊戲製作人的 1000 日告白 - Taiwan Indie Game Developer's Book
ISBN: 9861993649  出版日期: 2012-09-29

Wednesday, February 29, 2012

XNA-The snapshot is out of date and can not be used anymore because the binder has been updated

Solution-
Here is my problem.When i was  using Team Foundation Server(Source Controller) with my window phone's project(XNA),It's don't happen.
After i install a plugin "Productivity Power Tools" the problem is appear.I google it and found there is a solution and it's solve my problem:

Turn Off the "Automatic Brace Completion" at Tools->Options->Productivity Power Tools

Maybe turn off some plugin you could found the problem.

Tuesday, February 28, 2012

C#-Note: Internal


成員所屬型別 成員預設存取範圍 成員允許的宣告存取範圍
enumpublic
classprivatepublic
protected
internal
private
protected internal
interfacepublic
structprivatepublic
internal
private
internal只可以被本組合體(Assembly)內所有的類存取,組合體是C#語言中類被組合後的邏輯單位和物理單位,其編譯後的文件擴展名往往是“.DLL”或“.EXE”。 


MSDN範例:

internal class BaseClass
{
   public static int intM = 0;
}



class TestAccess
{
     static void Main()
     {
         BaseClass myBase = new BaseClass(); // CS0122
     }
}


如果在第二個檔案中嘗試產生BaseClass,將會產生錯誤。

將BaseClass 存取級別變為Public
將成員intM 存取級別變為Internal


public class BaseClass
{
    internal static int intM = 0;
}



public class TestAccess
{
    static void Main()
    {
      BaseClass myBase = new BaseClass(); // Ok.
      BaseClass.intM = 444; // CS0117 Error
    }
}


如此一來您可以將類別具現化,但無法存取內部成員。

Sunday, February 12, 2012

Team Foundation Server - Installation Note

1. Installation OS
       Window 7
       Window Server 2008 (recommend)
2.IIS service
     控制台->程式和功能->開啟或關閉Windows功能
      Check Internet Information Services
                  Internet Information Services Web核心
3.Installation Window SQL Server 2008 R2
      Add administrator and password
4.Installation Team Foundation Server 2010
5.Installation Visual studio 2010

Done
-----------------------------------------------------------------------------
Team Foundation Server Basic



Check-in:Upload your code to Server

Shelve And UnShelve:程式碼完成一半,暫時擱置,同時其他人也可以取得Shelve的程式碼並修改。

Branch(分支):將已完成的版本,建立新的分支,同時開發舊的版本與新的版本。
                       PS.After Branch you need Check-in again

Merge(合併):將舊版與新版合併


衝突發生:

也可先使用Shelve



Lable:標記程式碼版本




-----------------------------------------------------------------------------
Visual Studio 2010 hotkey Note

alt + shift :多行同時輸入
alt + mouse Left Drag:一次編輯多行





-----------------------------------------------------------------------------
Reference: