Using Trigonometry to Animate Bounces, Draw Clocks, and Point Cannons at a Target
Posted by Al Sweigart in pygame
Writings from the author of Automate the Boring Stuff.
Posted by Al Sweigart in pygame
Posted by Al Sweigart in python
Figuring out what Python's error messages mean can be kind of tricky when you are first learning the language. Here's a list of common errors that result in runtime error messages which will crash your program.
Posted by Al Sweigart in programming
True is the opposite of false. Up is the opposite of down. What is the opposite of dog?
Posted by Al Sweigart in teaching
Posted by Al Sweigart in python
This post goes into the details of how you can add a "save game" feature to your Python games.
Posted by Al Sweigart in python
To figure out bugs in your code, you might put in print
statements/print()
calls to display the value of variables. Don’t do this. Use the Python logging
module.
Posted by Al Sweigart in python
I made a twitter bot that checks every hour for someone who has asked the question, “Why do homeless people have dogs?” and automatically replies, “Because a dog will love you even though you are homeless.”
Posted by Al Sweigart in programming
CircleMUD was a popular piece of server software for running a MUD, and it came with a sizeable virtual world (which the admin could modify/append to customize their fantasy world.) It would be pretty handy to use parts of this data if you were creating your own virtual world for a text adventure game, but the format of CircleMUD's data files is kind of obtuse and not amenable to manipulation.
So I wrote a few scripts to convert these files into a single XML file which is 4MB when unzipped. You can parse this file and modify it to suit your needs. It contains 1979 rooms across 30 different areas (called zones in the file), with 46 shops and 569 different "mobs" (mobile objects, which are the monsters and NPCs). There are 678 different types of objects, including 116 weapons and 154 types of armor.
Posted by Al Sweigart in programming
Math and programming have a somewhat misunderstood relationship. Many people think that you have to be good at math or made good grades in math class before you can even begin to learn programming. But how much math does a person need to know in order to program?
Posted by Al Sweigart in programming
They don’t want to learn how to program just for the sake of programming. They don’t want to learn about algorithm complexity or implicit casting. They want to make Super Mario or Twitter or Angry Birds.
Posted by Al Sweigart in programming
Posted by Al Sweigart in news
I've completed my next book, which focuses on the Pygame library and making graphical games in Python.
Posted by Al Sweigart in news
Download pyganim.py and example programs. (Works on both Python 2 and 3.)
Details at http://inventwithpython.com/pyganim/
Pyganim is a module that you can import into your Pygame games to handle sprite animation.
Posted by Al Sweigart in python
IDLE is great, but over time I’ve noticed a lot of problems with IDLE that I wish someone would fix.
Posted by Al Sweigart in pygame
Here are a couple games I wrote. The first was so popular that I made a sequel.
Posted by Al Sweigart in news
Here's the introductory chapter to my next book on Python and Pygame. It assumes you have some Python and programming experience (if you don't, give a look to Invent with Python), and offers a quick view of all of the major parts of Pygame.
Posted by Al Sweigart in news
Yuanle Qiu has started translating the "Invent Your Own Computer Games with Python" into Chinese.
Posted by Al Sweigart in pygame
If you already know a bit of programming and Python, and want to get up to speed on the Pygame 2D game framework, here's a cheat sheet that you can look over. It implements a very short Pygame program covering most of Pygame's basic features.
Posted by Al Sweigart in programming
I wrote some programs to go through 6 GB of OpenStreetMap data from http://metro.teczno.com so that I could extract a list of street names for an upcoming game project. The game will use procedural generation to create cities, so I need to have a dataset of street names but couldn't easily find one. So I've created this one and wanted to share it.
Posted by Al Sweigart in news
I've created a web version of the Caesar Cipher wheel using JQuery and CSS sprites.