Contact
Want to email me?
You could also tweet me @willmcgugan.
Recruiters: No need to get in touch right now.
Note that a comment here isn't the best place to ask for technical help. Please email me instead.
Want to email me?
You could also tweet me @willmcgugan.
Recruiters: No need to get in touch right now.
Note that a comment here isn't the best place to ask for technical help. Please email me instead.
2009-03-08 19:34:03.228 Python Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
And I don't understand it? I'm using Mac OSX 10.5 by the way. I'm not a pro programmer… I come from a PHP background (using MAMP) and so the whole Terminal concept is pretty new to me. I'm damn sure I have installed Python and Pygame correctly, as there is some Pygame examples I've been able to run fine. But it's annoying, I want to complete your book, but I can't with these errors… Like the ‘helloworld’ example, the image shows up in the background, I have a cursor image too, but it doesn't move, it's like it's frozen and it has that above error in the console.
I know you must be busy, but please help! I love your book and really want to complete it. If you need any information about my setup, please just ask me, do tell me how to find out versions though, as I'm new to the Terminal experience! Thank you Will! Great book… James
I'm afraid I can't help you with that one, not having a Mac. Perhaps you need to press a key in the terminal to move past the error message?
The pygame mailing list is probably the best place for help on this sort of thing…
Will
http://wiki.python.org/moin/MacPython/Leopard
The only thing extra I had to do was move the pygame files to the /Library/Python/2.5/site-packages folder. Also true for gameobjects.
The warning you mentioned is not a fatal error and is discussed here:
http://www.mail-archive.com/pygame-users@seul.org/msg06183.html
I am seeing some problems with the OpenGL examples. In Chapter 9, the example rotation3d.py was missing a ball.png file, which can be easily fixed with your own image. More problematic is the lack of color for the firstopengl.py example on my MacBook (nvidia GeForce 9400M) and HP 2710p tablet (Vista, Mobile Intel 965 Express). It displays fine on my Dell 490 (Fedora 10, nvidia Quadro FX 4600). Do you think this is a driver issue?
Thanks,
Dan
First of all, I would like to congratulate you on your book, “Beginning Game Development with Python and Pygame”. It's really helping me right now (with the PyWeek and all, hehe).
I'm writing to make a correction (so far, I've read up to page 36): in the 4th entry of the table 2-5, the description of the math.ceil function should be “Returns the smallest integer greater than or equal to a number”.
Bye!
http://www.willmcgugan.com/blog/tech/2007/6/4/opengl-sample-code-for-pygame/#comment751
I was wondering if you have any experience integrating the python twisted networking module with pygame. I have encountered several approaches online to doing this (but no convergence on a good solution), and in a few your name was mentioned as someone that is pursuing this line of integration.
As an aside, I think your book Beginning Game Development with Python and Pygame is phenomenal, but one area that it is lacking is network support. Personally, I have a good deal of experience in many other languages, but I gravitate towards python and pygame because I think it enables rapid prototyping and proof of concept for small independent game efforts.
Networking would have been a good topic to cover, but would be quite hard to do justice without several chapters – or an entire book.
I haven't tried integrating pygame and Twisted. I suspect that they wouldn't play well together, since they both want to monopolise the main loop.
One solution would be to run twisted in its own thread and communicate to the main pygame thread through a queue object (in the std lib). Then you could read new events from the queue prior to rendering. Although in some respects that defeats the purpose of using twisted in the first place.
An alternative approach would be to have an interface to the game state that is thread-safe, and have the pygame loop do rendering only. That would give you a more tradition event based model of the kind used in web servers.
Hope that helps!
Will
I'm in chapter 5 of your book BGDWPAP. I'm running MacPython 2.5 and pygame
on a iMac G5. When I try to run the code in Listing 5-8. Vector Magnitude Function,
I get the following error:
Traceback (most recent call last):
File “/Users/Ken/Desktop/myvecmagnitude.py”, line 22, in <module>
AB = Vector2.from_points(A, B)
File “/Users/Ken/Desktop/myvecmagnitude.py”, line 15, in from_points
return Vector2(cls, P2 - P1, P2 - P1)
TypeError: __init__() takes at most 3 arguments (4 given)
It looks like Vector2 might be the 4th argument? Is there a way around it?
At age 69 I'm brand new to programming, as a hobby, and your book has been most
helpful. I never took algebra, geometry or trigonometry. I guess this “Old Coot” better
crack a book or two.
Also, I tried to go to your site willmcgugan.com/game-objects/ for the Game Objects
download as instructed in several places in the book, but the site can not be found.
Thanks, Ken
Looking forward to your next book.
I'm presently working on creating a 3D MMORPG with Python and intend on completing this project. For which I have to install PyOpenGL on my comp But the laptop that I want to install it on is not connected to the internet. But the I don't know how to install it, or acquire the setup file through the internet even on the computer that is connected to the internet. So I need your urgent help please.
If its Windows you will need to download the installer exe from http://pyopengl.sourceforge.net/ and copy it to the machine you want to install it on. If its not Windows then download the source, unpack it and install it with ‘python setup.py install’.
Hope that helps!
Will
Then I start the server using:
python manage.py runserver, and it started.
Then I access "http://127.0.0.1:8000/"
My browser displayed:
===========================================
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/
No Blog matches the given query.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
============================================
I've tried many ways to handle it , but I was failed. So could you help me with it?
Thanks a lot.
Page Lee
from China
Sorry to disturb you, I knew Django only two days ago.
I first come to your blog looking after the Vector2 source-code, the one you used in the Begining Game Developing with Python and Pygame, that I bought few days ago and it's really make me understand how it works.
And then I just take a look in another “stuff” of your blog and found the lucidesktop project.
It's seems amazing the idea to use a virtual desktop instead of bookmarks pages (even those that are rigorous organised become a mess with time)
So, after all this text, here is the question: Do you still have invites for this project (http://locidesktop.com/)??
And, as I'm here already: Do you planing to make any book a bit advanced of game developing?
No plans for another book at the moment. One day though…
I found your simpleopengl.py example very instructive and was browsing some of the accompanying libraries. I think in your vector library, vector3.py, the __rsub__ operator should be
I need your help. I'm trying to use the PySndObj library (http://wiki.python.org/moin/PySndObj) to create computer sound, but I can't get it to work.
First, I downloaded PySndObj-1.3-win32-Python2.5.zip (http://sourceforge.net/projects/sndobj/files/PySndObj/PySndObj-1.3/PySndObj-1.3-win32-Python2.5.zip/download).
Then, I extracted the contents of the download and placed it into the site-packages folder.
When I type “import sndobj” at the interactive prompt I receive a message that says “ImportError: No module named sndobj”. Why is there an import error?
I'm a software engineer who has dabbled in opengl on the side for years, but never really done anything other than scrappy proof-of-concept demos. I read your book over a year ago. At the time I really enjoyed reading it, but I had a reservation about it because I felt that it didn't really cover much that I didn't already know.
Since then though, I've started sitting down to actually write some small games, rather than just thinking ‘yeah yeah that looks easy, I could do that.’ During this time, I have found myself returning to your book again and again. I've undergone a bit of a transition away from my old arrogant attitude, and am much more appreciative of actually creating something, as opposed to simply thinking about it. I have found several instances where the difference between thinking I understand something in principle, and actually sitting down to do it, have turned out to be quite pronounced. :-)
Anyhow, all the ideas your talk about in your book are remarkably clearly expressed, and it has been a great source of reference for me to straighten my thoughts out when I'm in the thick of indecision about something. I have grown more and more appreciative of it as time has gone by. You did a really amazing job.
So, a sincere and belated thank-you.
Jonathan
I am reader of Your book and I am begginer in Pygame
First at all thank You for book. It's very nice of you
that you made it, and as far as I know there are not other
book about Pygame. Thought as a beginner, I have several remarks
Remark I
Your book Chapter 3, page 107:
A = (10.0, 20.0)
B = (30.0, 35.0)
AB = Vector2.from_points(A, B)
step = AB * .1
position = Vector2(A.x, A.y) #It's not going to work
for n in range(10):
position += step
print position
I changed it to A A but what did you mean
Second remark that at the certain points your book needs more exlanation than you gave. I mean this example wich you gave Chapter 7
class State(object):
def __init__(self, name):
self.name = name
def do_actions(self):
pass
def check_conditions(self):
pass
def entry_actions(self):
pass
def exit_actions(self):
pass
class StateMachine(object):
def __init__(self):
self.states = {}
self.active_state = None
……………….
def think(self):
if self.active_state is None:
return
self.active_state.do_actions()###### ???????????
new_state_name = self.active_state.check_conditions()
if new_state_name is not None:
self.set_state(new_state_name)
I will be very thankful if You explain me
how can be here used method from different class. Because I don't see any obvious connecting point. So I am hardly trying to figure out that.
Thanx to you for your book :)
But i got one problem when was trying to run listing 5-16…
I get this:
invalid destination position for blit
Class which was used:
class Vector2(object):
def __init__(self, x = 0.0, y = 0.0):
self.x = x
self.y = y
def __str__(self):
return “(%s, %s)” % (self.x, self.y)
@classmethod
def from_points(P1, P2):
return Vector2(P2 - P1, P2 - P1)
def get_magnitude(self):
return math.sqrt(self.x**2 + self.y**2)
def normalize(self):
magnitude = self.get_magnitude()
self.x /= magnitude
self.y /= magnitude
def __add__(self, rhs):
return Vector2(self.x + rhs.x, self.y + rhs.y)
def __sub__(self, rhs):
return Vector2(self.x - rhs.x, self.y - rhs.y)
def __neg__(self):
return Vector2(-self.x, -self.y)
def __mul__(self, scalar):
return Vector2(self.x * scalar, self.y * scalar)
def __div__(self, scalar):
return Vector2(self.x / scalar, self.y / scalar)
I need your help :)
I was hoping you could explain me why my code does not show the square I want it to do.
Thanks in advance.
Do you know if your book is sold anywhere as PDF?
Amazon only want to sell me paperback and kindle version.
Regards
-Espen-
-Espen-
Ive recently began learning Python and Pygame and have been hunting throughout the interwebs for various tutorials and guides on the two. Your site is and excelent resource for both (and has even sparked my curiosity in django)
Im currently stuck on pathfinding and have been looking for diffrent way people implement it. Your Fugu demo has helped and im also intrested in the Fugu's Friend demo (A* seems to be the way to go with pathfinding) Unfortunatly the link to the demo isnt working anymore and i was hoping you may have the .zip still stored somewhere? Googling for it hasnt helped at all.
The post in question is this http://www.willmcgugan.com/blog/tech/2007/4/30/swim-turtle-swim/ is over 3 years so the likelyhood of finding it is slim i know but still worth asking.
Thanks, Michael.
first congratulations on the book Beginning Game Development with Python and Pygame…, great book. I've done some games using pygame .. and now I'm starting to make a snake-style game using OpenGL. I read the chapters of the book on the subject but I'm still a little “lost” in the sense of how I will make the game! I have in mind as early concepts of primitives, textures…
be able to help with any tutorial or suggesting a book (using python in the examples, not the language of c or c + +) or someone who can connect with and ask questions thank you very much.
i recently bought your book “Beginning Game Development with python and pygame : from novice to professional”
i have python 2.7.1
i have windows vista
i am currently reading chapter 2 and i typed both tank.py and tankgame.py correctly in the sciTE text editor
when i try to run tankgame.py the out put is
>pythonw -u “tankgame.py”
>The system cannot find the file specified
and when i do a syntax check this comes up
>python -c “import py_compile; py_compile.compile(r'C:\Users\Sean\Documents\tankgame.py')”
'python' is not recognized as an internal or external command,
operable program or batch file.
>Exit code: 1
how do i get the tankgame.py to run correctly like it does in the book
Well anyway, will since yours was the best book on game development that I have “ever” read. I was wondering why have you not written any other books since then? I mean I have been waiting and it's been ages or so. Don't you like writing or teaching or something?
Well have you ever thought of writing a book on Python Ogre? hopefully using Python 3.0 Python-Ogre does not support it as yet, but it's about to. Should be complete any day now :P
I haven't tried Python Ogre. It looks pretty cool though…
screen.blit.(sprite, sprite_pos) said invalid destination position for a blit i dunno why it said that would you mind helping my and the vector class is defined
Another Question:
What type of licence djangotechblog have?
Requiere your signature?
bye
“pythonw -u ”list.py“
>The system cannot find the file specified.”
Please help i am using windows 7 operating system
heading *= movement_direction
what does * do in this line?
i have a little problem with donloading and installing the gameobjects library, gameobjects-0.0.3.win32.exe dosen't work on my computer so i tried the 0.0.3.zip version but when i try to run the setup file it dosen't work and this error shows up:
>>>
Game Objects v0.0.3
Traceback (most recent call last):
File “C:\Python25\Lib\site-packages\gameobjects-0.0.3\setup.py”, line 31, in <module>
classifiers = classifiers.splitlines(),
File “C:\Python25\lib\distutils\core.py”, line 139, in setup
raise SystemExit, gen_usage(dist.script_name) + “\nerror: %s” % msg
SystemExit: usage: setup.py cmd1 [cmd2 …]
or: setup.py –help
or: setup.py –help-commands
or: setup.py cmd –help
error: no commands supplied
>>>
and when i try to import it with IDLE it cannot find gameobjects.vector2
can you help with this ??
Thanks in advance
This is ganesh with you, had a doubt, is it possible to draw the pencil, circle, rectangles, at text view in python, else there is only way to draw the things in drawing area, how can i improve smoothness of pencil tool, is there any suitable package on available to import the drawing environment,..
please clarify myself,
Thanks in advance
Just saw your tweet and thought i'd get in touch as I'm after for a Python Developer for a 6 week remote opportunity to start immediately.
If you're available and interested please get in touch as soon as possible at 0207 269 6784 or you can reach me at az@opusrs.com
Best,
Anton
I modified your chess.py what in my mind is a really great and simple chess lib. I want to combine it with PyBitmessage to use it as P2P Serverless chess implementation.
Could I put my modified version to github and publish it there?
If yes, what licenses are possible?
Best regards,
Merlink
I'm so glad to discover your site while looking for a script to use for a welcome/splash page for a website. I've tried many sliders with the ken burns effect, but they provide start and end points for the panning only as top, left, bottom etc, which are not accurate enough for this project.
I suspect precise start and end coordinates for panning could probably be set in your script, which is exactly what I need.
When you get the opportunity, would you please give an example of how the entire randomization part of your script may be replaced by just one start point and one end point?
Thanks,
Kenny
Its time to finally move your projects to git. Even google suggests move to github.com now.
Google is a big barrier for me, keeping me from contributing.
sincerely,
Tanner
from tkinter import*
import random
import time
class Ball:
def __init__(self, canvas, paddle, color):
self.id = canvas.create_oval(10, 10, 25, 25, fill=color)
self.paddle = paddle
self.canvas = canvas
canvas.move(self.id, 232, 276)
starts =
random.shuffle(starts)
self.x = starts
self.y = -3
self.hit_bottom = False
self.speed = 0.01
def hit_paddle(self, pos):
paddle_pos = self.canvas.coords(self.paddle.id)
if pos >= paddle_pos and pos <= paddle_pos:
if pos >= paddle_pos and pos <= paddle_pos:
game.score.hit()
self.x += game.paddle.x
return True
return False
def draw(self):
self.canvas_width = self.canvas.winfo_width()
self.canvas_height = self.canvas.winfo_height()
self.canvas.move(self.id, self.x, self.y)
pos = self.canvas.coords(self.id)
if pos <= 0:
self.y = 3
if pos >= self.canvas_height:
self.hit_bottom = True
if self.hit_paddle(pos) == True:
self.y = -3
if pos <= 0:
self.x = 3
if pos >= self.canvas_width:
self.x = -3
class Paddle:
def __init__(self, canvas, color):
self.id = canvas.create_rectangle(0, 0, 100, 10, fill=color)
self.canvas = canvas
canvas.move(self.id, 200, 300)
canvas.bind_all(“<KeyPress-Left>”, self.turn_left)
canvas.bind_all(“<KeyPress-Right>”, self.turn_right)
canvas.bind_all(“<space>”, self.start_game)
self.started = False
self.x = 0
def draw(self):
self.canvas_width = self.canvas.winfo_width()
self.canvas.move(self.id, self.x, 0)
pos = self.canvas.coords(self.id)
if pos <= 0:
self.x = 0
elif pos >= self.canvas_width:
self.x = 0
def turn_left(self, evt):
self.x = -2
def turn_right(self,evt):
self.x = 2
def start_game(self, evt):
self.started = True
class Score:
def __init__(self, canvas, color):
self.value = 0
self.canvas = canvas
self.id = canvas.create_text(10,\
12, \
font=(“Purisa”, 14), \
text=“Score: ” + str(self.value), \
anchor=“nw”, \
fill=color)
def hit(self):
self.value += 1
self.canvas.itemconfig(self.id, text=“Score: ” + str(self.value))
def clear(self):
self.value = 0
self.canvas.itemconfig(self.id, text=“Score: ” + str(self.value))
class Game:
def __init__(self):
# Create canvas
self.canvas = Canvas(tk, width=500, height=400, bd=0, highlightthickness=0)
self.canvas.pack()
# Initialize restart button
self.restart_button = None
# Create game elements
self.score = Score(self.canvas, “black”)
self.paddle = Paddle(self.canvas, “blue”)
self.ball = Ball(self.canvas, self.paddle, “red”)
self.game_over_text = self.canvas.create_text(250, \
200, \
font=(“Purisa”, 50), \
fill=“red”, \
text=“GAME OVER”, \
state=“hidden”)
self.restart()
def add_restart(self):
self.restart_button = Button(tk, text=“RESTART GAME”, \
command=self.restart)
self.restart_button.pack()
def restart(self):
self.canvas.itemconfig(self.game_over_text, state='hidden')
# Reset score
self.score.clear()
# Reset paddle
self.paddle.x = 0
self.canvas.move(self.paddle.id, self.paddle.x, 0)
# Reset ball
self.ball.canvas.move(self.ball.id, 232, 276)
starts =
random.shuffle(starts)
self.ball.x = 0
self.ball.y = -3
self.ball.hit_bottom = False
self.ball.speed = 0.01
tk = Tk()
tk.title(“Game”)
tk.resizable(0,0)
tk.wm_attributes(“-topmost”, 1)
tk.update()
game = Game()
while 1:
if game.ball.hit_bottom == False and game.paddle.started == True:
game.ball.draw()
game.paddle.draw()
if game.ball.hit_bottom == True:
game.canvas.itemconfig(game.game_over_text, state='normal')
game.paddle.started = False
if game.restart_button is None:
game.add_restart()
tk.update_idletasks()
tk.update()
time.sleep(game.ball.speed)
Hi. gameobjects looks like a fantastically useful library. A few people have taken it onto github, would you consider having it on your own github and uploading it to pypi ?
S
I don't know if I ever thanked you or not for writing the Game Development for Python and Pygame book, I bought it years ago and still refer to it. I've taken a real interest in finite state machines recently, and remembered your AntStateMachine program. So I'm going through and running it. I finally am taking the time to learn more about Classes. I'm more of a procedural style programmer. But using class style code will help streamline some of the programming ideas I have, as far as FSM programming is concerned.
Thank you again for writing the book.
Glad you like it, Shawn! Hope you enjoy your project.
Hi Will, it's Scott from Oxford.
Do you still have the local currency experiment running? Been chatting with someone looking to launch their own complementary currency as part of an sustainable development, social justice, ethical living project.
If you've got a few minutes guidance setting accounts up with credits for people, that'd really help.
Hope this finds you well, love your new photography on your blog!
Scott
Hi Scott,
Nice to hear from you. I have a new version of the currency site (currency.moyaproject.com).
Feel free to pass on my details. I may be able to help...
Will
Thank you for getting back to me. You might want to look at the validation email here:
The first email had a big blue button: Add currency to account. This URL was complete.
After entering the registration details, the second part of the validation arrived via email. This link wasn't cosmetically styled, saying: Validate Email. The URL was incomplete.
http://signup/validate/?token=ova80x0uyy9rbneq0spf
When the domain was added though, it worked as expected: https://currency.moyaproject.com/signup/validate/?token=ova80x0uyy9rbneq0spf
Will, could you please drop me a note via my website contact form at www.randyhannaphotography.com
I have some photo questions for you. Tried to use your email link however it only wants to use the Apple mail app which I don't use.
Looking forward to hearing from you soon.
Cheers and great work on your images. Randall
You can email me at willmcgugan@gmail.com
Will,
I was interested in getting a hold of the source code from your book from 2007 - "Beginning Game Development with Python and Pygame". I have tried downloading it from Apress (now Springer), but was not able to find it there.
I have a class I am teaching for the first time to 2nd yr engineering students on programming and thought your book started with the fundamentals and took things step by step.
Thanks for your book and any source code you can send me. Email: hugh.chesser@gmail.com
Hugh
Hello, Will
I am a Python newbie, and learned alot from your Rich, and Rich-CLI code on GitHub. Thank you so much to your project open-source, and learner like me could learn from professional programmer like you.
Thanks Sam
Hello Will, my name is Cecilio Rodríguez.
I am from Venezuela. and I'm looking for a remote job, with which I can help my family and survive. I have an interesting set of skills and knowledge that may be of your interest. I'm not a software engineer or coder, in fact, my degree (Bachelor in Fiscal Sciences) is accumulating dust in my closet. Please allow me a couple of minutes to tell you a little more about it:
I have more than 8 years of experience working remotely, and I have developed and grown in the eCommerce and Tech world, said that I have had positions such as customer service, in my beginning, email marketing assistant, and copywriter. Similarly, I have worked as a virtual assistant, developing administrative tasks, and creating images, email templates, and newsletter, designed in Photoshop and Canva
I must say I am a very versatile person, I have worked with various entrepreneurs and companies over the years, and at this time, I find myself in a delicate position, since I lost the job, I had since I spent little more than 2 months recovering from a robbery where I lost my computer and phone.
I emphasize that due to inflation in my country, remote work is an excellent alternative to try to achieve the quality of life that I want, which is why I can commit to working more than 40 hours a week, for a monthly payment of XXX (I can tell you this privately)
If you have an open vacancy or a task that you can delegate, or know someone who may be interested in my services, I would greatly appreciate the connection with that person. As I told you, I find myself in a delicate situation where the only thing that matters to me is being able to help my family.
Thank you!
Hi Will,
I wanted to text you an email regarding some questions about which camera gear to take to a trip to Sumatra. Unfortunately your email seems to be wrong (there is space character too much). Could you give me your correct address?
Happy to hear from you soon!
Best regards from Germany, Felix