Difference between revisions of "Pygame"

From ArmadeusWiki
Jump to: navigation, search
(Tested pygame applications)
Line 1: Line 1:
 
On this page, you will find usefull informations to setup and develop pygame based applications for your Armadeus board.
 
On this page, you will find usefull informations to setup and develop pygame based applications for your Armadeus board.
 
{{Under_Construction}}
 
  
 
==Introduction==
 
==Introduction==
Line 14: Line 12:
 
  $ make menuconfig
 
  $ make menuconfig
 
</pre>
 
</pre>
and choose pygame package in:<br>
+
and choose pygame package in:
[[Image:menuconfig_package.png]]<br>
+
<pre class="config">
 
+
Package Selection for the target  --->
[[Image:menuconfig_package_graphics.png]]<br>
+
    Graphic libraries and applications (graphic/text)  --->
 
+
        ...
you can choose pygame options too; then save your configuration
+
        [*] pygame
 
+
        ...
 +
</pre>
 +
* you can choose pygame options too; then save your configuration
 
* Regenerate your rootfs
 
* Regenerate your rootfs
 
<pre class="host">
 
<pre class="host">
Line 27: Line 27:
 
and reflash it on your board
 
and reflash it on your board
  
==Configuration==
+
==Usage==
Our SDL version is using the [[FrameBuffer]] interface and so '''it's very important to have a ''/etc/fb.modes'' file up to date with the framebuffer parameters supported by your configuration''' (otherwise SDL try to use the VESA parameters which may misprogram the i.MX LCD controller).
+
* to test your pygame installation (requires a LCD with at least 640x480 pixels):
 +
<pre class="apf">
 +
# cd /usr/lib/python2.7/site-packages/pygame/examples
 +
# python testsprite.pyc
 +
</pre>
  
For example for the Sharp LQ057, ''/etc/fb.modes'' should contain:
+
===Tested pygame applications/examples===
mode "320x240-176"
+
* [http://www.scriptedfun.com/arinoid-an-arkanoid-clone/ arinoid (simple arkanoid clone)], to install it (assuming you have internet access on your APF):
    # D: 16.000 MHz, H: 43.836 kHz, V: 176.047 Hz
+
<pre class="apf">
    geometry 320 240 320 240 16
+
# mkdir arinoid && cd arinoid
    timings 62500 9 27 0 7 9 2
+
# wget http://www.scriptedfun.com/wp-content/uploads/2006/06/arinoid.zip
    rgba 5/11,6/5,5/0,0/0
+
# unzip arinoid.zip
endmode
+
# cd arinoid/
{{Note| ''/etc/fb.modes'' is now automatically generated at first boot of your rootfs by ''/etc/init.d/S01fb'' script.}}
+
# python arinoid.py
 
+
</pre>
* If you want to update your ''fb.modes'' for your currently running LCD, then do:
+
* [http://www.scriptedfun.com/1945-a-vertical-scrolling-shooter/ 1945 (simple 1942 clone)], to install it (assuming you have internet access on your APF):
 
<pre class="apf">
 
<pre class="apf">
# fbset > /etc/fb.modes
+
# mkdir arinoid && cd arinoid
 +
# wget http://www.scriptedfun.com/wp-content/uploads/2006/06/1945.zip
 +
# unzip 1945.zip
 +
# python 1945.py
 
</pre>
 
</pre>
  
==Adding Tslib (Touchscreen library) support to SDL==
+
===Adding Tslib (Touchscreen library) support to pygame===
SDL is by default compiled with Tslib support in current Buildroot distribution. You just have to make SDL knows the presence of Tslib when launching your application (assuming you have correct [[Tslib | Tslib envt variables]] set):
+
You just have to make SDL knows the presence of Tslib when launching your application (assuming you have correct [[Tslib | Tslib envt variables]] set):
 
<pre class="apf">
 
<pre class="apf">
 
  export SDL_MOUSEDRV=TSLIB
 
  export SDL_MOUSEDRV=TSLIB
Line 51: Line 58:
 
</pre>
 
</pre>
  
==Usage==
+
==Troubleshots==
 
+
* Screen/backlight goes black after SDL launch/exit: [[BackLight|use backlight driver to set backlight to a default value.]]
* Take a look at ''armadeus/target/demos/???" sources
+
* If SDL is complaining because it can't find any mouse (''Unable to init SDL: Unable to open mouse'') and you don't have one, then, before launching the program, do:
* If SDL is complaining because it can't find any mouse (''Unable to init SDL: Unable to open mouse'') then, before launching the program, do:
+
 
<pre class="apf">
 
<pre class="apf">
 
  # export SDL_NOMOUSE=1
 
  # export SDL_NOMOUSE=1
 
</pre>
 
</pre>
  
==Tested pygame applications/examples==
 
* [http://www.scriptedfun.com/arinoid-an-arkanoid-clone/ arinoid (simple arkanoid clone)]
 
* [http://www.scriptedfun.com/1945-a-vertical-scrolling-shooter/ 1945 (simple 1942 clone)]
 
 
==Troubleshots==
 
* Screen/backlight goes black after SDL launch/exit: [[BackLight|use backlight driver to set backlight to a default value.]]
 
  
 
==Links==
 
==Links==
Line 70: Line 70:
 
* [http://www.pygame.org/ pygame website]
 
* [http://www.pygame.org/ pygame website]
  
{{LanguageBar|pygame|pygame|pygame}}
+
[[Category:Python]]
 
+
[[Category:SDL]]
[[Category: Software]]
+
 
[[Category:Graphical User Interface]]
 
[[Category:Graphical User Interface]]
[[Category: SDL]]
+
[[Category:Software]]

Revision as of 20:19, 12 January 2012

On this page, you will find usefull informations to setup and develop pygame based applications for your Armadeus board.

Introduction

Pygame is a set of Python modules designed for writing games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language.

For more informations -> http://www.pygame.org/

Installation

  • Launch Buildroot configuration
 $ make menuconfig

and choose pygame package in:

Package Selection for the target  --->
    Graphic libraries and applications (graphic/text)  --->
        ...
        [*] pygame
        ...
  • you can choose pygame options too; then save your configuration
  • Regenerate your rootfs
 $ make

and reflash it on your board

Usage

  • to test your pygame installation (requires a LCD with at least 640x480 pixels):
# cd /usr/lib/python2.7/site-packages/pygame/examples
# python testsprite.pyc

Tested pygame applications/examples

# mkdir arinoid && cd arinoid
# wget http://www.scriptedfun.com/wp-content/uploads/2006/06/arinoid.zip
# unzip arinoid.zip 
# cd arinoid/
# python arinoid.py 
# mkdir arinoid && cd arinoid
# wget http://www.scriptedfun.com/wp-content/uploads/2006/06/1945.zip
# unzip 1945.zip 
# python 1945.py 

Adding Tslib (Touchscreen library) support to pygame

You just have to make SDL knows the presence of Tslib when launching your application (assuming you have correct Tslib envt variables set):

 export SDL_MOUSEDRV=TSLIB
 export SDL_MOUSEDEV=$TSLIB_TSDEVICE

Troubleshots

 # export SDL_NOMOUSE=1


Links