Archive for category Python 2.x

Pygame Tutorial Update: Tutorial 3.5 Creating Bullets, Enemies, and Meteors

Since the update for Tutorial 4 is taking longer than expected, I decided to switch from coding to art assets to keep the posts flowing. 

Also, it’s worth noting that on the Gamasutra Web site, Chris Hildenbrand has added more helpful 2D game art tutorials (there are 8 in total, listed at Gamasutra and at Chris’ blog page 2D Game Art for Programmers.  If your looking to improve your skills or looking to get up to speed with Inkscape his tutorials are a must read.  What caught my attention the most was the tutorials he did on attack helicopters.  Helicopters have always been a fun gaming element from back in the days of Choplifter and Infiltrator to Jane’s AH-64D Longbow (and Longbow 2).  Chris’ tutorials are very straight forward and easy to follow.  In just a couple of hours, you will be able to easily go from a blank Inkscape window to something like:

Read the rest of this entry »

, , ,

Leave a comment

Pygame Tutorial Update: Tutorial 4 still a WIP

del.icio.us Tags: ,,,,

At this point we have the basis for the Python pygame model.  We have the environment(outer space) and our player with the ability to move, but not shoot (nothing to shoot at yet).  The game now looks something like this (using the more “modern” version of artwork):

 

ink_player

 

But, ultimately what the window should look like, to make it more interesting and much more interactive would be something like the following mock up ( currently the game window does not look like this, but this is the intended final result). Currently I’m figuring out the GUI, I’ve gotten the furthest using Tkinter, but I haven’t gotten to the part where I can see the interaction between tkinter’s mainloop() and pygame’s mainloop().

mock_screen

 

Currently the work being done is on the GUI, to use what is available without having to include any additional install packages, this means that the GUI will be created either directly in pygame or using Tkinter(if possible). An alternate solution I’m thinking of is to create a transparent interface with SVG images and replace the option panel with that and then hardcode the buttons with pygame, but we’ll see how tkinter works out.  The actual current window looks like this:

window_base

, , , ,

Leave a comment

Note about tutorials

Sorry about the source code in the tutorials, (I either lose the spacing but retain the  source formatting, or vice versa) while I try and isolate the problem (I have it narrowed down to an ID 10 T error) I have posted complete listings of each of the files;

I checked that the code appears properly in Firefox and IE, if anyone is using a browser other than these drop me a comment if you have difficulty viewing.  Help me resolve the ID 10 T error!

Note: You can also leave a comment if you want to vote for either aliens or meteors in the the game.

Alien

Meteor

alien_2 meteor

, , ,

Leave a comment

Python Tutorial 02: Adding a background

In the first tutorial, we created a simple window using Python and Pygame. The next step, will be building on that example, we will create a star field background, then write the code to animate it.  One important point about these tutorials is the assumption that anyone following along already has at least a basic knowledge of how Python code is structured.  If that is not the case, then you should, at the very least, want to have the Python documentation(included in the Python install) at hand incase you wanted it for a reference.  There are some very good resources available for Python, either through THE OFFICIAL PYTHON WEB-SITE or by completing a Google search on the Python version you have installed.  If you have already coded the first tutorial you should do just fine with this one.  If there are any comments about the tutorials, whether they are critical or complimentary, you’re welcome to post them.  If there’s information that I have glossed over or skipped entirely, let me know, and I will add it in, with future edits of the tutorials.

starfield

NOTE:

I typically use Editra v0.7.12 to write Python code, when including the psyco try/except block, Editra would occasionally crash.  When I ran the starfield.py file in Python IDLE 2.6, it never crashed(but you need to have the pygame.quit() statement, so the app window does not crash).  If you’re using a different IDE your mileage may vary, if in doubt, use IDLE as your benchmark(or use IDLE to run this example).

UPDATE: Psyco is no longer supported as of March 12, 2012. If you are already using it you can choose to include it, if you’re not using psyco then avoid the install unless your confident that you can make it work.

Skip the source code in red, it is the psyco try/except block!

Read the rest of this entry »

, , , , ,

1 Comment

Python Tutorial 01: A Basic window using Python and Pygame.

The best way to get the most updated version of Python is from the Official Python Web-site, and Pygame found at the Pygame Official Web-site.  The most popular question when starting with Python, “Should I start with 2.x or 3.x?”.  The answer I would suggest, if you’re not supporting legacy code (versions like 2.5 or older) start with the newest version of Python you can run on your system, and handle your coding requirements.  As an example, for my situation, I have multiple versions installed ( 2.4 for Nvidia’s Fx Composer 2.5, 2.6 for Blender 2.49 and Panda 1.7, and 3.1 for coding and Blender 2.5/2.6 ), it’s what works for me.  Others might decide to have a particular version of Python on their hard drive, and other versions on memory sticks.  Just a reminder, the Python install is typically small ( less than 30 MB, so many applications written in Python include the Python code for simplicity – Blender and FX Composer both run this way), so if you have Open Source software on your system, or are running a non-Microsoft OS your system probably already has some version of Python.

The included code is in Python (it works with both 2.x and 3.x) and uses the Pygame version 1.9 library.

Read the rest of this entry »

, ,

1 Comment

%d bloggers like this: