<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>pygame &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/pygame/</link>
	<description>Feed of posts on WordPress.com tagged "pygame"</description>
	<pubDate>Fri, 27 Nov 2009 19:13:27 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Game project added to Sourceforge]]></title>
<link>http://phelerox.wordpress.com/2009/11/17/game-project-added-to-sourceforge/</link>
<pubDate>Mon, 16 Nov 2009 22:33:56 +0000</pubDate>
<dc:creator>Marco Baxemyr</dc:creator>
<guid>http://phelerox.wordpress.com/2009/11/17/game-project-added-to-sourceforge/</guid>
<description><![CDATA[After a month of stagnation on my Tower Defense game, I implemented some cool stuff yesterday and to]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>After a month</strong> of stagnation on my <a href="https://sourceforge.net/projects/pytowerdefense/" target="_blank">Tower Defense game</a>, I implemented some cool stuff yesterday and today. Mainly a makeshift main menu and flashy animated text messages popping up.</p>
<p><strong>Just a moment ago</strong> I started a Sourceforge.net project for it. Pretty neat! I appreciate that Sourceforge supports bazaar version control, and I do not yet know if I will discontinue the <a href="https://launchpad.net/~baxemyr/+junk/towerdefense" target="_blank">launchpad branch</a> or keep it updated. Keeping it updated would be no big deal if I only bothered to write a proper &#8216;bzr push&#8217; alias for both Sourceforge and Launchpad.</p>
<p><strong>There is a source release</strong> of version 0.4 <a href="https://sourceforge.net/projects/pytowerdefense/files/PyTowerDefense0.4%20Source%20%28Python2.6%29/pytowerdefense0.4.zip/download" target="_blank">available</a>. <strong>Binary</strong> releases for Windows will pop up soon (I am pretty sure I know how to do it properly!)<em><strong>[</strong></em><strong><em>Update:</em></strong><em> Windows version available<strong>]</strong></em>. Please note that the game is not balanced at all and not near complete. Consider it alpha-stage.  However, it allows for an initial impression and I would be grateful for any feedback! A more rounded-up release is planned for next week</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Is Python Slow?]]></title>
<link>http://hbfs.wordpress.com/2009/11/10/is-python-slow/</link>
<pubDate>Tue, 10 Nov 2009 14:33:29 +0000</pubDate>
<dc:creator>Steven Pigeon</dc:creator>
<guid>http://hbfs.wordpress.com/2009/11/10/is-python-slow/</guid>
<description><![CDATA[Python is a programming language that I learnt somewhat recently (something like 2, 3 years ago) and]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://www.python.org/" target="_blank">Python</a> is a programming language that I learnt somewhat recently (something like 2, 3 years ago) and that I like very much. It is simple, to the point, and has several <a href="http://en.wikipedia.org/wiki/Functional_programming" target="_blank">functional</a>-like constructs that I am already familiar with. But Python is <em>slow</em> compared to other programming languages. But it was unclear to me just how slow Python was compared to other languages. It just felt slow.</p>
<p><a href="http://en.wikipedia.org/wiki/File:Lewis_chess_queen_.jpg"><img src="http://hbfs.wordpress.com/files/2009/09/lewis_chess_queen_.jpg?w=265" alt="Lewis_chess_queen_" title="Lewis_chess_queen_" width="265" height="300" class="aligncenter size-medium wp-image-1670"></a></p>
<p>So I have decided to investigate by comparing the implementation of a simple, compute-bound problem, the <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle" target="_blank">eight queens puzzle</a> generalized to any board dimensions. This puzzle is most easily solved using, as <a href="http://en.wikipedia.org/wiki/Edsger_Dijkstra" target="_blank">Dijkstra</a> did, a depth-first <a href="http://en.wikipedia.org/wiki/Backtracking" target="_blank">backtracking</a> program, using bitmaps to test rapidly whether or not a square is free of attack<sup><a href="#1">1</a></sup>. I implemented the same program in <a href="http://en.wikipedia.org/wiki/C%2B%2B" target="_blank">C++</a>, Python, and <a href="http://en.wikipedia.org/wiki/Bash" target="_blank">Bash</a>, and got help from friends for the <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)" target="_blank">C#</a> and <a href="http://en.wikipedia.org/wiki/Java_(programming_language)" target="_blank">Java</a> versions<sup><a href="#2">2</a></sup>. I then compared the resulting speeds.</p>
<p><!--more--></p>
<p>The eight queens puzzle consist in finding a way to place 8 queens on a 8&#215;8 chessboard so that none of the queen checks another queen. By &#8220;checking&#8221;, we mean that if the other queen was of the opposing camp, you could capture it if it were your turn to play. So this means that no queen is on the same row, column, or diagonal as another queen. Using a real chessboard and pawns in lieu of queens, you can easily find a solution in a few seconds. Now, to make things more interesting, we might be interested in enumerating <em>all</em> solutions (and, for the time being, neglecting to check if a solution is a rotated or mirrored version of another solution).</p>
<p>The basic algorithm to solve the Eight queens puzzle is a relatively simple recursive algorithm. First, we place a queen somewhere on the first row and we mark the row it occupies as menaced. We also do so with the column and two diagonals. We then try to place a second queen somewhere on the second row, on a square that is menace-free, and mark the row, column, and diagonals of the new queen as menaced. And we proceed in the same fashion for other queens. But suppose that at the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />th stage, we cannot find a menace-free square, preventing us from placing the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />th queen. If the situation arises, we give up for the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />th queen and <em>backtrack</em> to the <img src='http://l.wordpress.com/latex.php?latex=%28n-1%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-1)' title='(n-1)' class='latex' />th queen. We try a new (and never tried before) location for the <img src='http://l.wordpress.com/latex.php?latex=%28n-1%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-1)' title='(n-1)' class='latex' />th queen and we go forth trying to place the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />th queen. If may happen that we go all the way back to the <img src='http://l.wordpress.com/latex.php?latex=%28n-k%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-k)' title='(n-k)' class='latex' />th queen because there are no other solutions for the <img src='http://l.wordpress.com/latex.php?latex=%28n-1%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-1)' title='(n-1)' class='latex' />th queen, which asks for the <img src='http://l.wordpress.com/latex.php?latex=%28n-2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-2)' title='(n-2)' class='latex' />th queen to be moved, which can also result in a dead-end; and so forth all the way down to the <img src='http://l.wordpress.com/latex.php?latex=%28n-k%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='(n-k)' title='(n-k)' class='latex' />th queen.</p>
<p>Because the algorithm proceeds depth-first and can rear back quite a bit in looking for new solutions, it is called a <em>backtracking</em> algorithm.  Backtracking algorithms are key to many <a href="http://en.wikipedia.org/wiki/Artificial_intelligence" target="_blank">artificial intelligence</a> systems like, well, <a href="http://en.wikipedia.org/wiki/Chess_engine" target="_blank">chess programs</a>.</p>
<p>So I wrote the program for the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' /> queens puzzle for a <img src='http://l.wordpress.com/latex.php?latex=n%5Ctimes%7B%7Dn&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n\times{}n' title='n\times{}n' class='latex' /> board in C quite sometime ago (circa 1995), then I ported to C++ recently (2006). And just for kicks, I decided to port it to different languages, with help from friends for Java and C# (of which I know about zilch). The C++ versions consist in a generic version that accepts the board size as a command-line argument and in a <a href="http://en.wikipedia.org/wiki/Constant_folding" target="_blank">constant-propagated</a> version where the board size is determined at compile-time. The Python versions, as there are two of them also, differ on how <em>python-esque</em> they are. The first variant is a rather literal translation of the C++ program. The second uses pythonesque idioms such as sets rather than bitmaps and turns out to be quite a bit faster&#8212;about 40% faster in fact. The Bash version is necessarily rather <em>bash-esque</em> as Bash does not offer anything much more sophisticated than arrays in terms of data structures.</p>
<p>All implementations were compiled with all optimizations enabled (<tt>-O3</tt>, inlining, interprocedural optimizations, etc.). For C++, I used g++ 4.2.4, for C#, gmcs 1.2.6.0, for Java, gcj 4.2.4, Python 2.6.2, and, finally, Bash 3.2.39&#8212;all latest versions for Ubuntu 8.04 LTS, which doesn&#8217;t means that they&#8217;re the really latest versions.</p>
<p>So I ran all seven implementations with boards sizes ranging from 1 to 15 on a AMD64 4000+ CPU (the numbers are arbitrary; I wanted to get good data but also limit the CPU time spent as the time increases <a href="http://en.wikipedia.org/wiki/Factorial" target="_blank">factorially</a> in board size!). At first, the results are not very informative:</p>
<div id="attachment_1674" class="wp-caption aligncenter" style="width: 310px"><a href="http://hbfs.wordpress.com/files/2009/09/results-linear-scale1.png"><img src="http://hbfs.wordpress.com/files/2009/09/results-linear-scale1.png?w=300" alt="Results, Time, Linear Scale" title="results-linear-scale" width="300" height="251" class="size-medium wp-image-1674" /></a><p class="wp-caption-text">Results, Time, Linear Scale</p></div>
<p>As expected, all times shoot up quite fast, with, unsurprisingly, BASH shooting up faster, followed by the two Python implementations. At this scale, Java, C#, C++, C++-fixed (the constant-propagated version) all seems to be more or less similar. To remove the factorial growth (as even with a log plot the data remains rather unclear), I scaled all performances relative to the C++ version. The C++ version is therefore 1.0 regardless of actual run-time; for board size <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />, the time needed by Bash, for example, was divided by the time needed by C++ for board size <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' />. We now get:</p>
<div id="attachment_1687" class="wp-caption aligncenter" style="width: 310px"><a href="http://hbfs.wordpress.com/files/2009/09/results-ratio-linear-scale2.png"><img src="http://hbfs.wordpress.com/files/2009/09/results-ratio-linear-scale2.png?w=300" alt="Speed Ratio, Linear Scale" title="results-ratio-linear-scale" width="300" height="251" class="size-medium wp-image-1687" /></a><p class="wp-caption-text">Speed Ratio, Linear Scale</p></div>
<p>We can use a log-scale for the <img src='http://l.wordpress.com/latex.php?latex=y&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='y' title='y' class='latex' /> axis to better separate the similar results:</p>
<div id="attachment_1678" class="wp-caption aligncenter" style="width: 310px"><a href="http://hbfs.wordpress.com/files/2009/09/results-ratio-log-scale.png"><img src="http://hbfs.wordpress.com/files/2009/09/results-ratio-log-scale.png?w=300" alt="Speed Ratio, Log Scale" title="results-ratio-log-scale" width="300" height="251" class="size-medium wp-image-1678" /></a><p class="wp-caption-text">Speed Ratio, Log Scale</p></div>
<p>We see three very strange things. The first is Bash shooting up wildly. The second is that C# relative time <em>goes down</em> with the increasing board size. The third is that before <img src='http://l.wordpress.com/latex.php?latex=n%3D8&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n=8' title='n=8' class='latex' />, the results are fluctuating. The first is easily explained: Bash is incredibly slow. About 10,000 times as slow as the optimized compiled C++ version. It is so slow that the two last data points are <em>estimated</em> as it would have taken an extra week, or so, to get them. The second anomaly needs a bit more analysis. Looking at the raw timing data, we can see that the C# version seems to be needing an extra 7ms regardless of board size. I do not know where that comes from, as the timings do not time things such as program load and initialization, but only the solving of the puzzle itself. It may well be the JIT that takes a while to figure out that the recursive function is expensive and the run-time compilation takes 7ms? Anyway, would we remove this mysterious extra 7ms, the odd behaviour of the C# implementation would vanish. The third anomaly is easily explained by the granularity of the timer and the operating system; up to puzzle size of 8, the times are much less than 100 &#956;s for most implementations. Suffice to move the mouse and generate a couple of interrupts to throw timing off considerably.</p>
<p>Removing the small board sizes yields:</p>
<div id="attachment_1680" class="wp-caption aligncenter" style="width: 310px"><a href="http://hbfs.wordpress.com/files/2009/09/results-ratio-log-scale-wo-outliers.png"><img src="http://hbfs.wordpress.com/files/2009/09/results-ratio-log-scale-wo-outliers.png?w=300" alt="Speed Ratios, Log Scale, Without Outliers" title="results-ratio-log-scale-wo-outliers" width="300" height="251" class="size-medium wp-image-1680" /></a><p class="wp-caption-text">Speed Ratios, Log Scale, Without Outliers</p></div>
<p>which shows that the respective implementations are well behaved (except for C# and its most probably JIT-related extra 7ms).</p>
<p>So we see that Bash is about 10,000 times slower than the optimized C++ version. The constant-propagated version is only a bit (~5%) faster than the generic C++ version. The Java version takes about 1.5&#215; the time of the C++ version, which is way better than I expected&#8212;don&#8217;t forget that this is a native-code version of the Java program, it doesn&#8217;t run on the JVM. The C# version is twice as slow as the C++ version, which is somewhat disappointing but not terribly so. The Python versions are 120&#215; (for the more pythonesque version) and 200&#215; slower. That&#8217;s unacceptably slow, especially that the Python programs aren&#8217;t particularly fancy nor complex. We do see that using pythonesque idioms yields a nice performance improvement&#8212;40%&#8212;but that&#8217;s still nowhere useful.</p>
<p align="center">*<br />*&#8195;*</p>
<p>So what does this tell us? For one thing, that Bash is slow. But that Bash is slow even when it doesn&#8217;t use any external command should not come as a surprise. From what I understand from Bash, data structures are limited to strings and arrays. Lists and strings are the same. Basically, a list is merely a string with items separated by the <tt>IFS</tt> character(s), which causes all array-like accesses to lists to be performed in linear time as each time the string is reinterpreted given the current <tt>IFS</tt>. So even though a construct such as <tt>${x[i]}</tt> looks like random-access, it is not. As for explicitly constructed arrays (as opposed to lists), there seems to be a real random-access capability, but it&#8217;s still very slow. I do not think that bash uses something like a virtual machine and an internal tokenizer to speed up script interpretation. Maybe that&#8217;d be something to put on the to-do list for Bash 5? In any case, I also learnt that Bash is a lot more generic than I thought.</p>
<p>The other thing is that Python is not a programming language for <a href="http://en.wikipedia.org/wiki/CPU_bound" target="_blank">compute-bound</a> problems. This makes me question how far projects such as <a href="http://www.pygame.org/" target="_blank">Pygame</a> (which aims at developing a cromulent gaming framework for Python) can go. While all of the graphics and sound processing can be off-loaded to third party libraries written in C or assembly language and interacting with the platform-specific drivers, the central problem of driving the game itself remains complete. How do you provide strong non-player characters/opponents when everything is 100&#215; slower than the equivalent C or C++ program? What about strategy games? How can you build a <a href="http://en.wikipedia.org/wiki/Massively_multiplayer_online_role-playing_game" target="_blank">MMORPG</a> with a Python engine? Is a MMORPG I/O or compute bound? Could you write a championship-grade chess engine in Python?</p>
<p>My guess is that you just can&#8217;t.</p>
<p>And that&#8217;s quite sad because I <em>like</em> Python as a programming language. I used it in a number of (<a href="http://en.wikipedia.org/wiki/I/O_bound" target="_blank">I/O-bound</a>) mini-projects and I was each time delighted with the ease of coding compared to C or C++ (for those specific tasks). It pains me that Python is just too slow to be of any use whatsoever in scientific/high-performance computing. I wish for Python 4 to have a new virtual machine and interpreter to bring Python back with Java and C#, performance-wise. Better yet, why not have a true native compiler like <tt>gcj</tt> for Python?</p>
<p align="center">*<br />*&#8195;*</p>
<p>I am fully aware that the <img src='http://l.wordpress.com/latex.php?latex=n&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n' title='n' class='latex' /> queens on a <img src='http://l.wordpress.com/latex.php?latex=n%5Ctimes%7B%7Dn&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='n\times{}n' title='n\times{}n' class='latex' /> board puzzle is a toy problem of sorts. But its extreme simplicity and its somewhat universal backtracking structure makes it an especially adequate toy problem. If a language can&#8217;t handle such a simple problem very well, how can we expect it to be able to scale to much more complex problems like, say, a championship-level chess engine?</p>
<p align="center">*<br />*&#8195;*</p>
<p>The raw data (do not forget that the two last timings for Bash are estimated). All times are in seconds.</p>
<table border="1">
<tr>
<td>Language</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
<td>11</td>
<td>12</td>
<td>13</td>
<td>14</td>
<td>15</td>
</tr>
<tr>
<td>C++</td>
<td>0.000000</td>
<td>0.000002</td>
<td>0.000003</td>
<td>0.000046</td>
<td>0.000005</td>
<td>0.000012</td>
<td>0.000036</td>
<td>0.000126</td>
<td>0.000569</td>
<td>0.002973</td>
<td>0.016647</td>
<td>0.080705</td>
<td>0.448602</td>
<td>2.830424</td>
<td>18.648028</td>
</tr>
<tr>
<td>C++-fixed</td>
<td>0.000000</td>
<td>0.000001</td>
<td>0.000001</td>
<td>0.000007</td>
<td>0.000005</td>
<td>0.000011</td>
<td>0.000033</td>
<td>0.000104</td>
<td>0.000500</td>
<td>0.002369</td>
<td>0.011468</td>
<td>0.065407</td>
<td>0.462506</td>
<td>2.765098</td>
<td>18.032639</td>
</tr>
<tr>
<td>C#</td>
<td>0.007315</td>
<td>0.007260</td>
<td>0.008356</td>
<td>0.007302</td>
<td>0.007864</td>
<td>0.007451</td>
<td>0.007421</td>
<td>0.008287</td>
<td>0.008452</td>
<td>0.012481</td>
<td>0.033548</td>
<td>0.154490</td>
<td>0.877194</td>
<td>5.444645</td>
<td>35.769138</td>
</tr>
<tr>
<td>Java</td>
<td>0.000001</td>
<td>0.000002</td>
<td>0.000002</td>
<td>0.000003</td>
<td>0.000005</td>
<td>0.000015</td>
<td>0.000049</td>
<td>0.000198</td>
<td>0.000895</td>
<td>0.004244</td>
<td>0.022947</td>
<td>0.128498</td>
<td>0.692349</td>
<td>4.457763</td>
<td>29.321677</td>
</tr>
<tr>
<td>Python</td>
<td>0.000012</td>
<td>0.000029</td>
<td>0.000054</td>
<td>0.000136</td>
<td>0.000424</td>
<td>0.001708</td>
<td>0.006078</td>
<td>0.026174</td>
<td>0.115218</td>
<td>0.546922</td>
<td>2.822554</td>
<td>15.405020</td>
<td>91.170068</td>
<td>581.983903</td>
<td>3762.739785</td>
</tr>
<tr>
<td>Python-2</td>
<td>0.000012</td>
<td>0.000028</td>
<td>0.000045</td>
<td>0.000109</td>
<td>0.000318</td>
<td>0.001275</td>
<td>0.004125</td>
<td>0.017448</td>
<td>0.077854</td>
<td>0.348823</td>
<td>1.701767</td>
<td>9.349661</td>
<td>55.532111</td>
<td>339.244132</td>
<td>2259.010794</td>
</tr>
<tr>
<td>Bash</td>
<td>0.003054</td>
<td>0.010938</td>
<td>0.006067</td>
<td>0.011355</td>
<td>0.026913</td>
<td>0.091869</td>
<td>0.347451</td>
<td>1.472102</td>
<td>6.483076</td>
<td>30.813085</td>
<td>163.061341</td>
<td>891.828031</td>
<td>5031.663741</td>
<td>31746.000000</td>
<td>209162.000000</td>
</tr>
</table>
<p>The More Pythonesque version:</p>
<pre class="brush: python;">
#!/usr/bin/python -O
# -*- coding: utf-8 -*-

import sys
import time

########################################
##
##   (c) 2009 Steven Pigeon (pythonesque version)
##

diag45=set()
diag135=set()
cols=set()
solutions=0

########################################
##
## Marks occupancy
##
def mark(k,j):
    global cols, diag45, diag135
    cols.add(j);
    diag135.add(j+k)
    diag45.add(32+j-k)

########################################
##
## unmarks occupancy
##
def unmark(k,j):
    global cols, diag45, diag135
    cols.remove(j);
    diag135.remove(j+k)
    diag45.remove(32+j-k)

########################################
##
## Tests if a square is menaced
##
def test(k,j):
    global cols, diag45, diag135
    return not((j in cols) or \
        ((j+k) in diag135) or \
        ((32+j-k) in diag45))

########################################
##
## Backtracking solver
##
def solve( niv, dx ):
    global solutions, nodes
    if niv &#62; 0 :
        for i in xrange(0,dx):
            if test(niv,i) == True:
                mark ( niv, i )
                solve( niv-1, dx)
                unmark ( niv, i )
    else:
        for i in xrange(0,dx):
            if (test(0,i) == True):
                solutions += 1

########################################
##
## usage message
##
def usage( progname ):
    print &#34;usage: &#34;, progname, &#34; &#60;size&#62;&#34;
    print &#34;size must be 1..32&#34;

########################################
##
## c/c++-style main function
##
def main():
    if len(sys.argv) &#60; 2:
        usage(sys.argv[0])
    else:
        try:
            size = int(sys.argv[1])
        except:
            usage(sys.argv[0])
            return

        if (size &#60;= 32) &#38; (size&#62;0):

            start = time.time()
            solve(size-1,size)
            elapsed = time.time()-start

            print &#34;%s %0.6f&#34; % (solutions,elapsed)

        else:
            usage(sys.argv[0])
#
if __name__ == &#34;__main__&#34;:
    main()
</pre>
<p>The other versions can be found here in <a href="http://www.stevenpigeon.org/blogs/hbfs/super_reines.zip">super_reines.zip</a>. The Bash and C++ versions are somewhat Linux-specific.</p>
<hr align="left" width="30%">
<sup><a name="1">1</a></sup>&#160;A trick explained in detail in Brassard and Bratley, <i>Introduction à l&#8217;algorithmique</i>, Presses de l&#8217;Université de Montréal. Translated to English: <a href="http://www.amazon.com/gp/product/0133350681?ie=UTF8&#38;tag=hardbettfasts-20&#38;linkCode=xm2&#38;camp=1789&#38;creativeASIN=0133350681" target="_blank"><i>Fundamentals of Algorithmics</i></a> (at Amazon.com)</p>
<p><sup><a name="2">2</a></sup>&#160;Frédéric Marceau translated the program from C++ to C#. <a href="http://lostwebsite.wordpress.com/" target="_blank">François-Denis Gonthier</a> translated from C++ to Java.</p>
<p align="center">*<br />*&#8195;*</p>
<p>So I added a third Python version to the archive. I also benchmarked it. It is quite a bit faster than the original one, and even than the &#8216;pythonesque&#8217; version. For example:</p>
<pre class="brush: bash;">
$ super-reines.py 12
14200 15.966019
$ super-reines-2.py 12
14200 9.478235
$ super-reines-3.py 12
14200 6.845071
</pre>
<p>So a more &#8216;functional&#8217; version performs about 2.3&#215; faster than a direct translation from C++. For the same problem size, however, the C++ (fixed) version takes 0.069s&#8230; Roughly 100&#215; faster than the 3rd version.</p>
<div id="attachment_1899" class="wp-caption aligncenter" style="width: 310px"><a href="http://hbfs.wordpress.com/files/2009/11/results-ratio-log-scale-wo-outliers-2.png"><img src="http://hbfs.wordpress.com/files/2009/11/results-ratio-log-scale-wo-outliers-2.png?w=300" alt="results-ratio-log-scale-wo-outliers-2" title="results-ratio-log-scale-wo-outliers-2" width="300" height="251" class="size-medium wp-image-1899" /></a><p class="wp-caption-text">Speed Ratios, Log Scale, Without Outliers, with 3rd Python version</p></div> 
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MicroWar 2.0rc3 (Game)]]></title>
<link>http://macin.wordpress.com/2009/11/07/microwar-20rc3/</link>
<pubDate>Sat, 07 Nov 2009 08:38:22 +0000</pubDate>
<dc:creator>kabbala</dc:creator>
<guid>http://macin.wordpress.com/2009/11/07/microwar-20rc3/</guid>
<description><![CDATA[MicroWar 2.0rc3 Pierre-Alain Dorange | MadDog Production 음악: Louis Jullien, Justin D. Davis 매년 바뀌는 P]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div style="text-align:center;">
<table border="0" align="center">
<tbody>
<tr align="center">
<td width="48" valign="top"><a href="http://macin.wordpress.com/files/2009/11/microwar-2-0rc3-icon.png"><img src="http://macin.wordpress.com/files/2009/11/microwar-2-0rc3-icon.png?w=48" alt="MicroWar 2.0rc3 Icon" title="MicroWar 2.0rc3 Icon" width="48" height="48" class="alignnone size-thumbnail wp-image-10271" /></a></td>
<td><a href="http://sourceforge.net/projects/microwar/">MicroWar</a> 2.0rc3<br />
Pierre-Alain Dorange &#124; MadDog Production<br />
음악: Louis Jullien, Justin D. Davis</td>
</tr>
</tbody>
</table>
</div>
<p>매년 바뀌는 PC 시장과 싸우는 인베이더 스타일 게임. (via <a href="http://www.moongift.jp/2009/11/microwar/">MOONGIFT</a>)</p>
<div style="text-align:center;">무료 · <a href="http://sourceforge.net/projects/microwar/files/MacOS%20X/MicroWar-mac-20rc3.dmg/download">download at SourceForge.net</a></div>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Faça jogos em Python com Pygame]]></title>
<link>http://dotinfo.wordpress.com/2009/10/25/faca-jogos-em-python-com-pygame/</link>
<pubDate>Sun, 25 Oct 2009 13:22:33 +0000</pubDate>
<dc:creator>Everton da Rosa</dc:creator>
<guid>http://dotinfo.wordpress.com/2009/10/25/faca-jogos-em-python-com-pygame/</guid>
<description><![CDATA[Colaboração: Ricardo Takemura Para quem gosta de Python e jogos, existe um framework para desenvolvi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Colaboração: Ricardo Takemura</p>
<p>Para quem gosta de Python e jogos, existe um framework para desenvolvimento<br />
de jogos em Python chamado Pygame (<a href="http://www.pygame.org/news.html" target="_blank">http://www.pygame.org/news.html</a>).</p>
<p>O jogo mais famoso feito por esta plataforma é o [Frets On Fire<br />
<a href="http://fretsonfire.sourceforge.net/" target="_blank">http://fretsonfire.sourceforge.net/</a>].</p>
<p>Fonte: <a href="http://www.dicas-l.com.br/dicas-l/20091017.php" target="_blank">Dicas-L</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[A Simple Pygame Screen]]></title>
<link>http://sebastienayotte.wordpress.com/2009/10/23/a-simple-pygame-screen/</link>
<pubDate>Fri, 23 Oct 2009 18:29:18 +0000</pubDate>
<dc:creator>Sébastien Ayotte</dc:creator>
<guid>http://sebastienayotte.wordpress.com/2009/10/23/a-simple-pygame-screen/</guid>
<description><![CDATA[Here&#8217;s a simple example of a game screen written in Python and Pygame. import pygame from pyga]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Here&#8217;s a simple example of a game screen written in <a href="http://www.python.org/">Python</a> and <a href="http://www.pygame.org">Pygame</a>.</p>
<pre class="brush: python;">
import pygame

from pygame.locals import *

def main():
    # I'm initializing the game's screen.
    pygame.display.init()

    # I set the width and the height of the screen.
    screen = pygame.display.set_mode((300, 200))

    # I'm setting the title of the game's screen.
    pygame.display.set_caption(&#34;The game's title&#34;)

    # I want to hide the mouse when It over the game's screen.
    pygame.mouse.set_visible(0)

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:
                running = False

if __name__ == &#34;__main__&#34;:
    main()
</pre>
<p>Cheers <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Release 0.0.8C]]></title>
<link>http://pyrl.wordpress.com/2009/10/10/release-0-0-8b/</link>
<pubDate>Sat, 10 Oct 2009 06:21:15 +0000</pubDate>
<dc:creator>hahn</dc:creator>
<guid>http://pyrl.wordpress.com/2009/10/10/release-0-0-8b/</guid>
<description><![CDATA[Got a quick chunk of time to play around with this again.  The minimap is now working properly, and ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Got a quick chunk of time to play around with this again.  The minimap is now working properly, and that memory fix I talked about is now in.  The tileset may also have been tweaked, I&#8217;m not sure on that one.  <a href="http://sites.google.com/site/pyrlfiles/">Grab it here!</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Instalando o Python e o pygame]]></title>
<link>http://tangerinagames.wordpress.com/2009/10/08/instalando-o-python-e-o-pygame/</link>
<pubDate>Thu, 08 Oct 2009 02:58:21 +0000</pubDate>
<dc:creator>tangzero</dc:creator>
<guid>http://tangerinagames.wordpress.com/2009/10/08/instalando-o-python-e-o-pygame/</guid>
<description><![CDATA[Olá pessoal, continuando a série de posts sobre desenvolvimento de jogos, hoje vou falar sobre a ins]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Olá pessoal,</p>
<p>continuando a série de posts sobre desenvolvimento de jogos, hoje vou falar sobre a instalação do Python + pygame e quais ferramentas utilizar.</p>
<h3>Instalando o Python + pygame</h3>
<p>Os usuários do Windows, devem baixar o instalador do Python em <a href="http://www.python.org/download" target="_blank">http://www.python.org/download</a> e executá-lo. Eu aconselho a versão 2.6.3. Depois devem baixar o instalador do pygame em <a href="http://www.pygame.org/download.shtml" target="_blank">http://www.pygame.org/download.shtml</a> correspondente a versão do Python escolhido anteriormente. O processo é bem simples, não passa de um NNF (Next-Next-Finish).</p>
<p>Para os usuários do Ubuntu, basta executar no shell o comando:</p>
<pre class="brush: python;">
sudo apt-get install python-pygame
</pre>
<p><!--more--></p>
<h3>Qual editor ou IDE utilizar?</h3>
<p>Várias opções estão listadas no site do <a href="http://www.python.org.br/wiki/IdesPython" target="_blank">PythonBrasil</a>.</p>
<p>Eu aconselho utilizar um editor de texto simples com suporte a syntax highlight, ao invés de uma IDE pesada e cheia de recursos que, creio, não iremos precisar. Usuários do Windows podem utilizar o ótimo <a href="http://notepad-plus.sourceforge.net" target="_blank">Notepad++</a> ou um similar. No Linux, o Gedit, o Kate ou até mesmo o Vim são muito bem-vindos. Eu, pessoalmente, vou utilizar o <a href="http://www.e-texteditor.com/" target="_blank">E-TextEditor</a> que é um editor extremamente poderoso baseado no <a href="http://macromates.com/" target="_blank">TextMate</a>. Originalmente desenvolvido para o Windows, o E-TextEditor possui o código-fonte disponível no <a href="http://github.com/etexteditor/e" target="_blank">Github</a> para quem quiser se aventurar, como eu, a compilá-lo no Linux.</p>
<h3>Nosso primeiro programa com o pygame</h3>
<p>Salve o código a seguir em um arquivo chamado jogo.py.</p>
<pre class="brush: python;">
# importa as bibliotecas necessarias
import sys, pygame

# inicia o pygame
pygame.init()

# define o tamanho da tela
screen_size = (400, 300)

# define as cores utilizadas
white = (255, 255, 255)
black = (0, 0, 0)

# cria a tela com o tamanho especificado e seta o titulo da mesma
screen = pygame.display.set_mode(screen_size)
pygame.display.set_caption(&#34;Primeiro Programa&#34;)

# obtem uma fonte de tamanho 30. Nesse caso, usa a default do sistema
font = pygame.font.Font(None, 30)

# renderiza um texto.
# o segundo parametro especifica se deve utilizar antialias
# o terceiro e o quarto sao a cor do texto e a cor do fundo
text = font.render(&#34;Primeiro programa com pygame!&#34;, True, white, black)

# obtem o quadrante do texto, ou seja, a area do mesmo
text_rect = text.get_rect()

# posiciona a area do texto no centro da tela
text_rect.centerx = screen.get_rect().centerx
text_rect.centery = screen.get_rect().centery

# desenha o texto na tela
screen.blit(text, text_rect)

# atualiza a tela exibindo o texto
pygame.display.update()

while True:
  # itera no pool de eventos capturados
  for event in pygame.event.get():
    # se a janela for fechada, finaliza o programa
    if event.type == pygame.QUIT:
      sys.exit()
</pre>
<p>Depois basta executar na linha de comando:</p>
<pre class="brush: python;">
python jogo.py
</pre>
<p>O resultado é esse:</p>
<p><img class="aligncenter size-full wp-image-35" title="Primeiro Programa" src="http://tangerinagames.wordpress.com/files/2009/10/primeiro-programa.png" alt="Primeiro Programa" width="410" height="326" /></p>
<p>Enfim, finalmente começamos a colocar a mão na massa. Creio que o exemplo é bem simples e claro, por isso não irei entrar em detalhes agora.</p>
<p>No próximo post, iremos discutir as principais técnicas de Game Loop e criar a estrutura básica de nosso jogo.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Developing a game.]]></title>
<link>http://phelerox.wordpress.com/2009/10/04/developing-a-game/</link>
<pubDate>Sun, 04 Oct 2009 13:55:35 +0000</pubDate>
<dc:creator>Marco Baxemyr</dc:creator>
<guid>http://phelerox.wordpress.com/2009/10/04/developing-a-game/</guid>
<description><![CDATA[Yet again, it&#8217;s been a while since I wrote here. I apologize for being so irregular &#8211; bu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Yet again, it&#8217;s been a while since I wrote here. I apologize for being so irregular &#8211; but at least I&#8217;m considerbly better at regular <a href="http://www.twitter.com/phelerox">microblogging</a>. Social Media rocks!</p>
<p>So, my current software project is a <a href="http://en.wikipedia.org/wiki/Tower_Defense">Tower Defense</a>-game. It&#8217;s actually my project for the <a href="http://en.wikipedia.org/wiki/Gymnasium_(school)" target="_blank">Gymnaisum</a> (Swedish) course PA1201 (the purpose of which is to do a major project). The scope of the course is 100 hours of dedicated school-time (ending in spring), so this is a serious project.  I have already spent countless of hours on it, and the current version can be found <a href="https://code.launchpad.net/~baxemyr/+junk/towerdefense" target="_blank">here</a> (revision 35 at the time of writing).</p>
<p>I&#8217;d love all sorts of feedback. Unfortunately, it&#8217;s slightly messy to get it to work right now. First off you need the version control system <a href="http://bazaar-vcs.org/">Bazaar</a> to fetch the game from launchpad (by typing &#8220;bzr branch lp:~baxemyr/+junk/towerdefense&#8221; in a command line), and then you need <a href="http://www.python.org">python</a> and <a href="http://www.pygame.org">pygame</a> installed to play the game.</p>
<p><img class="alignright size-medium wp-image-276" title="TowerDefense5" src="http://phelerox.wordpress.com/files/2009/10/towerdefense5.png?w=300" alt="TowerDefense5" width="300" height="234" /></p>
<p>Besides, it is barely worth the trouble right now due to the small amount of content &#8212; even though the game itself is shaping upnicely! Nonetheless, feedback is warmly appreciated (user interface design, feature requests and anything else you can think of)!</p>
<p>I&#8217;m planning for a proper demo release later this year, to maximize feedback reception before it&#8217;s too late. Hopefully with compiled windows executables etc so that you won&#8217;t need to install anything!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Memory, Python, and You.]]></title>
<link>http://pyrl.wordpress.com/2009/09/27/memory-python-and-you/</link>
<pubDate>Sun, 27 Sep 2009 18:38:01 +0000</pubDate>
<dc:creator>hahn</dc:creator>
<guid>http://pyrl.wordpress.com/2009/09/27/memory-python-and-you/</guid>
<description><![CDATA[Rather recently I learned about a handy little program called Valgrind. I get to use it to debug som]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Rather recently I learned about a handy little program called <a href="http://valgrind.org/">Valgrind</a>.  I get to use it to debug some C++ code that works with dynamic memory to fix any leaks that occurred.  As it turns out, this program can do a lot more.</p>
<p>Something I&#8217;ve noticed for a while now is that Graff takes up a pretty significant amount of memory&#8211;around 40 megabytes of RAM.  I never really thought about it too hard until now, but I discovered that with the command:</p>
<pre class="brush: plain;">valgrind --tool=massif python Start.py
...
ms_print massif.out.** &#62; output</pre>
<p>it takes snapshots of Graff&#8217;s memory usage.  The first time running this and opening up &#8220;output&#8221; gives this result:</p>
<p><a href="http://pyrl.wordpress.com/files/2009/09/mem1.png"><img src="http://pyrl.wordpress.com/files/2009/09/mem1.png?w=300" alt="mem1" title="mem1" width="300" height="176" class="alignnone size-medium wp-image-424" /></a></p>
<p>So currently I get ~43MB usage of the heap (or in python terms, plain memory) by just opening up the program and running around.  Later in that output file, I notice a lot of calls to &#8220;SDL_CreateRGBSurface (in /usr/lib/libSDL-1.2.so.0.11.2)&#8221; seem to be eating up the most memory percentage-wise.  </p>
<p>Doing some digging, I find out pygame converts images into a .RAW format for fast blitting&#8211;unfortunately, the file size is pretty hefty.  Looking through my code, I notice that within Entity.py, when an entity is initialized, it loads up a file called &#8220;tiles.png&#8221; to pull the entity&#8217;s picture out of that and use it.  After that, that loaded image is just kept there, permanently until the program quits.  Tiles.png is only 42.3KB, though, which seems a little weird.</p>
<p>I decide to see just how many times entity loads up this image and stores it away forever.  It turns out that this file is being loaded around 200 times, and is then saved as a member variable &#8220;self.sheet&#8221;.  Since we don&#8217;t need it anymore once the entity&#8217;s image is ripped out of that sprite sheet, I decide to add one extra line to my code:
<pre class="brush: plain;">delete self.sheet</pre>
<p>, after the entity&#8217;s image is set.  What does that memory chart look like now?</p>
<p><a href="http://pyrl.wordpress.com/files/2009/09/mem2.png"><img src="http://pyrl.wordpress.com/files/2009/09/mem2.png?w=300" alt="mem2" title="mem2" width="300" height="176" class="alignnone size-medium wp-image-425" /></a></p>
<p>15.64 MB is now used.  By adding one extra line of code to delete an unused part of the code, I cut memory usage by 2/3!</p>
<p>Tinkering around some more, I find the pygame init routines take up a total of about 5MB, which means the code portion that I wrote takes up about 10MB of RAM.  Perhaps now I&#8217;ll start paying attention to where memory ends up in Graff.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Map generation #4.5 - tidying up some ends]]></title>
<link>http://pyrl.wordpress.com/2009/09/26/map-generation-4-5-tidying-up-some-ends/</link>
<pubDate>Sun, 27 Sep 2009 03:04:15 +0000</pubDate>
<dc:creator>hahn</dc:creator>
<guid>http://pyrl.wordpress.com/2009/09/26/map-generation-4-5-tidying-up-some-ends/</guid>
<description><![CDATA[In my last post about this map-making process, I seemed to have left off at the part where the image]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In my last post about this map-making process, I seemed to have left off at the part where the image itself is generated in its own separate program.  Converting this image into a matrix for use in Graff was relatively straightforward.  Pygame&#8217;s surfarray module allows one to access a surface (the screen) and treat it as a matrix of color values.  From there I pulled out the color, used a dict datatype to convert that color into a tile type, and then write that into a matrix for use with the Graff; that wasn&#8217;t much of a problem.</p>
<p>However, one glitch I&#8217;ve noticed is that often the map would have some holes in it&#8211;it seemed like the algorithm would skip over a tile, perhaps because it couldn&#8217;t find a properly-fitting tile, so sometimes you get things that looked like this:</p>
<p><a href="http://pyrl.wordpress.com/files/2009/09/screenshot4.png"><img src="http://pyrl.wordpress.com/files/2009/09/screenshot4.png?w=300" alt="glitchy tiles" title="glitchy tiles" width="300" height="225" class="alignnone size-medium wp-image-416" /></a></p>
<p>As it turns out, that was the case.  I simply did not make enough tiles to cover each possible combination.  After thinking that I&#8217;d have to make a mind-boggling number of additions to the 6&#215;6 tile pieces I already have, I edited the code so that if the tile it needed could not be found, it should spit out that key combination and then I&#8217;d see where that would take me.  Altogether, only about 30 &#8220;impossible&#8221; combinations of tiles ever seemed to come up, so I just added those extra ones onto the tileset.</p>
<p>After doing that, the results are much cleaner.  Some glitches still remain (mainly I missed a few combinations, it seems), and I&#8217;ll probably adapt this to work with a smaller scale (say 3&#215;3 instead of 6&#215;6) or make changes to it to develop other areas, but I think I&#8217;ve just about exhausted the usefulness of posting about this process.</p>
<p><a href="http://pyrl.wordpress.com/files/2009/09/screenshot_2.png"><img src="http://pyrl.wordpress.com/files/2009/09/screenshot_2.png?w=300" alt="Still a little glitchy, but better!" title="Still a little glitchy, but better!" width="300" height="225" class="alignnone size-medium wp-image-418" /></a></p>
<p>Oh, there is also the problem of the map not always being one complete piece.  I still haven&#8217;t decided in what way I&#8217;ll solve that one yet, but there are some more interesting questions about Graff that I think I need to find an answer to first.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Playing With Python]]></title>
<link>http://calmcrisis.wordpress.com/2009/09/17/playing-with-python/</link>
<pubDate>Thu, 17 Sep 2009 08:10:54 +0000</pubDate>
<dc:creator>CalmCrisis</dc:creator>
<guid>http://calmcrisis.wordpress.com/2009/09/17/playing-with-python/</guid>
<description><![CDATA[Right off the bat, let me be clear, we&#8217;re talking Python the programming language here, not Py]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Right off the bat, let me be clear, we&#8217;re talking <a href="http://www.python.org/">Python the programming language</a> here, not Python the snake.  While not impossible, it is highly unlikely you&#8217;ll see me talking about playing with a snake.</p>
<p>So, I&#8217;m gonna get python installed and check out some comparisons between <a href="http://www.pygame.org/news.html">pygame</a> and <a href="http://www.pyglet.org/">pyglet</a>.  They are a couple of libraries intended to provide some of the constructs needed for game development.  I&#8217;ve used pygame before, but that was a couple of years ago.  I want to make sure that it is still a viable choice of api before I jump back into using it.</p>
<p>After I get them installed, I&#8217;m gonna try to put together a few simple games with it.  Python is not my language of choice by any means (C# has that title), but I do like it quite a bit.</p>
<p>The plan is to make the choice and have the chosen platform installed within the next 2 days or so.  And from there, I&#8217;ll get down to the business of deciding what little game(s) I&#8217;m gonna make and get some posting done on my progress.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[dasclient early alpha screenshot ]]></title>
<link>http://synnax.wordpress.com/2009/09/13/dasclient-early-alpha-screenshot/</link>
<pubDate>Sun, 13 Sep 2009 05:36:56 +0000</pubDate>
<dc:creator>daspork</dc:creator>
<guid>http://synnax.wordpress.com/2009/09/13/dasclient-early-alpha-screenshot/</guid>
<description><![CDATA[dasclient early alpha screenshot Originally uploaded by dasp0rk Just a little look at what I have go]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><div style="float:right;margin-left:10px;margin-bottom:10px;"><a title="photo sharing" href="http://www.flickr.com/photos/38322776@N04/3914102619/"><img style="border:solid 2px #000000;" src="http://farm4.static.flickr.com/3502/3914102619_378c49595c_m.jpg" alt="" /></a></p>
<p><span style="font-size:.9em;margin-top:0;"><br />
<a href="http://www.flickr.com/photos/38322776@N04/3914102619/">dasclient early alpha screenshot </a></p>
<p>Originally uploaded by <a href="http://www.flickr.com/people/38322776@N04/">dasp0rk</a><br />
</span></div>
<p>Just a little look at what I have going on the client so far. The widgets are part of a UI library that I have updated and developed for years called clad. I have only used it for my own projects, but it&#8217;s pretty nice if I do say so myself. The life/mana/stamina bars are all custom widgets derived from the base widgets of clad and fully functional (even the text entry!). The four blue squares are the beginnings of re-programmable hotkeys/aliases. I have no plan to support the mouse with the client. I don&#8217;t see any reason to personally as re-mappable keys could surely do just as good a job, and the code required to do very complicated operations is much lighter. More updates to come if this can hold my interest.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[0.0.8]]></title>
<link>http://pyrl.wordpress.com/2009/09/12/0-0-8/</link>
<pubDate>Sat, 12 Sep 2009 17:54:38 +0000</pubDate>
<dc:creator>hahn</dc:creator>
<guid>http://pyrl.wordpress.com/2009/09/12/0-0-8/</guid>
<description><![CDATA[Release here! This&#8217;ll probably be the last update for a few weeks. Trying to go back to Python]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://sites.google.com/site/pyrlfiles/">Release here!</a></p>
<p>This&#8217;ll probably be the last update for a few weeks.  Trying to go back to Python after spending a few weeks of working with C++ feels so..different.  I might switch this project over to C++ if I get equated well enough with it, or maybe I&#8217;ll just start working on a C++ project instead and keep this around too.  Busy busy busy.  Either way, more activity will come in December or so.</p>
<p>The only glitch I&#8217;ve noticed with this release is the minimap is a little screwy.  I know why it doesn&#8217;t work, but if I hold off on this until I fix it, it&#8217;ll be even longer before this post comes up.</p>
<p>CHANGES:<br />
&#160;&#160;&#160;Added a (barebones) title screen.<br />
&#160;&#160;&#160;Custom keybindings via title screen.<br />
&#160;&#160;&#160;Added &#8220;Key&#8221; py file and an ini file for manual editing if need be.<br />
&#160;&#160;&#160;Digging function cleaned up somewhat.<br />
&#160;&#160;&#160;Integrated new map generator.<br />
&#160;&#160;&#160;&#160;&#160;&#160;A fully glitch-free version is finished, I just need to update it.<br />
&#160;&#160;&#160;Changed scrolling/grass behaviors for more natural movement.<br />
&#160;&#160;&#160;Automatic screenshots placed in the Screenshots directory.  Use the SCROLL LOCK key.</p>
<p>Additionally on that page under Misc, I&#8217;ve added in a dialog.py / dialog.txt file to show how my dialogue system will hopefully work.  Run it through the terminal</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Semi-graphical MUDs]]></title>
<link>http://synnax.wordpress.com/2009/09/09/semi-graphical-muds/</link>
<pubDate>Wed, 09 Sep 2009 08:29:02 +0000</pubDate>
<dc:creator>daspork</dc:creator>
<guid>http://synnax.wordpress.com/2009/09/09/semi-graphical-muds/</guid>
<description><![CDATA[I&#8217;m thinking about picking up an old project again. For a while I was enjoying playing MUDs. I]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I&#8217;m thinking about picking up an old project again. For a while I was enjoying playing MUDs. I often wondered why there had never really been a hybrid MUD out there. Something not graphical really, but with just a GUI. I have already made some headway on a client that will work on any platform that has the ability to use python and pygame. The client can even be packaged with all the dependencies needed to play it.</p>
<p>The server portion of the game is the hard part. I have had a little luck with NakedMud, and also modifying the last and most up to date version of Circle.</p>
<p>The type of game I really want to make would be similar to classic Everquest. I had a lot of fun with that game and think it could be captured in this way.</p>
<p>More to come.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[OpenGL in Pygame Tutorial - Part 3]]></title>
<link>http://pypede.wordpress.com/2009/09/05/opengl-in-pygame-tutorial-part-3/</link>
<pubDate>Sat, 05 Sep 2009 18:24:51 +0000</pubDate>
<dc:creator>pede</dc:creator>
<guid>http://pypede.wordpress.com/2009/09/05/opengl-in-pygame-tutorial-part-3/</guid>
<description><![CDATA[Seid Ihr zum ersten mal hier, dann startet Ihr am besten mit Part 1. Moin moin und willkommen zum dr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><em>Seid Ihr zum ersten mal hier, dann startet Ihr am besten mit <a href="http://pypede.wordpress.com/2009/08/30/opengl-in-pygame-tutorial-part-1/">Part 1</a>.</em></p>
<p>Moin moin und willkommen zum dritten Part dieses Tutorials. In den ersten beiden Parts haben wir die Pygame-Segel gesetzt, nun geht es etwas schneller voran. Diesmal erobern wir mit unserem Tutorial-Kutter das OpenGL-Meer. Am Ende dieses Parts wird endlich etwas zu sehen sein, und zwar: Ein Viereck!</p>
<p>Damit wir die OpenGL-Schnittstelle nutzen können, importieren wir die PyOpenGL-Module. GL stellt einerseits OpenGL-Funktionen bereit, die mit gl beginnen (Beispiel: <code>glVertex()</code>) und andererseits Konstanten, die mit GL_ beginnen (Beispiel: <code>GL_QUADS</code>).<br />
Mit GLU (<strong>GL U</strong>tility Library) werden weitere hilfreiche Funktionen und Konstanten nach dem gleichen Präfixmuster importiert (Beispiele: <code>gluScaleImage</code>, <code>GLU_FILL</code>).</p>
<pre class="brush: python;">
from OpenGL.GL import *
from OpenGL.GLU import *
</pre>
<p>Als nächstes definieren wir eine Funktion namens reshape(), die jedesmal aufgerufen werden soll, wenn das Fenster neu angezeigt wird, oder die Fenstergröße verändert wird.<br />
<code>glViewport</code> legt dabei ein Rechteck fest, in dessen Bereich wir unsere Vierecke zeichnen wollen. Es erstreckt sich von unten links (0,0) bis oben rechts (width,height, also 800,600).<br />
Die Zeilen 3-6 beschäftigen sich mit Matrizen. Dazu mehr im nächsten Part.</p>
<pre class="brush: python;">
def reshape((width,height)):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(60, 1.0*width/height, 0.1, 1000.0)
    glMatrixMode(GL_MODELVIEW)
</pre>
<p>Nun definieren wir eine init() Funktion, die zu Beginn des Programms aufgerufen wird und einige Eigenschaften unserer OpenGL-Umgebung festlegt. <code><strong>glClearColor</strong></code> legt eine weiße Hintergrundfarbe fest und erwartet dabei 4 Parameter: Rot-, Grün- und Blau-Anteil sowie den Alphawert.<br />
Außerdem wird hier unsere reshape()-Funktion zum ersten mal aufgerufen.</p>
<pre class="brush: python;">
def init():
    glClearColor(1.0, 1.0, 1.0, 1.0)
    reshape(screen)
</pre>
<p>Später im Tutorial fügen wir hier noch weitere OpenGL-Funktionen hinzu. Gleich gehts ans Zeichnen, aber zunächst ein wenig OpenGL-Vokabular:</p>
<p><strong>Primitive</strong><br />
Primitives sind geometrische Grundformen, wie zum Beispiel Punkte, Linien oder Polygone. Diese lassen sich zusammensetzen und ergeben dann komplexere geometrische Formen.</p>
<p><strong>Vertex</strong><br />
Ein Vertex (Plural: Vertices) ist ein Eckpunkt eines Primitives, dessen Position mit Koordinaten festgelegt wird. In OpenGL können mindestens zwei Koordinaten (X,Y) und maximal drei Koordinaten (X,Y,Z,W) angegeben werden, wobei X,Y und Z die 3D-Koordinaten sind. W findet hier zunächst keine Beachtung. Bei 2D-Darstellungen ist die Z-Koordinate immer 0.</p>
<p><strong>Polygon</strong><br />
Ein Polygon ist eine aus mindestens drei Vertices bestehendes Vieleck. Das einfachste Polygon ist das Dreieck</p>
<p>Gentlemen, take your Bleistifts, das Malen kann beginnen. Zunächst definieren wir eine draw-Funktion. In dieser wird zunächst der Bildschirm geleert und mit der oben definierten Hintergrundfarbe (weiß) gefüllt. </p>
<pre class="brush: python;">
def draw():
    glClear(GL_COLOR_BUFFER_BIT&amp;#124;GL_DEPTH_BUFFER_BIT)
    ...
</pre>
<p>Die draw-Funktion geht noch weiter. In OpenGL gibt es eine &#8220;virtuelle Kamera&#8221;, die aufnimmt, was später am Bildschirm zu sehen ist. Mit <code>gluLookAt</code> können wir Position und Ausrichtung (<em>orientation</em>) dieser Kamera bestimmen. Die ersten drei Parameter (0, 0, 6) bestimmen die Koordinaten der Position, also 6 Einheiten die Z-Achse entlang (Richtung Betrachter). Wir gehen mit der Kamera also im Prinzip 6 &#8220;Schritte&#8221; zurück, damit wir etwas sehen.</p>
<p>Die nächsten drei Parameter (0, 0, -100) bestimmen die Koordinaten eines Punktes, auf den die Kamera gerichtet sein soll. In unserem Fall ein negativer Wert auf der Z-Achse (in den Bildschirm hinein). Die letzten drei Parameter (0, 1, 0) bestimmen, wo oben ist. Hier also die Y-Achse gerade nach oben.<br />
Die Funktion <code>glLoadIdentity()</code> wird aufgerufen, um die Einheitsmatrix (<em>identity matrix</em>) zu laden. Somit wird bestimmt, dass die nachfolgende Funktion vom Ursprung des Koordinatensystems (0,0,0) ausgehen soll.</p>
<pre class="brush: python;">
    ...
    glLoadIdentity()
    gluLookAt(0, 0, 6, 0, 0, -100, 0, 1 ,0)
    ...
</pre>
<p>Jetzt zeichnen wir die ersten Primitives. Innerhalb von <code>glBegin(GL_QUADS)</code> und glEnd() bestimmen wir die Vertices unseres Vierecks (Quads). <code>glBegin</code> erwartet als Parameter den Typen des Primitives. Zum Beispiel GL_POLYGON für Polygone oder GL_QUADS für Vierecke. Es existiert eine sehr gute vollständige <a href="http://wiki.delphigl.com/index.php/glBegin#Parameter">Liste der Primitive-Typen (inkl. Erläuterungen)</a> im Wiki der Delphi-OpenGL-Community.</p>
<p>Als Nächstes bestimmen wir blau (0.0, 0.0, 1.0) als Füllfarbe. Anschließend werden nacheinander die vier Vertices des ersten Vierecks bestimmt. glVertex2f erwartet dabei die X,Y Koordinaten eines Vertex als Parameter.</p>
<p>Später werden wir sehen, dass es effektivere Möglichkeiten gibt, Primitives zu zeichnen. Zum Beispiel <em>Vertex-Arrays</em>. Aber zu Beginn ist es so in Ordnung. Wir wollen ja nur ein Viereck darstellen.</p>
<pre class="brush: python;">
    ...
    glBegin(GL_QUADS)
    glColor(0, 0, 1.0)
    glVertex2f(-2, 2)  # oben links
    glVertex2f(2, 2)   # oben rechts
    glVertex2f(2, -1)  # unten rechts
    glVertex2f(-2, -1) # unten links
    glEnd()   

    pygame.display.flip()
</pre>
<p><code>pygame.display.flip()</code> bewirkt einen <em>OpenGL Buffer Swap</em>. Dazu später mehr, wenn es zu Bewegtbildern kommt. Zunächst genügt die Erklärung, dass diese Funktion den Bildschirminhalt aktualisiert.</p>
<p>An dieser Stelle ein kleiner Einschub zum Thema OpenGL-Syntax. Der Funktionsname <code>glVertex2f</code> sieht ja schon etwas eigenartig aus. Die Erklärung ist allerdings recht simpel. Das angehängte <code><strong>2f</strong></code> bedeutet, dass die Funktion <strong>2</strong> Parameter (X,Y Koordinaten) des OpenGL-Datentyps <strong>f</strong>loat erwartet. Es gibt von vielen OpenGL Funktionen verschiedene Versionen (zum Beispiel <code>glVertex3f</code>, <code>glVertex4i</code>, &#8230;).</p>
<p>Nun rufen wir die draw-Funktion innerhalb unseres <em>main loops</em> auf. Das bewirkt, dass das Bild mit jedem Schleifendurchlauf einmal aktualisiert wird. Das macht bisher noch nicht soviel Sinn, aber wenn später Bewegung ins Spiel kommt, ist es unverzichtbar.</p>
<pre class="brush: python;">
def main():
    init()
    maxfps = 100
    clock = pygame.time.Clock()
    while True:
        clock.tick(maxfps)
        draw()
        get_event()

if __name__ == &quot;__main__&quot;:
    main()
</pre>
<p>So sieht unser Ergebnis aus, wenn wir das Programm ausführen:</p>
<div id="attachment_199" class="wp-caption alignnone" style="width: 310px"><a href="http://pypede.wordpress.com/files/2009/09/opengl_tut3.png"><img src="http://pypede.wordpress.com/files/2009/09/opengl_tut3.png?w=300" alt="Tutorial Part 3 - Ergebnis" title="opengl_tut3-1" width="300" height="232" class="size-medium wp-image-199" /></a><p class="wp-caption-text">Tutorial Part 3 - Ergebnis</p></div>
<p><a href="http://paste.pocoo.org/show/138219/" target="_blank">Der vollständige Quellcode zum dritten Tutorial-Part (ausgelagert)</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[pyEmpires v0.2]]></title>
<link>http://prokaryot.wordpress.com/2009/09/05/pyempires-v0-2/</link>
<pubDate>Sat, 05 Sep 2009 00:48:20 +0000</pubDate>
<dc:creator>prokaryot</dc:creator>
<guid>http://prokaryot.wordpress.com/2009/09/05/pyempires-v0-2/</guid>
<description><![CDATA[Version 0.2 is out! Hurray! First: old post: http://wp.me/pp3Ng-Z Update: pyEmpires is GPLed! New sc]]></description>
<content:encoded><![CDATA[Version 0.2 is out! Hurray! First: old post: http://wp.me/pp3Ng-Z Update: pyEmpires is GPLed! New sc]]></content:encoded>
</item>
<item>
<title><![CDATA[Motorists, Pygame and Chaitu]]></title>
<link>http://lafootrix.wordpress.com/2009/09/05/motorists-pygame-and-chaitu/</link>
<pubDate>Fri, 04 Sep 2009 19:41:59 +0000</pubDate>
<dc:creator>punchagan</dc:creator>
<guid>http://lafootrix.wordpress.com/2009/09/05/motorists-pygame-and-chaitu/</guid>
<description><![CDATA[Well, here&#8217;s some lafootgiri I&#8217;ve been upto. I had been trying out some pygame and I mad]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Well, here&#8217;s some lafootgiri I&#8217;ve been upto.<br />
I had been trying out some pygame and I made this image. It&#8217;s actually a screenshot of an animation that my code generates.<br />
<a href="http://lafootrix.wordpress.com/files/2009/09/25lines.png"><img src="http://lafootrix.wordpress.com/files/2009/09/25lines.png" alt="" title="" width="632" height="474" class="aligncenter size-full wp-image-443" /></a><br />
The number of lines actually keep reducing, and the density of the mesh keeps going down. </p>
<p>I showed Chaitu this code, and he suggested me to write code for an interesting problem, that was in <a href="http://en.wikipedia.org/wiki/Harish_Chandra_Verma">H C Verma</a>. </p>
<blockquote><p>Three motorists, are travelling at a constant speed, each one moving towards the guy on his right. </p></blockquote>
<p><a href="http://lafootrix.wordpress.com/files/2009/09/10motorists1.png"><img src="http://lafootrix.wordpress.com/files/2009/09/10motorists1.png" alt="" title="" width="632" height="494" class="aligncenter size-full wp-image-442" /></a><br />
I wrote code that takes any value of n as input and shows the motorists moving. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /><br />
I&#8217;m having fun!<br />
Pygame Rocks!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[OpenGL in Pygame Tutorial - Part 2]]></title>
<link>http://pypede.wordpress.com/2009/09/02/opengl-in-pygame-tutorial-part-2/</link>
<pubDate>Wed, 02 Sep 2009 12:50:45 +0000</pubDate>
<dc:creator>pede</dc:creator>
<guid>http://pypede.wordpress.com/2009/09/02/opengl-in-pygame-tutorial-part-2/</guid>
<description><![CDATA[Seid Ihr zum ersten mal hier, dann startet Ihr am besten mit Part 1. Ziel von Part 2 ist das simple ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><em>Seid Ihr zum ersten mal hier, dann startet Ihr am besten mit <a href="http://pypede.wordpress.com/2009/08/30/opengl-in-pygame-tutorial-part-1/">Part 1</a>.</em></p>
<p>Ziel von Part 2 ist das simple Anzeigen eines Pygame-Fensters und die Möglichkeit dieses wieder zu schließen. </p>
<p>Zunächst importieren wir das Pygame-Paket und alle seine Untermodule (z.B. pygame.display, pygame.sound, &#8230;), sowie die exit-Funktion aus dem sys-Modul.</p>
<pre class="brush: python;">
import pygame
from sys import exit
</pre>
<p>Hier wird die Auflösung des Fensters in einem Tupel als Variable <code>screen</code> gespeichert:</p>
<pre class="brush: python;">
screen = (800,600)
</pre>
<p>In folgender Zeile werden alle Untermodule von pygame initialisiert:</p>
<pre class="brush: python;">
pygame.init()
</pre>
<p>Die Funktion im folgenden Code-Abschnitt erstellt eine Pygame-Oberfläche und erwartet drei Parameter, von denen die letzten beiden optional sind. Der erste Parameter bestimmt die Auflösung (Variable <code>screen</code>). Im zweiten (optionalen) Parameter legen wir Flags fest, die bestimmen, dass eine OpenGL-Oberfläche erstellt werden soll, die einen doppelten Puffer nutzt. Es gibt noch weitere Flags, die zunächst nicht wichtig sind. Der dritte (optionale) Parameter ist die Farbtiefe in Bit.<br />
Die Funktion <code>pygame.display.set_mode</code> gibt ein Oberflächen-Objekt (surface object) zurück, das wir in der Variable <code>surface</code> speichern.</p>
<pre class="brush: python;">
surface = pygame.display.set_mode(screen, pygame.OPENGL&amp;#124;pygame.DOUBLEBUF, 16)
</pre>
<p>Als nächstes geben wir dem Pygame-Fenster einen Namen, der in der Titelleiste des Fensters erscheint.</p>
<pre class="brush: python;">
pygame.display.set_caption(&quot;Hallo Welt!&quot;)
</pre>
<p>Innerhalb der Funktion get_input() werden Events erkannt und bearbeitet. Ein Event kann ein Tastenanschlag auf der Tastatur sein, oder in unserem Beispiel das Klicken auf den Schließen-Button des Fensters.</p>
<pre class="brush: python;">
def get_event():
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
</pre>
<p>Nun benötigen wir den <em>main loop</em>, damit das Fenster sichtbar bleibt. Hier wartet das Programm auf Events. Der Codeabschnitt clock.tick(maxfps) sorgt dafür, dass Frames per Second (FPS) begrenzt werden. Das ist deshalb sinnvoll, um die CPU-Auslastung gering zu halten. Andernfalls würde die Schleife so schnell es geht durchlaufen werden. Später bringen wir hier weitere Dinge unter.</p>
<pre class="brush: python;">
def main():
    maxfps = 100
    clock = pygame.time.Clock()
    while True:
        clock.tick(maxfps)
        get_event()

if __name__ == &quot;__main__&quot;:
    main()
</pre>
<p>Führt man das Programm aus, erscheint ein schwarzes Fenster mit dem Titel &#8220;Hallo Welt!&#8221;, das quasi danach schreit, gleich wieder geschlossen zu werden <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Aber keine Angst, im nächsten Part wird es mehr zu sehen geben!</p>
<p>Hier noch einmal der komplette Quellcode aus Part 2 des Tutorials:</p>
<pre class="brush: python;">
import pygame
from sys import exit

screen = (800,600)

pygame.init()
surface = pygame.display.set_mode(screen, pygame.OPENGL&amp;#124;pygame.DOUBLEBUF, 16)
pygame.display.set_caption(&quot;Hallo Welt!&quot;)

def get_event():
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()

def main():
    maxfps = 100
    clock = pygame.time.Clock()
    while True:
        clock.tick(maxfps)
        get_event()

if __name__ == &quot;__main__&quot;:
    main()
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[OpenGL in Pygame Tutorial - Part 1]]></title>
<link>http://pypede.wordpress.com/2009/08/30/opengl-in-pygame-tutorial-part-1/</link>
<pubDate>Sun, 30 Aug 2009 17:58:05 +0000</pubDate>
<dc:creator>pede</dc:creator>
<guid>http://pypede.wordpress.com/2009/08/30/opengl-in-pygame-tutorial-part-1/</guid>
<description><![CDATA[An dieser Stelle startet mein Tutorial zu OpenGL in Pygame. Das Ziel dieses Tutorials ist ein in Pyt]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>An dieser Stelle startet mein Tutorial zu OpenGL in Pygame. Das Ziel dieses Tutorials ist ein in <em>Python 2.6</em> geschriebenes Programm, das ein 3D-Objekts darstellt, das sich mit Hilfe eines Gamepads bewegen lässt. Das Hauptaugenmerk liegt dabei auf OpenGL.</p>
<p>Wenn Ihr folgen wollt, solltet ihr bereits Python-Kenntnisse besitzen. Pygame-Kenntnisse sind nicht unbedingt Voraussetzung aber hilfreich, da ich nicht so ausführlich darauf eingehe. OpenGL ist für mich neu und ich versuche beim Schreiben des Tutorials selbst dazuzulernen und setze dementsprechend keine OpenGL-Kenntnisse voraus.</p>
<p>Zunächst ein paar Worte zu OpenGL, PyOpenGL und Pygame:</p>
<p><strong>OpenGL</strong> (Open Graphics Library) ist eine Schnittstelle (API) zur Entwicklung von 2D- und 3D-Grafik. Derzeit befindet sich OpenGL in einer Umbruchsphase. Das heißt, viele Befehle aus der mittlerweile 17 Jahre alten API werden ausgemistet, sodass zukünftig weitaus perfomantere Techniken genutzt werden, um anderen APIs &#8211; wie zum Beispiel DirectX &#8211; wieder Konkurrenz machen zu können. In diesem Tutorial werden allerdings die klassischen Programmiertechniken zum Einsatz kommen, da der Einstieg in die 3D-Programmierung damit in meinen Augen wesentlich verständlicher ist.</p>
<p><strong>PyOpenGL</strong> ist ein plattformunabhängiges Python-Binding zu OpenGL. Es ist wie eine Hülle (Wrapper) um OpenGL zu verstehen, die Befehle unter Python zur Verfügung stellt. Version in diesem Tutorial: <em>PyOpenGL 3.0.0</em> (unterstützt OpenGL 1.1 bis 3.0): <a href="http://pyopengl.sourceforge.net/">http://pyopengl.sourceforge.net</a></p>
<p><strong>PyGame</strong> ist eine Sammlung von Modulen, die vor allem der Spieleentwicklung dienen. Es sind zum Beispiel Module zur Steuerung von Grafik und Sound enthalten, sowie Module zum Abfragen von Eingabegeräte wie Maus, Tastatur oder Gamepad. Version in diesen Tutorial: <em>Pygame 1.8.1</em>: <a href="http://www.pygame.org">http://www.pygame.org</a></p>
<p>Pygame stellt also quasi das Grundgerüst unseres Programms dar. Deshalb gehe ich in Part 2 überwiegend auf Pygame ein und lege den Grundstein für das weitere Vorgehen. Später folgen dann die 3D-Animationen in OpenGL.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Freedom The Game]]></title>
<link>http://mkmgames.wordpress.com/2009/08/29/freedom-the-game/</link>
<pubDate>Sat, 29 Aug 2009 20:46:00 +0000</pubDate>
<dc:creator>mkmgames</dc:creator>
<guid>http://mkmgames.wordpress.com/2009/08/29/freedom-the-game/</guid>
<description><![CDATA[Ovu igricu sam napravio za natjecanje na DoubleBuffer forumu. Priča: U zemlji gdje ništa nije bespla]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ovu igricu sam napravio za natjecanje na DoubleBuffer forumu.<br />
<span style="font-weight:bold;">Priča</span>:<br />
U zemlji gdje ništa nije besplatno, pa ni zrak, vi morate ubiti The Mother of Chaos, iliti Majku Kaosa i tako prekinuti njenu tiraniju.</p>
<p><span style="font-weight:bold;">Upute</span>:<br />
Za igranje: Pokrenite &#8220;main.exe&#8221;<br />
Za kontrole: Pogledajte &#8220;readme.txt&#8221;</p>
<p><a href="http://pygame.org/project/1265/?tags=arcade%2Cpygame%2Cdoublebuffer">Pygame Stranica</a><br />
<a href="http://code.google.com/p/freedom-the-game">Download Stranica</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[back to pygame]]></title>
<link>http://ssscripting.wordpress.com/2009/08/14/back-to-pygame/</link>
<pubDate>Fri, 14 Aug 2009 15:06:23 +0000</pubDate>
<dc:creator>geo</dc:creator>
<guid>http://ssscripting.wordpress.com/2009/08/14/back-to-pygame/</guid>
<description><![CDATA[I&#8217;ve spent about 3-4 hours today familiarizing myself to pygame. I wrote a prototype for a war]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><font size="3"><br />
I&#8217;ve spent about 3-4 hours today familiarizing myself to pygame. I wrote a prototype for a wario clone, pario.<br />
Right now, my character can move around ( to the left and to the right ), and he can jump. I never thought game development would be so fun ( yet, difficult ). </p>
<p>I have big plans for my pario <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
</font></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Pygame Finale]]></title>
<link>http://mkmgames.wordpress.com/2009/08/14/pygame-finale/</link>
<pubDate>Fri, 14 Aug 2009 07:57:00 +0000</pubDate>
<dc:creator>mkmgames</dc:creator>
<guid>http://mkmgames.wordpress.com/2009/08/14/pygame-finale/</guid>
<description><![CDATA[Ovako izgleda kod za našu igru, gdje igrač kontrolira metak, i uništava kutije. [tab] je jedan priti]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ovako izgleda kod za našu igru, gdje igrač kontrolira metak, i uništava kutije.<br />
[tab] je jedan pritisak na tiku &#8220;Tab&#8221;!<br />
<code><br />
import pygame<br />
from pygame.locals import *<br />
import sys</p>
<p>class Kutija(pygame.sprite.Sprite):<br />
[tab]def __init__(self,x,y):<br />
[tab][tab]#započinjemo sprite<br />
[tab][tab]pygame.sprite.Sprite.__init__(self)<br />
[tab][tab]#stvaramo varijablu self.image za prikaz slike<br />
[tab][tab]self.image = pygame.image.load("kutija.PNG").convert()<br />
[tab][tab]#stvaramo kvadrat koji nam treba za koliziju i poziciju<br />
[tab][tab]self.rect = self.image.get_rect()<br />
[tab][tab]#ovdje mijenjamo poziciju od kvadrata- mislim da sada znate kako micati sprite <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
[tab][tab]self.rect.x = x<br />
[tab][tab]self.rect.y = y<br />
[tab][tab]self.zivot = 100<br />
[tab]def update(self):<br />
[tab][tab]#ovdje obnavljamo sprite<br />
[tab][tab]if self.zivot&#60;=0:<br />
[tab][tab][tab]#ovdje je mičemo iz grupe- neće se prikazati, ali je se i dalje može koristiti<br />
[tab][tab][tab]self.kill()</p>
<p>class Metak(pygame.sprite.Sprite):<br />
[tab]def __init__(self,x,y,kutije):<br />
[tab][tab]pygame.sprite.Sprite.__init__(self)<br />
[tab][tab]self.image = pygame.image.load("metak.PNG").convert()<br />
[tab][tab]self.rect = self.image.get_rect()<br />
[tab][tab]self.rect.x = x<br />
[tab][tab]self.rect.y = y<br />
[tab][tab]self.kutije = kutije</p>
<p>[tab]def update(self):<br />
[tab][tab]kolizija= pygame.sprite.spritecollide(self,self.kutije,False)<br />
[tab][tab]if kolizija:<br />
[tab][tab][tab]for i in kolizija:<br />
[tab][tab][tab][tab]i.zivot-=5<br />
[tab][tab][tab]self.rect.x-=5<br />
[tab][tab][tab]self.rect.y-=5<br />
[tab][tab]else:<br />
[tab][tab][tab]pass</p>
<p>[tab]def micanje(self,x,y):<br />
[tab][tab]self.rect.x+=x<br />
[tab][tab]self.rect.y+=y</p>
<p>fps = pygame.time.Clock()<br />
pygame.init()<br />
ekran = pygame.display.set_mode((800,600))<br />
pygame.display.set_caption("CroProgrammer Rocks!")<br />
pygame.key.set_repeat(500,30)<br />
kutije = pygame.sprite.Group()<br />
kutije.add(Kutija(10,20))<br />
kutije.add(Kutija(300,20))<br />
kutije.add(Kutija(20,100))<br />
metci = pygame.sprite.Group()<br />
metak = Metak(700,300,kutije)<br />
metci.add(metak)<br />
while True:<br />
[tab]ekran.fill((0,0,255))<br />
[tab]for event in pygame.event.get():<br />
[tab][tab]if event.type==QUIT:<br />
[tab][tab][tab]sys.exit(0)<br />
[tab][tab]elif event.type==KEYDOWN:<br />
[tab][tab][tab]if event.key==K_w:<br />
[tab][tab][tab][tab]metak.micanje(0,-2)<br />
[tab][tab][tab]elif event.key==K_s:<br />
[tab][tab][tab][tab]metak.micanje(0,2)<br />
[tab][tab][tab]elif event.key==K_a:<br />
[tab][tab][tab][tab]metak.micanje(2,0)<br />
[tab][tab][tab]elif event.key==K_d:<br />
[tab][tab][tab][tab]metak.micanje(-2,0)<br />
[tab]metci.draw(screen)<br />
[tab]metci.update()<br />
[tab]kutije.draw(screen)<br />
[tab]kutije.update()<br />
[tab][tab]fps.tick(30)<br />
pygame.display.update()<br />
</code></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Brief update.]]></title>
<link>http://pyrl.wordpress.com/2009/09/01/brief-update/</link>
<pubDate>Tue, 01 Sep 2009 21:29:10 +0000</pubDate>
<dc:creator>hahn</dc:creator>
<guid>http://pyrl.wordpress.com/2009/09/01/brief-update/</guid>
<description><![CDATA[Got some feedback on how the player movement worked and so I decided to switch it to the original id]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Got some feedback on how the player movement worked and so I decided to switch it to the original idea I had&#8211;when the player gets too close to the bounds of the screen, then the screen recenters itself on the player, as opposed to re-centering every single time the player moves.  Likewise the grass is now drawn so that it looks &#8220;attached&#8221; to the tile, instead of before where the grass appeared to just float under the screen like an odd <a href="http://en.wikipedia.org/wiki/Parallax_scrolling">parallax</a> effect (see image; night sky is what the grass looked like if anyone hasnt tried out this thing).</p>
<p>Also, I&#8217;ve worked in the map generator into the game itself.  It looks a bit weird, to be sure:<br />
<a href="http://pyrl.wordpress.com/files/2009/09/screenshot1.png"><img src="http://pyrl.wordpress.com/files/2009/09/screenshot1.png?w=300" alt="ingame map generator" title="ingame map generator" width="300" height="225" class="alignnone size-medium wp-image-403" /></a><br />
But I feel like currently that&#8217;s due to tileset issues and not necessarily the code.  Don&#8217;t mind the odd looking minimap, still have a few kinks to work out.</p>
<p>Also, now I&#8217;ve got a way to output screenshots (properly labelled to boot) into a &#8217;screenshots&#8217; directory when you press the printscreen key.  Saves time when I&#8217;m on Windows, thats for sure.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
