Game Programming Tutorial 4 in Python: Control with mouse
Top Comments
All Comments (24)
-
ok so this is a out of date or something tut- everyone is getting the same error - im gonna say i understand how it should work and mostly why- but im gonna move on cuz obviously its not working for me.
im sure versions are different - but they do not offer the 2.5.6 for windows anymore - just for linux
- python 2.7.2
-pygame 1.9.1
-
for some reason when I try to execute startcode.py, I just started getting an error saying s=Starter() is invalid
it wasn't happening before, and it's also happening with your final code version
-
@Dragonno96 Thanks for the tip, that fixed the TypeError problem.
-
@faithfulnathan I keep getting the same problem. DX
-
What are the parameters for the key input? Is it the arrow keys alone? Cause I've been at this for some time now, but I don't know the right integers for using the 'KeyUp' function. I don't think I ever saw a tutorial for it anywhere.
-
@xFelicianoX that's a fair complaint, I should have been a bit more clear on this. When you do dir.length = 3, behind the scenes Python does something like dir.setLength(3) . And that function does a few things: it computes the length of the dir vector, and then it divides each component by this length, and then multiplies each component by the 3. The result being that dir.x and dir.y are pointing along the same direction, but dir is now a length of 3. Bit of vector math
-
Nice tutorial but I don't get how dir.length works
-
self.pos.inttup() converts the vec2d item into a integer tuple
Found this when i was exploring the vec2d module
Hi. Great tutorials.
However, I got a TypeError: Integer argument expected, got float. (line 37)
Draw is expecting an Integer, but Vec2d is returning a float. How do you get it to work?
(for the record I'm using Python 3.1, and Pygame 1.9.1)
faithfulnathan 1 year ago 6
To fix the error, i recommend just assigning another variable in draw, for example self.posint = (int(self.pos[0]), int(self.pos[1])) and then use self.posint in the draw, or whatever you want to call it. since redefining self.pos to int would screw other things up
Arcifer 2 months ago