As you study, here’s a great little article with links about various Python tutorials that could help:
http://arstechnica.com/news.ars/post/20081202-getting-a-grip-on-python-six-ways-to-learn-online.html
And here’s a link that is not really for studying but does mention some interesting information about Python’s use in Google’s new online app engine:
http://arstechnica.com/news.ars/post/20080408-analysis-google-app-engine-alluring-will-be-hard-to-escape.html
The final exam slot for this class is Tuesday, December 9 at 11:30 a.m.
The last programming project is also due by this time.
Your final project is to complete the following and submit on or before the final exam time:
1) Download this sample code package based on the earlier race-game example.
2) Modify the game to run using two cars, one using the arrow keys and the other using ‘w’, ’s’, ‘a’, and ‘d’ to maneuver.
3) Also, do the following:
a) Modify the game so that each car is a different color. (Hint: look in the directory).
b) Modify the game so that when a car goes off the left side of the window, it comes back on the right, etc. for all sides of the window.
c) Modify the game so that there are three bumpers for the red car, three bumpers for the orange car, and three bumpers that should not be hit. Each set of these should look different (such as changing color, image, or whatever).
d) Randomly locate the bumpers across the (x,y) of the game background when the game starts.
e) Re-write the game so that the first player has to hit his bumpers in order (even though the order will not be known since they are randomly distributed), the second player has to hit his bumpers in order, and both cars have to avoid the bumpers to avoid (or some penalty will happen — make this up — they lose, they blow-up, they slow-down, whatever you like).
f) Whoever hits all the bumpers belonging to that car in the proper order first wins.
Bonus (Complete any or as many as possible for extra credit):
a) Play a sound whenever a bumper is hit.
b) Play sounds for the cars whenever they accelerate, collide, or whatever seems appropriate.
c) Give the cars capabilities such as oil-slick, guns, whatever…
d) Display scores on screen — makeup whatever scoring mechanism you like.
e) Have the cars explode if they run into each other.
f) Make your own artwork to replace the images of the cars, bumpers, and background.
The progress on projects so far looks good. To allow just a bit more time to fix and polish things, projects will now be due on Monday.
We ran out of time before I could work with everyone today, so please do email to schedule a time Friday or Monday to talk about your project if you still have questions.
This is a web exercise to be completed on or before Wed., Nov 19. Meeting is optional, as there will be no lecture, but you may still wish to come to campus to complete this assignment so that you could try the Python examples on Maya (which is installed on the machines in our classroom).
Today, we’ll keep looking at some Python programming. We’ll take a momentary break from PyGame, though, and look a little bit at Python being used in the real world — at Industrial Light and Magic (ILM), the company behind many incredible digital special-effects films such as Pirates of the Caribbean among many, many others. ILM is one of many entities using Python extensively today. Other high-profile ones include Google and NASA.
Because of its ease and flexibility, Python has become a great tool for modern visual effects work. We’ll take a little peek at that, and you’ll also see a little bit of Maya — one of the most widely used professional graphics and animation packages. (See this brochure and this website for more information. We also use Maya a lot in ART/CSC/FST 220 if you have an interest in that course or the Digital Arts Minor).
First, read each of these pages, to see a little bit of the computing setup used at ILM:
Visit this page and read the quotes from ILM and others about Python.
Visit this page detailing some of technical setup used by ILM and this page as well.
Then, visit this page and read about Python’s use at ILM.
Second, watch the following videos from the same series: One, Two, Three, Four, Five, Six, Seven, Eight, Nine, and Ten.
Thirdly, when finished watching the videos (or at least the first several), visit these pages: http://linil.wordpress.com/2008/01/24/python-maya-part-1/ http://linil.wordpress.com/2008/01/31/python-maya-part-2/
Post a comment to this posting mentioning two things that you found interesting or informative, either in the articles or video clips.
You may not have used Maya before, but as a bonus, complete the Python and Maya animation setup presented in the two page tutorial and demonstrate your working script to me at some point before the end of classes.
In the meantime, continue working on your projects that are now due on Friday. Please bring any questions on Thursday to class.
Whenever you work on the exercises previously posted, chimp.py is one of the examples. It may not run if you just enter the code, because the image files are not where expected. The easiest way to fix this is to go to the examples folder where chimp.py and other examples are included and run the Python script from there.
If you installed on a Mac, it’s in the examples folder in the PyGame folder.
If you installed on a Windows, you’ll likely have to install the examples separately. Here’s a helpful related tip (thanks again, Robbie):
Download the pygame-1.8-docs-setup.exe <http://www.pygame.org/ftp/pygame-1.8-docs-setup.exe> file as well to get the examples, like the Chimp one.
There will be no official lecture today. In lieu of meeting, complete this web exercise on or before Friday, November 7.
We’ve been looking at event-driven programming in Alice and Python, and we have also been looking at the fun library of modules, PyGame. Today, we’ll look a little more at how PyGame works. It gives a very fast way of getting to some of the more fun aspects of programming.
1) Download the document “Jones–Rapid Game Development”, which is from this web page. (And yes, if you’re thinking it, he does seem to look a bit like yours truly — at least when my hair was shorter
2) Read and complete the document, all the way through “Adding a Background.” You should be able to actually enter the given code in your own Python .py script and run it.
3) Leave a comment on this page, answering the following:
i) What method from which class would need to be changed to change the car’s speed?
ii) What is the condition on the while loop in the program? What does this do and why?
4) Complete the example. Print a screen capture of the game running next to the Python script in an IDLE window. Bring this to the next class.
There will be no official lecture today. In lieu of meeting, complete this web exercise on or before Wednesday, November 5.
We’ve been looking at event-driven programming in Alice and Python, and we have also been looking at the fun library of modules, PyGame. Today, we’ll look a little more at how PyGame works. It gives a very fast way of getting to some of the more fun aspects of programming.
1) Visit this page and look around a bit, reading over things.
2) Complete Lectures One through Three on this page. The first few lectures should be a very good review. The last will introduce you to some more basics of how PyGame works.
3) Leave a comment on this website answering the following:
i) What line of code loads the image of the monkey’s head?
ii) In that line of code, what is the “module,” what is the “class,” and what is the “method?”
iii) Describe a simple game idea that you could possibly program using PyGame.
Choose one of the following to implement in Python:
1) A text-based adventure game with a theme (i.e. fantasy, 1920s New York detective, stay-at-home parent and kids, whatever) and multi-part goal (such as get shield, get sword, fight dragon or get puzzle part 1, get puzzle part 2, assemble, use as key). The game should have at least 3 rooms, 3 verbs, and 3 objects. Draw how these are connected in a simple map on paper. The objects should be randomly placed in the rooms at the beginning of the game. The game should also have an “inventory system,” remembering if you pick-up an object. Once the multi-part goal is reached by collecting and using things, let the player know. Be as creative and witty in your writing as possible.
2) Implement Blackjack in a text-based program for at least two players, the user and the computer. Use random numbers to choose the user’s cards and the computer’s cards. You can choose either to be the dealer.
3) BONUS: If you’re up for a fun challenge, complete a version of the good ol’ Light Cycles game from the film TRON. (3-D is not necessarily — if you go for this, 2-D is fine). Here’s a link to a description of the original 80s arcade game based on the film.
Read Chapter 4 in the Alice and Java text. We’ll look at some “event-driven” programs in Alice and Python this week. GUI (graphical user interface) programs and games are usually “event-driven” — this usually involves a continuously running loop that waits for things (such as mouse-clicks) to happen before calling other methods.
Visit the resources page on this website. From there, visit the PyGame website.
1) Download and install PyGame. It’s a set of modules that make game programming simpler. (If you’re using a Mac, make sure to install it and the PyObjC set of modules that are linked just below it on the Mac OS X portion of the PyGame download page).
2) Read through the first introductory tutorial. (This is also linked just below PyGame on the resources page).
3) Copy the code and run the example. (You’ll need a ball.bmp image file in the same folder — procure from anywhere or make one up if desired).
4) Double the size of the window screen used and put a .bmp image of your own choice in the example instead of the ball.bmp. Grab a screen capture of your code running in a window next to the IDLE window displaying the code (figure out how or download a freeware/shareware program from the web if desired). Print this and bring to class on Thursday.
5) Read over the Chimp example. (Also linked on the resources page). The code for this is also in the “Examples” folder that was installed with PyGames (along with others). You can actually run it from this directory, and chimp.py will find the sound and image files that it needs. This is a nice example of a simple event-driven game.
←Older