<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>程式設計 遇上 小提琴 &#187; C/C++</title>
	<atom:link href="http://blog.ez2learn.com/category/c_and_cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ez2learn.com</link>
	<description>Victor&#039;s個人部落格，關於程式設計與小提琴</description>
	<lastBuildDate>Tue, 07 Feb 2012 03:26:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dev C++ 5.0.0.3釋出</title>
		<link>http://blog.ez2learn.com/2011/09/17/dev-c-5-0-0-3/</link>
		<comments>http://blog.ez2learn.com/2011/09/17/dev-c-5-0-0-3/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 10:49:18 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[DevC++]]></category>
		<category><![CDATA[新版]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=1564</guid>
		<description><![CDATA[還記得先前的吐嘈Dev C++用於教學嗎? 其實就在那文章張貼的時間點左右，有熱心的人替Dev C++更新了一個版本，從4.9.9.2到4.9.9.3，修了一些bug，除了那一版以外，又額外了出了好幾次的更新，每次更新都改善了一些東西，它的內建GCC編譯器更新為4.5.2，我自己在試過了之後，發現真的修掉了我列出的那些幾個最主要的大問題，雖然它的debugger對於變數顯示的功能還是很差，不過至少已經有在解決問題，並且持續改善，但我相信很多人都還是不知道有這樣的新版Dev C++可以使用，因為畢竟不是官方的更新，最近還推出到了5.0.0.3版，而且應該還會繼續更新 做為教學用的IDE，確實是小巧簡單上手的，Dev C++修掉那身臭蟲的話對於學生學習會遇到的問題也會較少，舉個例子，光是啟用除錯器，原本的Dev C++有bug，一定得到專案去設定而且還有奇怪的bug，弄半天才能進行debugging，可以參考我以前寫的 Dev C++ debugger教學 有了新版的Dev C++，要啟用debugger只要先編譯一次，再點除錯，它問你要不要加入除錯訊息，按是之後，再次按除錯，就可以進行除錯，簡化了非常多的步驟，如果你是助教或是教C/C++的老師，個人建議盡量使用這些最新版本的Dev C++ 下載最新版本的Dev C++，請到作者的部落格 Orwell&#8217;s Engine]]></description>
			<content:encoded><![CDATA[<p>還記得先前的<a href="http://blog.ez2learn.com/2011/07/08/please-do-not-use-dev-c/">吐嘈Dev C++用於教學</a>嗎? 其實就在那文章張貼的時間點左右，有熱心的人替Dev C++更新了一個版本，從4.9.9.2到4.9.9.3，修了一些bug，除了那一版以外，又額外了出了好幾次的更新，每次更新都改善了一些東西，它的內建GCC編譯器更新為4.5.2，我自己在試過了之後，發現真的修掉了我列出的那些幾個最主要的大問題，雖然它的debugger對於變數顯示的功能還是很差，不過至少已經有在解決問題，並且持續改善，但我相信很多人都還是不知道有這樣的新版Dev C++可以使用，因為畢竟不是官方的更新，最近還推出到了5.0.0.3版，而且應該還會繼續更新</p>
<p>做為教學用的IDE，確實是小巧簡單上手的，Dev C++修掉那身臭蟲的話對於學生學習會遇到的問題也會較少，舉個例子，光是啟用除錯器，原本的Dev C++有bug，一定得到專案去設定而且還有奇怪的bug，弄半天才能進行debugging，可以參考我以前寫的</p>
<p><a href="http://ez2learn.com/index.php/c-tutorials/dev-c-/203-dev-cdebugger">Dev C++ debugger教學</a></p>
<p>有了新版的Dev C++，要啟用debugger只要先編譯一次，再點除錯，它問你要不要加入除錯訊息，按是之後，再次按除錯，就可以進行除錯，簡化了非常多的步驟，如果你是助教或是教C/C++的老師，個人建議盡量使用這些最新版本的Dev C++</p>
<p>下載最新版本的Dev C++，請到作者的部落格 <a href="http://orwellengine.blogspot.com/">Orwell&#8217;s Engine</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2011/09/17/dev-c-5-0-0-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>你沒遇過的編譯器鬼打牆，許功蓋問題</title>
		<link>http://blog.ez2learn.com/2011/07/08/%e4%bd%a0%e6%b2%92%e9%81%87%e9%81%8e%e7%9a%84%e7%b7%a8%e8%ad%af%e5%99%a8%e9%ac%bc%e6%89%93%e7%89%86%ef%bc%8c%e8%a8%b1%e5%8a%9f%e8%93%8b%e5%95%8f%e9%a1%8c/</link>
		<comments>http://blog.ez2learn.com/2011/07/08/%e4%bd%a0%e6%b2%92%e9%81%87%e9%81%8e%e7%9a%84%e7%b7%a8%e8%ad%af%e5%99%a8%e9%ac%bc%e6%89%93%e7%89%86%ef%bc%8c%e8%a8%b1%e5%8a%9f%e8%93%8b%e5%95%8f%e9%a1%8c/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 04:33:44 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[C/C++]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=1472</guid>
		<description><![CDATA[我想在前面的文章裡很多人可能都沒遇過所謂的鬼打牆，大學四年中我遇到最多鬼打牆的狀況全是Dev C++引起的，其實如果都一一記下來應該是個很長的列表，只是問題解決通常我自己也忘記了，其中一個我印相最深刻的鬼打牆問題不是由Dev C++引起的，而是Visual C++ 6.0引起的，程式碼大略像這樣 class SocketHandler &#123; // 此函數會被呼叫以通知連線成功 void onConnectionSuccess&#40;&#41;; &#125;; &#160; void SocketHandler::onConnectionSuccess&#40;&#41; &#123; // some code here &#125; 這是我自己寫的一個socket連線程式，不管怎麼試，編譯器總會跟我抱怨它不認識onConnectionSuccess這個函數，從表面上看起來程式也沒有任何問題，所以問題到底出在哪裡? 答案是許功蓋問題，看到了嗎? 註解的最後一個字是"功"，而我們知道"功"在 big5 其中最後一個字元是 "/"，且VC6不懂得unicode，它會以ASCII的方式來處理程式碼，所以程式碼就變成 // 此函數會被呼叫以通知連線成 \ void onConnectionSuccess(); 如此一來，註解就被延伸到了下一行，onConnectionSuccess的宣告就因為這樣被忽視掉了，為了找到這個問題，我重讀了好多次程式碼，都找不到任何缺陷，一整天的時間就花在這個上面 這個故事告訴我們什麼? 從此之後我就強迫自己改用英文寫註解，我想沒有多少人有機會遇到這問題，而誰也想不到註解也會造成程式的編譯問題，這個故事告訴我們，工具的好壞遠比你想像重要，不要以為這種缺陷沒什麼，事實上是那些缺陷可以讓你debug一整天都找不到原因，除了你的工作時間浪費了，學習的時間更是浪費在其中，更慘的是還帶來了嚴重的挫折感，再一次，工欲善其事，必先利其器，學習更是如此]]></description>
			<content:encoded><![CDATA[<p>我想在前面的文章裡很多人可能都沒遇過所謂的鬼打牆，大學四年中我遇到最多鬼打牆的狀況全是Dev C++引起的，其實如果都一一記下來應該是個很長的列表，只是問題解決通常我自己也忘記了，其中一個我印相最深刻的鬼打牆問題不是由Dev C++引起的，而是Visual C++ 6.0引起的，程式碼大略像這樣</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> SocketHandler <span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// 此函數會被呼叫以通知連線成功</span>
    <span style="color: #0000ff;">void</span> onConnectionSuccess<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> SocketHandler<span style="color: #008080;">::</span><span style="color: #007788;">onConnectionSuccess</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
   <span style="color: #666666;">// some code here</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>這是我自己寫的一個socket連線程式，不管怎麼試，編譯器總會跟我抱怨它不認識onConnectionSuccess這個函數，從表面上看起來程式也沒有任何問題，所以問題到底出在哪裡? 答案是許功蓋問題，看到了嗎? 註解的最後一個字是"功"，而我們知道"功"在 big5 其中最後一個字元是 "/"，且VC6不懂得unicode，它會以ASCII的方式來處理程式碼，所以程式碼就變成</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// 此函數會被呼叫以通知連線成 \
void onConnectionSuccess();</span></pre></div></div>

<p>如此一來，註解就被延伸到了下一行，onConnectionSuccess的宣告就因為這樣被忽視掉了，為了找到這個問題，我重讀了好多次程式碼，都找不到任何缺陷，一整天的時間就花在這個上面</p>
<h2>這個故事告訴我們什麼?</h2>
<p>從此之後我就強迫自己改用英文寫註解，我想沒有多少人有機會遇到這問題，而誰也想不到註解也會造成程式的編譯問題，這個故事告訴我們，工具的好壞遠比你想像重要，不要以為這種缺陷沒什麼，事實上是那些缺陷可以讓你debug一整天都找不到原因，除了你的工作時間浪費了，學習的時間更是浪費在其中，更慘的是還帶來了嚴重的挫折感，再一次，工欲善其事，必先利其器，學習更是如此</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2011/07/08/%e4%bd%a0%e6%b2%92%e9%81%87%e9%81%8e%e7%9a%84%e7%b7%a8%e8%ad%af%e5%99%a8%e9%ac%bc%e6%89%93%e7%89%86%ef%bc%8c%e8%a8%b1%e5%8a%9f%e8%93%8b%e5%95%8f%e9%a1%8c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>99乘法表C++ Meta Programming版</title>
		<link>http://blog.ez2learn.com/2010/03/29/multiplication-table-cpp-meta-programming/</link>
		<comments>http://blog.ez2learn.com/2010/03/29/multiplication-table-cpp-meta-programming/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 11:20:31 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Meta-Programming]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=971</guid>
		<description><![CDATA[前些日子有人在PTT C++版問了99乘法表相關的問題，於是我手癢就寫了一個C++ Meta-Programming的版本，沒用真正寫過Meta-Programming，因為感覺上實在是太炫技了，像是帕格尼尼的炫技曲似的，如果inline最佳化都成功的話，應該是會整個被展開來，用的是編譯時間來換效能，因為和一般的程式寫法和思考方式都不太一樣，所以這樣的東西還是盡量別亂用的好，不然別人通常都難以維護，所以這只是純寫好玩的 如果你在修C++的課，剛好遇到99乘法表的作業，或許你可以把這拿去交，看助教看了會有什麼反應 XD 以下是程式碼 &#60;code&#62; &#160; #include &#60;iostream&#62; &#160; using namespace std; &#160; inline void printLine&#40;int i, int j&#41; &#123; cout &#60;&#60; i &#60;&#60; &#34; * &#34; &#60;&#60; j &#60;&#60; &#34; = &#34; &#60;&#60; i * j &#60;&#60; &#8230; <a href="http://blog.ez2learn.com/2010/03/29/multiplication-table-cpp-meta-programming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>前些日子有人在PTT C++版問了99乘法表相關的問題，於是我手癢就寫了一個C++ Meta-Programming的版本，沒用真正寫過Meta-Programming，因為感覺上實在是太炫技了，像是帕格尼尼的炫技曲似的，如果inline最佳化都成功的話，應該是會整個被展開來，用的是編譯時間來換效能，因為和一般的程式寫法和思考方式都不太一樣，所以這樣的東西還是盡量別亂用的好，不然別人通常都難以維護，所以這只是純寫好玩的</p>
<p>如果你在修C++的課，剛好遇到99乘法表的作業，或許你可以把這拿去交，看助教看了會有什麼反應 XD</p>
<p>以下是程式碼</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #000080;">&lt;</span>code<span style="color: #000080;">&gt;</span>
&nbsp;
<span style="color: #339900;">#include &lt;iostream&gt;</span>
&nbsp;
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">void</span> printLine<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i, <span style="color: #0000ff;">int</span> j<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> i <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; * &quot;</span> <span style="color: #000080;">&lt;&lt;</span> j  <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; = &quot;</span> <span style="color: #000080;">&lt;&lt;</span> i <span style="color: #000040;">*</span> j <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> I, <span style="color: #0000ff;">int</span> J<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> Line <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        Line<span style="color: #000080;">&lt;</span>I, J<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        printLine<span style="color: #008000;">&#40;</span>I, J<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> I<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> Line<span style="color: #000080;">&lt;</span>I, <span style="color: #0000dd;">1</span><span style="color: #000080;">&gt;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        printLine<span style="color: #008000;">&#40;</span>I, <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> NUM, <span style="color: #0000ff;">int</span> N<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> Group <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        Group<span style="color: #000080;">&lt;</span>NUM, N <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span><span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
        Line<span style="color: #000080;">&lt;</span>N, NUM<span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> NUM<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> Group<span style="color: #000080;">&lt;</span>NUM, <span style="color: #0000dd;">1</span><span style="color: #000080;">&gt;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        Line<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">1</span>, NUM<span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">template</span> <span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span> NUM<span style="color: #000080;">&gt;</span>
<span style="color: #0000ff;">struct</span> Meta99 <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">inline</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> print<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        Group<span style="color: #000080;">&lt;</span>NUM,NUM<span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    Meta99<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">20</span><span style="color: #000080;">&gt;</span><span style="color: #008080;">::</span><span style="color: #007788;">print</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #000080;">&lt;</span><span style="color: #000040;">/</span>code<span style="color: #000080;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2010/03/29/multiplication-table-cpp-meta-programming/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Python使用HGE引擎</title>
		<link>http://blog.ez2learn.com/2009/08/25/python-hge/</link>
		<comments>http://blog.ez2learn.com/2009/08/25/python-hge/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 13:24:55 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[遊戲設計]]></category>
		<category><![CDATA[設計]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[2D引擎]]></category>
		<category><![CDATA[2D硬體加速]]></category>
		<category><![CDATA[遊戲開發]]></category>
		<category><![CDATA[開源]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Game design]]></category>
		<category><![CDATA[HGE]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=718</guid>
		<description><![CDATA[大家肯定都知道在Python下面寫2D遊戲有個眾所階知的選擇就是pygame，雖然它簡單好寫，對於簡單的遊戲來說已經足夠，但是他有一個致命的缺點，就是速度太慢了，在pygame的背後是SDL，用純軟體畫圖的函式庫，既然為純軟體繪圖，遇上旋轉、半透明等等需求，更顯得吃力和不切實際，所以該怎麼辦才好呢? 答案是用Haaf&#8217;s Game Engine，它是一款用DirectX做為backend的Open source遊戲函式庫，我在先前的文章裡已經有做簡單的介紹，就不再重覆，那這函式庫和Python又有什麼關聯呢? 他是用C++寫的，Python沒辦法用，正因為這樣，我一直一來想幫他寫一個python的binding，我一直想如果Python也能用HGE寫起來一定很開心，我試著找了一下有沒有已經存在這樣的專案，有找到一個，但是居然是在萬惡的GNU授權下的，讓我百思不得其解，那專案的作者到底在想什麼? 想讓大家寫Open source的Game嗎? 我們都知道GNU是大名頂頂的病毒授權，任何程式使用了用GNU的函式庫都會被感染，代表你的主程式一樣得變成GNU的開源授權，我個人非常討厭打著自由名義但是卻有強烈的強迫性質的GNU授權，況且HGE的授權是非常寬鬆的 zlib/libpng License，實在想不透為什麼一個binding可以用超嚴格的GNU，不過那是那作者的自由，我也管不著，在不能接受那惡心的授權，加上我看了一下他的專案似乎好像也沒有很完整的進度，於是我還是決定自己開了一個新的專案 Python HGE 在這樣的情況下，我前些天抽空開了一個新的Open source專案: Python-HGE，把一些最核心的程式碼都用boost.python包裝給Python使用，最核心的部份完成度很高，剩下的需要我在未來有空慢慢補上，License是MIT，如果你問我為什麼選MIT，我想答案應該是商業用途一樣也可以，不像GNU那種假腥腥的自由，還有一個重點就是，我覺得麻省理工這名字聽起來很酷，讓我想起每次在Discovery看到的東西 效能問題 我照著原本HGE的Tutorial7的程式寫了一個Python的版本，這個範例的目的就是在展示HGE的效能，純C++的版本速度當然是很快，而Python的版本FPS掉了不少，一開始讓我覺得有點失望，讓我開始懷疑如果效能掉很多的話，那用Python寫HGE還有價值嗎? 後來仔細思考了一下，對於一般的2D遊戲來說，要像這demo整畫面跑來跑去的圖片加透明效果的情況實在不多，就算有也很難到這樣上千張的圖片，再者我都還沒進行最佳化、跑profile等等，而且雖說FPS掉不少，但是那是和C++數百的FPS比起來，在60以上其實都是可以接受的，加上我測試的這台電腦已經有點年代，對現代的電腦和GUP來說情況只會更好，在如此的考量之下，Python HGE還是有搞頭的 python版的tutorial 7截圖 這個demo可以在這裡下載 目前狀況 目前雖然核心部份已經高度完成，不過我還沒有把編出來的pyd釋放的打算，如果想嘗鮮的話可以直接從那個demo裡面找pyd出來用，又或著自己check out原始碼進行編譯 參與開發 如果有興趣的話，歡迎參與專案的開發，如同我上面所提到的，我用的是boost.python，一款基於C++的python binding函式庫，如果你熟悉boost.python的話當然是最好，就算沒有也沒關系，因為其實大部份工作都是剪下貼上之類的，可以參考我已經寫好的部份，有些函數回傳例如指標之類的東西需要特別處理，除此之外都只是很簡單無腦工作]]></description>
			<content:encoded><![CDATA[<p>大家肯定都知道在Python下面寫2D遊戲有個眾所階知的選擇就是pygame，雖然它簡單好寫，對於簡單的遊戲來說已經足夠，但是他有一個致命的缺點，就是速度太慢了，在pygame的背後是SDL，用純軟體畫圖的函式庫，既然為純軟體繪圖，遇上旋轉、半透明等等需求，更顯得吃力和不切實際，所以該怎麼辦才好呢?</p>
<p>答案是用<a href="http://hge.relishgames.com/">Haaf&#8217;s Game Engine</a>，它是一款用DirectX做為backend的Open source遊戲函式庫，我在<a href="http://blog.ez2learn.com/2009/01/10/intro-to-hge/">先前的文章</a>裡已經有做簡單的介紹，就不再重覆，那這函式庫和Python又有什麼關聯呢? 他是用C++寫的，Python沒辦法用，正因為這樣，我一直一來想幫他寫一個python的binding，我一直想如果Python也能用HGE寫起來一定很開心，我試著找了一下有沒有已經存在這樣的專案，有找到一個，但是居然是在萬惡的GNU授權下的，讓我百思不得其解，那專案的作者到底在想什麼? 想讓大家寫Open source的Game嗎? 我們都知道GNU是大名頂頂的病毒授權，任何程式使用了用GNU的函式庫都會被感染，代表你的主程式一樣得變成GNU的開源授權，我個人非常討厭打著自由名義但是卻有強烈的強迫性質的GNU授權，況且HGE的授權是非常寬鬆的<a href="http://www.opensource.org/licenses/zlib-license.php" target="_blank"> zlib/libpng License</a>，實在想不透為什麼一個binding可以用超嚴格的GNU，不過那是那作者的自由，我也管不著，在不能接受那惡心的授權，加上我看了一下他的專案似乎好像也沒有很完整的進度，於是我還是決定自己開了一個新的專案<a href="http://www.opensource.org/licenses/zlib-license.php" target="_blank"></a></p>
<h2>Python HGE</h2>
<p>在這樣的情況下，我前些天抽空開了一個新的Open source專案: <a href="http://code.google.com/p/python-hge/">Python-HGE</a>，把一些最核心的程式碼都用boost.python包裝給Python使用，最核心的部份完成度很高，剩下的需要我在未來有空慢慢補上，License是MIT，如果你問我為什麼選MIT，我想答案應該是商業用途一樣也可以，不像GNU那種假腥腥的自由，還有一個重點就是，我覺得麻省理工這名字聽起來很酷，讓我想起每次在Discovery看到的東西</p>
<h2>效能問題</h2>
<p>我照著原本HGE的Tutorial7的程式寫了一個Python的版本，這個範例的目的就是在展示HGE的效能，純C++的版本速度當然是很快，而Python的版本FPS掉了不少，一開始讓我覺得有點失望，讓我開始懷疑如果效能掉很多的話，那用Python寫HGE還有價值嗎? 後來仔細思考了一下，對於一般的2D遊戲來說，要像這demo整畫面跑來跑去的圖片加透明效果的情況實在不多，就算有也很難到這樣上千張的圖片，再者我都還沒進行最佳化、跑profile等等，而且雖說FPS掉不少，但是那是和C++數百的FPS比起來，在60以上其實都是可以接受的，加上我測試的這台電腦已經有點年代，對現代的電腦和GUP來說情況只會更好，在如此的考量之下，Python HGE還是有搞頭的</p>
<p>python版的tutorial 7截圖</p>
<p><a href="http://blog.ez2learn.com/wp-content/uploads/2009/08/t7.png"><img class="alignnone size-medium wp-image-719" title="t7" src="http://blog.ez2learn.com/wp-content/uploads/2009/08/t7-300x235.png" alt="t7" width="300" height="235" /></a></p>
<p>這個demo可以在<a href="http://python-hge.googlecode.com/files/t7.zip">這裡下載</a></p>
<h2>目前狀況</h2>
<p>目前雖然核心部份已經高度完成，不過我還沒有把編出來的pyd釋放的打算，如果想嘗鮮的話可以直接從那個demo裡面找pyd出來用，又或著自己check out原始碼進行編譯</p>
<h2>參與開發</h2>
<p>如果有興趣的話，歡迎參與專案的開發，如同我上面所提到的，我用的是boost.python，一款基於C++的python binding函式庫，如果你熟悉boost.python的話當然是最好，就算沒有也沒關系，因為其實大部份工作都是剪下貼上之類的，可以參考我已經寫好的部份，有些函數回傳例如指標之類的東西需要特別處理，除此之外都只是很簡單無腦工作</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/08/25/python-hge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>VC++ 9.0的編譯器鬼打牆錯誤</title>
		<link>http://blog.ez2learn.com/2009/01/30/vc-strange-compiler-error/</link>
		<comments>http://blog.ez2learn.com/2009/01/30/vc-strange-compiler-error/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 12:34:05 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[心得]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[腦殘]]></category>
		<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=498</guid>
		<description><![CDATA[VC++ 9.0的編譯器鬼打牆錯誤 : 這個時候不應有 的原因和解決方法 <a href="http://blog.ez2learn.com/2009/01/30/vc-strange-compiler-error/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天要將一些C++程式弄成Python模組，使用Boost.Python，以bjam編譯時一直跑出一堆鬼打牆的錯誤訊息</p>
<blockquote><p>這個時候不應有 \Utilities\Bin\x86&#8243;;F:\Inprise\vbroker\bin;F:\Borland\CBUILD~1\Bi<br />
n;F:\Borland\CBUILD~1\Projects\Bpl;"F:\Microsoft。</p></blockquote>
<p>這個時候不應有，到底是什麼鬼東西是這裡不應該有的，我仔細觀察了一下，把bjam呼叫的內容全印出來，可是都找不到有參數是那段一堆路徑，再仔細看看那堆路徑看起來像是Path裡的東西，想一想bjam應該丟參數給compiler而已，於是就懷疑是VC++ 9.0 Express的問題，花了好大的力氣，讓我找到了</p>
<p>這篇文章 :</p>
<h2><a id="viewpost_ascx_TitleUrl" title="Title of this entry." href="http://weblogs.sqlteam.com/mladenp/archive/2008/05/28/Serious-Visual-Studio-2008-install-bug-that-can-break-your.aspx">Serious Visual Studio 2008 install bug that can break your builds</a></h2>
<p>才解決這個問題，原來是安裝的SDK像"C:\Program Files\Microsoft DirectX SDK <strong>(June 2006)</strong>\Utilities\Bin\x86&#8243;有括號，在bat檔裡被錯誤解析的樣子</p>
<p>很多時候其實都希望程式設計相關的錯誤訊息不要中文化，像是這個，"這時候不應該有"，放到Google搜尋只會出現一堆不相關的東西，但是原文"was unexpected at this time." 下去找很快就能找到相關的資料，我記得之前在Ubuntu下編譯程式，就有遇到編譯器錯誤訊息輸出被中文化的情況&#8230;，真的是鬼打牆，沒翻還好，一翻根本不知道它在說什麼鬼，也沒辦法貼到Google找資料</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/01/30/vc-strange-compiler-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Unit Test Framework試玩</title>
		<link>http://blog.ez2learn.com/2009/01/21/try-google-unit-test-framework/</link>
		<comments>http://blog.ez2learn.com/2009/01/21/try-google-unit-test-framework/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 11:00:42 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[單元測試]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Unit Test]]></category>
		<category><![CDATA[測試]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=485</guid>
		<description><![CDATA[介紹Unit Test和 測試驅動開發 (Test-driven development)，以及Google Unit Test Framework的試玩心得 <a href="http://blog.ez2learn.com/2009/01/21/try-google-unit-test-framework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一直一來我都知道Unit Test對於程式的開發是蠻重要的一個環節，在以往我們常常不停地改寫程式，在這個過程中，有意無意地常常會有東西被改壞掉還不知道，而我們檢查的方式可能很常是透過一直修改程式碼或輸入的資料來測試，但是當程式越來越大，我們測試時只專注在一個地方，此時所要測試的程式越來越多，不小心出錯的可能也越來越多，每改寫一次就是一次昂貴的人力檢查，最後程式就像一艘漏水的船，補了這裡，那裡卻又多了一個洞，船員像無頭蒼蠅一樣四處補洞，這樣的情況就是Unit Test能解決的問題，透過Unit Test，每次寫的程式碼都交給程式自動測試，一來測試的速度很快，不管是一百次還是一千次，總比人工測試來得快速、正確、廣範，但這不是免費的，代價就是程式設計師要寫很多Unit Test的程式碼，還要想要如何寫Unit Test的程式，進一步的還有測試導向的開發模式(<a href="http://en.wikipedia.org/wiki/Test-driven_development">Test-driven development</a>)，程式是在Unit Test寫完之後才開始寫，這樣一來迫使程式設計師在一開始就得把設計想好，邊寫邊想的做法不再可行，這或許算缺點也算優點</p>
<p>這些我都知道，但都沒有很確實去做，之前有用Python寫過Unit Test，他那種寫法我很喜歡，但C++卻沒有，直到這次想開發某些東西，我決定要試著落實TDD，但在開始以前，要有合適的工具，也就是自動測試的框架，起初我使用Boost.Test，雖然說可以使用，但是我不得不抱怨，他的文件是寫給鬼看的，好幾十頁的文件裡面廢話連篇，分類也很不明確，難以找到重點，或許是我英文程度太差，我真的讀不太懂Boost.Test到底怎麼用，靠著東拼西湊勉強終於還算可以使用，但是或許是我搞不太清楚它一堆Compile時用的Macro定義的Flag如何使用，編譯起來不知為何非常地慢</p>
<p>不合胃口(有些反胃的感覺)的文件，讓我覺得該是時候和Boost.Test說再見，尋找新歡的時候到了，無意間發現，在不知道什麼時候突然冒出來的<a href="http://code.google.com/p/googletest/">Google Unit Test Framework</a>，似乎才剛釋放出來沒多久，是Google內部C++寫Unit Test的框架，開放成Open source的專案，看起來很不錯，文件簡單明瞭，不像Boost.Test幾十頁連篇翻半天還不知道Unit Test到底要怎樣執行，他們主張為什麼要使用Google Unit Test Framework的理由:</p>
<blockquote>
<ol>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">Tests should be <em>independent</em> and <em>repeatable</em>. It&#8217;s a pain to debug a test that succeeds or fails as a result of other tests. Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging. </a></li>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">Tests should be well <em>organized</em> and reflect the structure of the tested code. Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base. </a></li>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">Tests should be <em>portable</em> and <em>reusable</em>. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral. Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations. (Note that the current release only contains build scripts for Linux &#8211; we are actively working on scripts for other platforms.) </a></li>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">When tests fail, they should provide as much <em>information</em> about the problem as possible. Google C++ Testing Framework doesn&#8217;t stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle. </a></li>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">The testing framework should liberate test writers from housekeeping chores and let them focus on the test <em>content</em>. Google C++ Testing Framework automatically keeps track of all tests defined, and doesn&#8217;t require the user to enumerate them in order to run them. </a></li>
<li><a name="Introduction:_Why_Google_C++_Testing_Framework?">Tests should be <em>fast</em>. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other. </a></li>
</ol>
</blockquote>
<p>聽起來很合我胃口，於是就下載來試試，首先，要得編譯Google Test的library，以Visual Studio來說，開啟它的.sln檔，然後編譯就可以了</p>
<p>接著是如何使用Google Test? 雖然有點小麻煩，但其實也還好，首先include "gtest/gtest.h"，接著是lib的設定，因為Google Test的lib是使用/MT參數進行編譯，所以你的專案也一樣要設為/MT或/MTd(Debug 模式下使用)，然後link gtest.lib就可以了，如果不這樣做，你會看見一大堆xxx aleardy defined in xxx的link錯誤</p>
<p>而我用Code Blocks似乎因為編譯參數不太一樣又遇到一堆link錯誤，後來發現好像是Code Blocks的Console Application專案一開始就link的msvcrtd.lib一系列.lib所造成的，將那些移除只剩gtest.lib或gtestd.lib就可以正確執行，我隨手從它的範例裡組合出一個測試的執行檔</p>
<pre lang="c++">
#include

#include 

using namespace std;

// Returns n! (the factorial of n).  For negative n, n! is defined to be 1.
int Factorial(int n) {
  int result = 1;
  for (int i = 1; i &lt;= n; i++) {
    result *= i;
  }

  return result;
}

// Returns true iff n is a prime number.
bool IsPrime(int n) {
  // Trivial case 1: small numbers
  if (n &lt;= 1) return false;

  // Trivial case 2: even numbers
  if (n % 2 == 0) return n == 2;

  // Now, we have that n is odd and n &gt;= 3.

  // Try to divide n by every odd number i, starting from 3
  for (int i = 3; ; i += 2) {
    // We only have to try i up to the squre root of n
    if (i &gt; n/i) break;

    // Now, we have i &lt;= n/i &lt; n.
    // If n is divisible by i, n is not prime.
    if (n % i == 0) return false;
  }

  // n has no integer factor in the range (1, n), and thus is prime.
  return true;
}

// Step 2. Use the TEST macro to define your tests.
//
// TEST has two parameters: the test case name and the test name.
// After using the macro, you should define your test logic between a
// pair of braces.  You can use a bunch of macros to indicate the
// success or failure of a test.  EXPECT_TRUE and EXPECT_EQ are
// examples of such macros.  For a complete list, see gtest.h.
//
//
//
// In Google Test, tests are grouped into test cases.  This is how we
// keep test code organized.  You should put logically related tests
// into the same test case.
//
// The test case name and the test name should both be valid C++
// identifiers.  And you should not use underscore (_) in the names.
//
// Google Test guarantees that each test you define is run exactly
// once, but it makes no guarantee on the order the tests are
// executed.  Therefore, you should write your tests in such a way
// that their results don't depend on their order.
//
// 

// Tests Factorial().

// Tests factorial of negative numbers.
TEST(FactorialTest, Negative) {
  // This test is named "Negative", and belongs to the "FactorialTest"
  // test case.
  EXPECT_EQ(1, Factorial(-5));
  EXPECT_EQ(1, Factorial(-1));
  EXPECT_TRUE(Factorial(-10) &gt; 0);

  //
  //
  // EXPECT_EQ(expected, actual) is the same as
  //
  //   EXPECT_TRUE((expected) == (actual))
  //
  // except that it will print both the expected value and the actual
  // value when the assertion fails.  This is very helpful for
  // debugging.  Therefore in this case EXPECT_EQ is preferred.
  //
  // On the other hand, EXPECT_TRUE accepts any Boolean expression,
  // and is thus more general.
  //
  //
}

// Tests factorial of 0.
TEST(FactorialTest, Zero) {
  EXPECT_EQ(1, Factorial(0));
}

// Tests factorial of positive numbers.
TEST(FactorialTest, Positive) {
  EXPECT_EQ(1, Factorial(1));
  EXPECT_EQ(2, Factorial(2));
  EXPECT_EQ(6, Factorial(3));
  EXPECT_EQ(40320, Factorial(8));
}

// Tests IsPrime()

// Tests negative input.
TEST(IsPrimeTest, Negative) {
  // This test belongs to the IsPrimeTest test case.

  EXPECT_FALSE(IsPrime(-1));
  EXPECT_FALSE(IsPrime(-2));
  EXPECT_FALSE(IsPrime(INT_MIN));
}

// Tests some trivial cases.
TEST(IsPrimeTest, Trivial) {
  EXPECT_FALSE(IsPrime(0));
  EXPECT_FALSE(IsPrime(1));
  EXPECT_TRUE(IsPrime(2));
  EXPECT_TRUE(IsPrime(3));
}

// Tests positive input.
TEST(IsPrimeTest, Positive) {
  EXPECT_FALSE(IsPrime(4));
  EXPECT_TRUE(IsPrime(5));
  EXPECT_FALSE(IsPrime(6));
  EXPECT_TRUE(IsPrime(23));
}

int main(int argc, char** argv) {
  // Prints elapsed time by default.
  //testing::GTEST_FLAG(print_time) = true;

  // This allows the user to override the flag on the command line.
  testing::InitGoogleTest(&amp;argc, argv);

  return RUN_ALL_TESTS();
}</pre>
<p>很簡單明瞭吧? 然後它執行的結果畫面如下</p>
<div id="attachment_486" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.ez2learn.com/wp-content/uploads/2009/01/gtest_result.png"><img class="size-medium wp-image-486" title="Google test 執行結果" src="http://blog.ez2learn.com/wp-content/uploads/2009/01/gtest_result-300x196.png" alt="Google test 執行結果" width="300" height="196" /></a><p class="wp-caption-text">Google test 執行結果</p></div>
<p>沒想到還有顏色，看起來蠻酷的對吧，很酷有時候也是選擇專案的理由之一，在這樣試玩下來，雖然還沒深入研究，還有實際寫Unit Test，但是感覺起來真的很不錯，有興趣的人可以試一試</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/01/21/try-google-unit-test-framework/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Google C++ 程式風格指南</title>
		<link>http://blog.ez2learn.com/2009/01/21/google-coding-style-guide/</link>
		<comments>http://blog.ez2learn.com/2009/01/21/google-coding-style-guide/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 08:52:48 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[風格]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=482</guid>
		<description><![CDATA[介紹Google的 C++ 程式風格指南 <a href="http://blog.ez2learn.com/2009/01/21/google-coding-style-guide/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天在找比Boost.Test更好用的Unit Ttest Framework時，在看<a href="http://code.google.com/p/googletest/">Google Unit Test Framework</a>時，無意間發現了<a href="http://code.google.com/p/google-styleguide/">Google的程式風格指南</a>，裡面有<a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">C++的程式風格指南</a>，我看了一下覺得還蠻有參考價值的，他們不是沒有理由的規定編程的風格，每條理由都有清楚寫出優點、缺點、甚至討論等等，做為決定團隊程式語言風格的指南決定，或是看他們決定的理由，都很有幫助</p>
<p>學寫C++的人可以參考看看</p>
<p>註 : 每個條目要按一個向下的三角形會展開細節，優缺點和討論等等</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/01/21/google-coding-style-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HGE project wizard template for Code::Blocks</title>
		<link>http://blog.ez2learn.com/2009/01/10/hge-project-wizard-template-for-codeblocks/</link>
		<comments>http://blog.ez2learn.com/2009/01/10/hge-project-wizard-template-for-codeblocks/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 17:42:51 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[English Articles]]></category>
		<category><![CDATA[遊戲]]></category>
		<category><![CDATA[Blocks]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[HGE]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wizard]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=458</guid>
		<description><![CDATA[HGE project wizard template for Code::Blocks <a href="http://blog.ez2learn.com/2009/01/10/hge-project-wizard-template-for-codeblocks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am learning HGE (<a href="http://hge.relishgames.com/">Haaf&#8217;s Game Engine</a>) these days. It is troublesome to set up all include and library directory stuff every time you want to write an application based on HGE. For this reason I spent some time to learn how to create a Code::Blocks project wizard template, and finally finish it. It is quite simple to install the HGE project wizard template into Code::Blocks. The only step you have to do is unzip the zip file to the location you install Code::Blocks and restart Code::Blocks. If you have installed other nonstandard templates, those templates might disappear from the project list, because Code::Blocks use "share\CodeBlocks\templates\wizard\config.script" to list all templates, and you overwrite it. To solve that problem, you can merge config.script manually. It is not too difficult to understand that file if you are going to learn how to write a game with C or C++ :D</p>
<p>Download : <a href="http://blog.ez2learn.com/wp-content/uploads/2009/01/hge_project_wizard1.zip">HGE project wizard template for codeblocks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/01/10/hge-project-wizard-template-for-codeblocks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code::Blocks的HGE專案樣版</title>
		<link>http://blog.ez2learn.com/2009/01/10/codeblocks-hge-project-wizard-template/</link>
		<comments>http://blog.ez2learn.com/2009/01/10/codeblocks-hge-project-wizard-template/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 17:24:59 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[遊戲設計]]></category>
		<category><![CDATA[HGE]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=454</guid>
		<description><![CDATA[為了能方便開新專案寫HGE的程式，我特地研究了一下如何製作Code::Blocks的Wizard template <a href="http://blog.ez2learn.com/2009/01/10/codeblocks-hge-project-wizard-template/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近開始研就<a href="http://hge.relishgames.com/">HGE (Haaf&#8217;s Game Engine)</a>，為了能方便開新專案寫HGE的程式，我特地研究了一下如何製作<a href="http://www.codeblocks.org/">Code::Blocks</a>的Wizard template，有個樣版每次開新專案就很方便，不用每次都要設定link之類的麻煩事情，我將它上傳，有興趣的就抓回去使用吧，安裝方法很簡單，只要解壓縮到Code::Blocks安裝的目錄下即可，如果你有安裝其它Project Wizard template的話，有可能會抓不到，或讓其它安裝的template被蓋掉，因為Code::Blocks是依照share\CodeBlocks\templates\wizard\config.script這個script檔來決定有哪些template，遇到這個問題的話，就請手動合併config.script檔案，內容很簡單，應該看了大概就明白在做什麼的</p>
<p><a href="http://blog.ez2learn.com/wp-content/uploads/2009/01/hge_project_wizard1.zip">HGE project wizard template for codeblocks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2009/01/10/codeblocks-hge-project-wizard-template/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>簡易Compiler(其實是Interpreter) : Micro 實作</title>
		<link>http://blog.ez2learn.com/2008/10/13/implement-of-micro-interpreter/</link>
		<comments>http://blog.ez2learn.com/2008/10/13/implement-of-micro-interpreter/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 03:47:08 +0000</pubDate>
		<dc:creator>victor</dc:creator>
				<category><![CDATA[中文文章]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[程式設計]]></category>

		<guid isPermaLink="false">http://blog.ez2learn.com/?p=198</guid>
		<description><![CDATA[昨天 花了一個晚上的時間把Compiler作業Micro直譯器寫出來了，為啥說它是直譯器，因為光寫文法解析實在很無聊，它的語法又太簡單，反正讓它能執行也多沒幾行程式，就順手讓它可以直接執行，還蠻有趣的，第一次寫比較正規的語法解析器，我想起很久很久以前我寫過一個滑鼠鍵盤的巨集程式 就有解析自創的簡單語法，可是方法實在很暴力很蠢 XD，用了一些五四三的方法硬湊出來，現在我寫完這個作業覺得scanner和parser這樣才是比較正規的做法，我還用了Interpreter Pattern來實作 Micro 課本上的Micro語言實在有點簡單過頭了，只有輸入、輸出、運算而已，運算也只有加和減，本來想修改的，可是又要設計BNF和考慮運算優先順序等等麻煩的問題就打消念頭，只寫了兩個簡單的程式 begin read (a, b, c); sum := a + b + c; write (sum); end begin read (f1, f2); f3 := f1 + f2; f4 := f2 + f3; f5 := f3 + &#8230; <a href="http://blog.ez2learn.com/2008/10/13/implement-of-micro-interpreter/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>昨天</h2>
<p>花了一個晚上的時間把Compiler作業Micro直譯器寫出來了，為啥說它是直譯器，因為光寫文法解析實在很無聊，它的語法又太簡單，反正讓它能執行也多沒幾行程式，就順手讓它可以直接執行，還蠻有趣的，第一次寫比較正規的語法解析器，我想起很久很久以前我寫過一個滑鼠鍵盤的巨集程式</p>
<div id="attachment_199" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.ez2learn.com/wp-content/uploads/2008/10/2008-10-13_113038.png"><img class="size-medium wp-image-199" title="滑鼠鍵盤巨集程式" src="http://blog.ez2learn.com/wp-content/uploads/2008/10/2008-10-13_113038-300x144.png" alt="滑鼠鍵盤巨集程式" width="300" height="144" /></a><p class="wp-caption-text">滑鼠鍵盤巨集程式</p></div>
<p>就有解析自創的簡單語法，可是方法實在很暴力很蠢 XD，用了一些五四三的方法硬湊出來，現在我寫完這個作業覺得scanner和parser這樣才是比較正規的做法，我還用了Interpreter Pattern來實作</p>
<h2>Micro</h2>
<p>課本上的Micro語言實在有點簡單過頭了，只有輸入、輸出、運算而已，運算也只有加和減，本來想修改的，可是又要設計BNF和考慮運算優先順序等等麻煩的問題就打消念頭，只寫了兩個簡單的程式</p>

<div class="wp_syntax"><div class="code"><pre class="pasical" style="font-family:monospace;">begin
    read (a, b, c);
    sum := a + b + c;
    write (sum);
end</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="pasical" style="font-family:monospace;">begin
    read (f1, f2);
    f3 := f1 + f2;
    f4 := f2 + f3;
    f5 := f3 + f4;
    f6 := f4 + f5;
    f7 := f5 + f6;
    write (f1, f2, f3, f4, f5, f6, f7);
end</pre></div></div>

<h2>下載</h2>
<p><a href="http://blog.ez2learn.com/wp-content/uploads/2008/10/micro.zip">micro直譯器</a></p>
<p>有興趣可以載回去玩玩看，不過<strong>同學請注意，參考看看就好，要拿來當作業交被逮到可不關我的事= =</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ez2learn.com/2008/10/13/implement-of-micro-interpreter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

