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
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
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
You are an excellent teacher! I'd love it if you could read through the starter code files and explain them because this just looks too easy to follow.
Excellent as always! I just have a question, I tried to control the ball with the keyboard, using both keyDown and keyUp, but if I hold the button on the keyboard it stops moving. What am I doing wrong? Tks!
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
Chaz7201 2 weeks ago
Comment removed
Chaz7201 2 weeks ago
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
skyler114 2 months ago
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
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.
60namrruC 3 months ago
Nice tutorial but I don't get how dir.length works
xFelicianoX 5 months ago
@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
badmephisto 5 months ago
@Hobben93
@faithfulnathan
self.pos.inttup() converts the vec2d item into a integer tuple
Found this when i was exploring the vec2d module
Dragonno96 6 months ago
@Dragonno96 Thanks for the tip, that fixed the TypeError problem.
frenzic91 2 months ago
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
@faithfulnathan i have the same problem, plz respond
Hobben93 8 months ago
@Hobben93 Found this fixed the problem:
- In Class Starter, in the Draw(draw) method, change 'self.pos' to '(int(self.pos[0]), int(self.pos[1]))'
ie. pygame.draw.circle(self.screen, (0,0,0), self.pos, 21) to pygame.draw.circle(self.screen, (0,0,0), (int(self.pos[0]), int(self.pos[1])), 21) and pygame.draw.circle(self.screen, (200,200,255), self.pos, 20) to pygame.draw.circle(self.screen, (200,200,255), (int(self.pos[0]), int(self.pos[1])), 20)
faithfulnathan 8 months ago
@faithfulnathan I keep getting the same problem. DX
LordNokturne 2 months ago
how do you use an img for the player?
ariel32123 1 year ago
Awesome tutorials!
XAutomatedOwnerX 1 year ago
You are an excellent teacher! I'd love it if you could read through the starter code files and explain them because this just looks too easy to follow.
gorogawa 1 year ago
Excellent as always! I just have a question, I tried to control the ball with the keyboard, using both keyDown and keyUp, but if I hold the button on the keyboard it stops moving. What am I doing wrong? Tks!
thiagocavila 1 year ago
Great tutorial. Please make more of these. I myself would like to learn more about how to handle boundaries and collision detection :)
kjpersson 1 year ago
Comment removed
kjpersson 1 year ago
Game maker is fun, it's less "programming" but more a program which you use to create games. Try it if you want :3
AwdioSurfer 1 year ago
@AwdioSurfer Less programming means less features though.
XAutomatedOwnerX 1 year ago
@XAutomatedOwnerX I know, but I mean "less" as in it's "click and drag" in game maker, but here you have to type it all out
AwdioSurfer 1 year ago
@AwdioSurfer Ooooooh well i like writing the code myself :) but yah i can see how some people would like that.
XAutomatedOwnerX 1 year ago
Comment removed
patrick1020000 1 year ago