The only helpful tip I can give for you guys havin trouble is to make sure your pictures (background picture and mouse picture) are in your python folder. If you don't know what your python folder is... I have a folder in my documents that says "Python Files". I put my pictures in there and that fixed it. Hope it helps.
@AlexTheBulgarianMan Make sure at the top of the script you're writing that it says the following statements, one line each and without quotes "import python" "from python.locals import *"
I followed everything and all i get when it runs is a black screen, no errors, no anything, just a black box. I have checked everything like 10 times and been working on this forever and cant get it to work. plz help me
@jjobros I had that error too, i don't know if you got it solved but the solution is simple,make sure all the "if" and "elif" are lined up cause when i copied and pasted, they weren't lined up vertically
@MrEldrane You need to put your picture file with the python file you created. (ex. I have mine in a "Python Stuff" folder it has my python files and the pictures I use)
To be completely honest, this type of event checking isn't all that powerful. If the program is constantly CHECKING for input, that's squandering it's resources for something more advances, like the AI. A better way of doing this would to let the event TELL the program when it's triggered. It's like a fire alarm that is always ringing until there's a fire happening, really.
i am new to this and i noticed something. if you try to not use a background all it does is make a hole lot of pictures and the next pic is moved the way you told it. so when you use the background it just covers up the other pics. this will slow down the game if you play it for a while, because their is so many pics. how would you delete the picture that is covered up by the updated picture?
Instead of an image as a background, you can also set the background as black and use screen.fill(black) rather than screen.blit. You have to use RGB values but you can set black = (0, 0, 0) so you can use 'black' whenever you want that color chosen.You'll have to fiddle around a bit but it will also teach you more Pygame in the process.
Screen.blit makes his background reappear again. If your image bg is smaller than the window, you'll get trails from your previous cursor position.
HI, I made my two images in paint and it runs the problem is my ball doesn't move properly it only moves a millimeter in the direction and stops then moves back, it look likes its shaking, any help would be appreciated
Hello! I loved the tutorial! I know that bucky won't answer this, so this is for anyone who wants to help me out. I coped everything perfectly but when I start the program it shows the background, the ball but...I can't move it. Help? Thanks in advance!
Great tutorial. However, I noticed that if I gold both left and right down at the same time, I can press up and I will go up. However, if I hold both left and right down at the same time and press down, I will not move down. How can I fix this problem? It is very annoying.
Is there a function like "if event.type=KEYHELDDOWN"? That would also help. Thanks!
haha, i love you bucky, you make great tutorials, and they have a little humor in there for us sometimes too when we are frustrated/need something to cheer us up. hahahaha.
i run the program and i press the left arrow, the ball goes left and wont stop unless i press the right arrow,and none of the other buttons work left is the only one, it starts it going left, and it dont see the KEYUP it only stops if i press the right arrow ,but that only stops it,it doesnt go any other direction,i copied your code exactly i dont see any errors ill keep checking.PLEASE HELP.
@Jonte135 Nope, that means if any keyboard on the keyboard is up, you cant move. You would literally have to push every button on the keyboard for it not to set your move to 0 every frame.
how do you lock the movement of the mouse to the size of the frame window? Because right now, when i keep holding up/down/left/right button, the mouse seems to go further in those direction, even while the mouse if off the frame screen.
Is there a way to add a "super boost" by like having to hold shift...it would just be another if statement that says liek if SHIFT + K_LEFT then the shape would move faster then just K_LEFT without shift? how would i do this?
Hi,guys,I am confusing with the KEYDOWN in pygame. I made a ball moving on the screen, and I just test KEYDOWN, when I press KEYLEFT once and release it, the ball moves and does not stop, I know I have to test KEYUP to stop it but I do not know why. Since I think in the for loop, first time I get a KEYDOWN event and remove the KEYDONW event from the queue, and do something, then after refresh, there is no event in the queue, how the movex or movey be changed?
i cant run the program, because an error message sais "uninden does not match any outer indentation level"...
and then in the program the line " elif event.key==K_RIGHT:" is marked red... but i cant se any failiture in it, since i just copiedit from the upper lines, wheres nothing wrong.....
Dude, there is an option for every desktop recorder to move the recording area. In Camstudio and Camtasia studio it is seen as four green flashing angle lines.
wow, when i play it it moves so much smoother than in his...but it also lags the internet, liek wehn i scroll my screen i cans ee the lag from the game running...thanks thenewboston!
never mind
BoringAirsofter100 4 days ago
Please help it works for everything except the ball wont go right. Ive gone over the code many times and there are no mistakes
BoringAirsofter100 4 days ago
it wont work for me, it wont load the window, its just frozen on my screen and i dont know why :(
RetroPretzle 1 week ago
It runs ok see the red ball. My only problem wich is a HUGE ONE is that I can only control the ball with my mouse. PPPLLLLEEEAAASSSE HELP
TheManManolo 1 month ago
@TheManManolo If you followed the last couple videos, you may have left in some code from the first basic program.
Darkgold1021 1 month ago in playlist More videos from thenewboston
I't keeps saying:
There's an error in your program:
unindent does not match any outer indentation level
MinecraftFasds 1 month ago
@MinecraftFasds go on the format tab and click dedent region
earthsbrawler 4 weeks ago in playlist More videos from thenewboston
i tried running my program and the window came up and then didnt respond....any help?
sc2videomaker 1 month ago
screen-blit(background,(0,0))
NameError: name 'blit' is not defined
iEatgunz 1 month ago
@iEatgunz .blit not -blit :)
WhoopMQ 1 month ago in playlist More videos from thenewboston
@iEatgunz did you mean, screen DOT blit? check for dots and extra whitespaces.
ExRedRain 1 month ago
i keep getting errors about the blit things
iEatgunz 1 month ago
The only helpful tip I can give for you guys havin trouble is to make sure your pictures (background picture and mouse picture) are in your python folder. If you don't know what your python folder is... I have a folder in my documents that says "Python Files". I put my pictures in there and that fixed it. Hope it helps.
TheAJkiter 1 month ago
I type this in exactly ad get a syntax error that points to the elif statement. help please!
italyhorse45 1 month ago
i've got a syntax error, even if i made that perfectly. why?
AlexTheBulgarianMan 1 month ago
@AlexTheBulgarianMan Did you make sure the elif statement is lined up with
the if statement above it, that was the problem with mine.
italyhorse45 1 month ago
@italyhorse45 yes, i did, the problems isn't there. I have an error called "no module named locals"
AlexTheBulgarianMan 1 month ago
@AlexTheBulgarianMan Make sure at the top of the script you're writing that it says the following statements, one line each and without quotes "import python" "from python.locals import *"
sharpiedyourwhat 1 month ago
I followed everything and all i get when it runs is a black screen, no errors, no anything, just a black box. I have checked everything like 10 times and been working on this forever and cant get it to work. plz help me
MrRutt0568 1 month ago
;') hear that? he just follows his heart *sniffle sniffle*
MrNeemer 1 month ago
Comment removed
MrRianael 2 months ago
there's an error in my program apparently ;~; "unindent does not match any outer indentation" and the KEYDOWN: line is in the red so any ideas here?
KermitAndShawn 2 months ago in playlist Computer Game Development Tutorial
@KermitAndShawn you must make sure your 'elif' is all line up in the straight line,hope this help...... :)
AenHacker 2 months ago
how do we run what we have created???
2810Mad 2 months ago
@2810Mad Have you watched his python tutorials?
carlaraya256 2 months ago
@carlaraya256 sry I havent im new to this stuff
2810Mad 2 months ago
@2810Mad You can either go to the run option in the top of the screen, or press f5.
Programminggonebad 1 month ago
@Programminggonebad thx mate ^^
2810Mad 1 month ago
thumbs up if it was your first time and you actually played around with the directional keys in amazement, not believing what you just did
austinewunclerful 2 months ago
Wow. I don't believe it, I actually did it! c:
xDFancyPantsxD 3 months ago
Help! it keeps saying "Couldn't open 003.jpg" (my picture) I made it look exactly like his and its not working.. helapalpal!
Alaskanbisk 3 months ago in playlist More videos from thenewboston
@Alaskanbisk make sure its in the same directory, for example both the python file and the image could be on your desktop.
InspironFilms1 2 months ago in playlist Computer Game Development Tutorial
My cursor wont go up or down, but it will go left and right. It looks like I did everything as you said, but maybe im missing something.
LordNokturne 3 months ago
If you want the sensitivity of the ball movement to go faster, change the movex and movey to 2 and -2, or 5 and -5, etc...
llewgnolm 3 months ago in playlist More videos from thenewboston
You my friend, are amazingly helpful.
Alaskanbisk 3 months ago in playlist Computer Game Development Tutorial
i keep getting the same problem it says unident does not match any outer identation
can any1 help me
jjobros 4 months ago
@jjobros I had that error too, i don't know if you got it solved but the solution is simple,make sure all the "if" and "elif" are lined up cause when i copied and pasted, they weren't lined up vertically
kidkouga 3 months ago
It can't open the file for the mouse image. I'm sure I put in the right file name (C:\Documents and Settings\Jack McKenna\Desktop\ball)
MrEldrane 4 months ago
@MrEldrane You need to put your picture file with the python file you created. (ex. I have mine in a "Python Stuff" folder it has my python files and the pictures I use)
iamcoolsweet 4 months ago
@iamcoolsweet thanks
MrEldrane 4 months ago in playlist Computer Game Development Tutorial
@MrEldrane lol add ".png" after "ball"
kidkouga 3 months ago
My image moves like a damn turtle lol but it works thanks for the video keep up the great work.
MKShadowX 5 months ago
To be completely honest, this type of event checking isn't all that powerful. If the program is constantly CHECKING for input, that's squandering it's resources for something more advances, like the AI. A better way of doing this would to let the event TELL the program when it's triggered. It's like a fire alarm that is always ringing until there's a fire happening, really.
louisrocks40 5 months ago
i am new to this and i noticed something. if you try to not use a background all it does is make a hole lot of pictures and the next pic is moved the way you told it. so when you use the background it just covers up the other pics. this will slow down the game if you play it for a while, because their is so many pics. how would you delete the picture that is covered up by the updated picture?
justin6532 5 months ago in playlist Computer Game Development Tutorial
my ball wont stop moving and i did everything just like this tutorial and i dont know why it wont stop moving lol...
xxskitzo4201 5 months ago
Is my program unresponsive because of IDLE? No errors occur,just the pygame window starts black and the is unresonponsive.
TheFirstSpawnOfMyMom 6 months ago
Comment removed
TheFirstSpawnOfMyMom 6 months ago
@turtleanj is it saved to your desktop?
tspideyboy 6 months ago
i get an error every time saying it cant open bg.jpg
turtleanj 6 months ago
how do you make your character keep movingif you hold down the key
hamrwolf 6 months ago
@hamrwolf Don't check for KEYDOWN events the way, he does. Just do the QUIT part the way he does.
Then, outside the if statement(inside the loop), do this:
pressed_keys = pygame.key.get_pressed()
if pressed_keys[K_UP]: movey = -1
if pressed_keys[K_DOWN]: movey = +1
if pressed_keys[K_LEFT]: movex = -1
if pressed_keys[K_RIGHT]: movex = +1
Hope this helps!!!
achuaditi 6 months ago 2
follow your heart, thats what i do.
SpaceMongoose 7 months ago
I've checked my syntax/indentation 3 times, I'm still getting an error stating "TypeError: 'pygame.Surface' object is not callable"? Any ideas?
DaedalianDork 7 months ago
@DaedalianDork Check that you have commas in the right places in:
screen.blit(background,(0,0))
screen.blit(mouse_curs,(x,y))
hadron2 6 months ago
thanks for the video.
I have a little problem-instead of moving any time I keep the key down, the ball only moves 1 pixel while it's being held then stops. Why?
guykuglo 7 months ago
@guykuglo nevermind, I've had the rows wrong. Thank you again for the videos :)
guykuglo 7 months ago
Comment removed
contranton123 7 months ago
Instead of an image as a background, you can also set the background as black and use screen.fill(black) rather than screen.blit. You have to use RGB values but you can set black = (0, 0, 0) so you can use 'black' whenever you want that color chosen.You'll have to fiddle around a bit but it will also teach you more Pygame in the process.
Screen.blit makes his background reappear again. If your image bg is smaller than the window, you'll get trails from your previous cursor position.
Vazeroth16 8 months ago
HI, I made my two images in paint and it runs the problem is my ball doesn't move properly it only moves a millimeter in the direction and stops then moves back, it look likes its shaking, any help would be appreciated
MrJoshPeach 9 months ago
@MrJoshPeach If you still need help with this, move the x,y = 0,0 to before the while True loop
Abengoshis 7 months ago
@thenewboston
for some reason, on the last line of the code I get an error saying invalid syntax over pygame.display.update()
Please Help!
TheKasattack 9 months ago
@TheKasattack are u sure it is properly indented? remember that python is really annoying with indentation.
fafase 8 months ago
@fafase It was indentation. Thanks for the help!
TheKasattack 8 months ago
Hello! I loved the tutorial! I know that bucky won't answer this, so this is for anyone who wants to help me out. I coped everything perfectly but when I start the program it shows the background, the ball but...I can't move it. Help? Thanks in advance!
-Proga
ProgaKun 10 months ago
@ProgaKun did you include pygame.display.update()
maradona640 10 months ago
@ProgaKun I have this issue aswell.
drewlark99 10 months ago
Comment removed
ProgaKun 10 months ago
Does relative directory searching work?
I.E: ".../graphics/ball.png"
nosehair26 11 months ago
For everybody with problems getting access to their bg... Add the directory to your image file and it should work, ex. C:/Users/Jimmy/Desktop
PurexOvvnage 1 year ago
ooh boy for some reason, i tried to run the program in the idle, it said it couldnt open bg, though it worked for the first tut.
OCoptimusconvoy 1 year ago
you can go off screen with the ball!!!
LOL
TheMisterMan101 1 year ago
Great tutorial. However, I noticed that if I gold both left and right down at the same time, I can press up and I will go up. However, if I hold both left and right down at the same time and press down, I will not move down. How can I fix this problem? It is very annoying.
Is there a function like "if event.type=KEYHELDDOWN"? That would also help. Thanks!
bf2widowmaker 1 year ago
"Uhum um bla bla...it changes by negative down.."
LOL? Nice tutorials xD
I luve ur style of teaching.Tuna.
idvhfd 1 year ago
My python IDE gvies me the below. why? It's indented correctly....I hate python!
elif event.key==K_DOWN:
^
IndentationError: unindent does not match any outer indentation level
zRichi 1 year ago
if event.type==KEYUP: movex, movey=0,0
isn't this more easyer than that longer one
Dexdix2 1 year ago
@Dexdix2 yes but after i tried it, your version is a bit laggier with the controls.. so i prefer this longer one :)
RevaqOfTheLight 1 year ago
Bucky, you are so owesome..!!
didier566 1 year ago
Why my program keep freezing when I run it
salehyassin 1 year ago
my left button don't work
dominater5 1 year ago
How can just: event.key==KEYUP: Screw up the entire thing...?
Weirdo10o4 1 year ago
haha, i love you bucky, you make great tutorials, and they have a little humor in there for us sometimes too when we are frustrated/need something to cheer us up. hahahaha.
vlangjahr 1 year ago
i run the program and i press the left arrow, the ball goes left and wont stop unless i press the right arrow,and none of the other buttons work left is the only one, it starts it going left, and it dont see the KEYUP it only stops if i press the right arrow ,but that only stops it,it doesnt go any other direction,i copied your code exactly i dont see any errors ill keep checking.PLEASE HELP.
disneyfannrkrb 1 year ago
Just wondering, can't you just do:
if event.type==KEYUP:
movex=0
movex=0
movey=0
movey=0
But with tab of course.
Jonte135 1 year ago
@Jonte135 Nope, that means if any keyboard on the keyboard is up, you cant move. You would literally have to push every button on the keyboard for it not to set your move to 0 every frame.
FuzetsuRed 1 year ago
@FuzetsuRed but by pressing all the arrows it would only go right and down as they movex/y is set using an equal sign and not a plus or minus.
level1kid 1 year ago
@Jonte135 use this instead jonte, works perfectly hehe
if event.type==KEYUP: movex,movey=0,0
dagarath 1 year ago
This has been flagged as spam show
What's The Purpose of life ?
Here you will get the answer :
islamtomorrow (DOT) com/purpose.htm
converts
converts-ahmd.blogspot (DOT) com/
((( Acquainted With Islam )))
aslam-ahmd.blogspot (DOT) com/
acquaintedwithislam.maktoobblog (DOT) com/
ahmd1431 1 year ago
I got this :( please help me
Traceback (most recent call last): File "C:/Python26/del.py", line 11, in <module> background=pygame.image.load(bif).conver()
AttributeError: 'pygame.Surface' object has no attribute 'conver'
LennyHandsome 1 year ago
@LennyHandsome
hi -
You forgot a "t" at 'convert'...
Diekatzeful 1 year ago
@Diekatzeful yes I noticed thanks
LennyHandsome 1 year ago
@LennyHandsome Come on dude the typo is right in your face, is conver a word? Didnt think so. make it convert...
FuzetsuRed 1 year ago
when i run it and press on the navigation keys nothing happens
:( please help
didagoal 1 year ago
Comment removed
didagoal 1 year ago
give me the ball image, i cant make a ball.png!
ownz100 1 year ago
@ownz100 Don't you have paint? Or if you don't have Windows try GIMP.
Jonte135 1 year ago
cool... i can even use 0.1 to slow down.
kinmanyuen 2 years ago
when i compile it the window is just black
raver2008 2 years ago
Comment removed
PsycoHenny 2 years ago
how do you lock the movement of the mouse to the size of the frame window? Because right now, when i keep holding up/down/left/right button, the mouse seems to go further in those direction, even while the mouse if off the frame screen.
hoyun 2 years ago
Is there a way to add a "super boost" by like having to hold shift...it would just be another if statement that says liek if SHIFT + K_LEFT then the shape would move faster then just K_LEFT without shift? how would i do this?
1xXxBENxXx1 2 years ago
you need to make like movex or movey is using a velocity variable to multiply speed... im not sure but like:
movex=-1*velocity
if shift is not pressed than velocity is 1
if shift is pressed then velocity is 2 (or whatever you like)
kinmanyuen 2 years ago
Hi,guys,I am confusing with the KEYDOWN in pygame. I made a ball moving on the screen, and I just test KEYDOWN, when I press KEYLEFT once and release it, the ball moves and does not stop, I know I have to test KEYUP to stop it but I do not know why. Since I think in the for loop, first time I get a KEYDOWN event and remove the KEYDONW event from the queue, and do something, then after refresh, there is no event in the queue, how the movex or movey be changed?
ratzip 2 years ago
Hi, I love your videos and it's very useful for me. One question: Is it really necessary to check every key after checking KEYUP:
I did like this and it's worked well: if event.type == KEYUP: movex=0 movey=0
thanks
biotep 2 years ago
dude love your vids but once i have made the program how do i run it and test it?
RyanLynchMindFreak 2 years ago
under the run, click run module, or just press F5
LockonStratos1 2 years ago
It works :D. It didn't at first due to a typo.
Thanks.
MrGrahameThomson 2 years ago
pygame window not responding wwhyyyyy!!!!!!!
baby2bla2009 2 years ago
THANX
crazynoob11 2 years ago
Comment removed
Fangornmmc 2 years ago
Comment removed
Fangornmmc 2 years ago
i got a problem with this...
i cant run the program, because an error message sais "uninden does not match any outer indentation level"...
and then in the program the line " elif event.key==K_RIGHT:" is marked red... but i cant se any failiture in it, since i just copiedit from the upper lines, wheres nothing wrong.....
please help..
Makromax 2 years ago
wrong whitespace (tabs, spaces)
sandorlev 2 years ago
ah okay, thank you you are right, now it finally works
Makromax 2 years ago
Dude, there is an option for every desktop recorder to move the recording area. In Camstudio and Camtasia studio it is seen as four green flashing angle lines.
gasto5 2 years ago
wow, when i play it it moves so much smoother than in his...but it also lags the internet, liek wehn i scroll my screen i cans ee the lag from the game running...thanks thenewboston!
bubbletanking 2 years ago
That's because there is no animation framerate control implemented yet!
gasto5 2 years ago
i can never get the images to load!
heres what i have in image loading
back = pygame.image.load("bg.jpg").convert()
mou = pygame.image.load("ball.png").convert_alpha() screen.blit(back, (0,0)) screen.blit(mou, (x,y)) pygame.display.update() pygame.display.flip()
please help
guitardude1991 2 years ago
back = pygame.image.load("bg.jpg").convert()
no space in covert?
0121ryanh117 2 years ago
That's YouTube's fault.
AbsalomPitchingfork 2 years ago
Are your images even in the directory your code is in? -_-
AbsalomPitchingfork 2 years ago
either you call update or flip,not both, I'd for flip, so when you use double buffer it still works.
gasto5 2 years ago
Comment removed
guitardude1991 2 years ago
kik ass dude =)
DaVietPride 2 years ago 2
This has been flagged as spam show
hey wtf where can i get those bg.jpg and ball.png
deipoo 2 years ago
Can't you just make them yourself using a simple image editor? It would only take a few minuets.
bebebo30 2 years ago 10
@bebebo30 how??
ownz100 1 year ago
@ownz100 just make a ball in for example paint. and save as .PNG in stead of .JPG
chillas 1 year ago
@bebebo30 google image !!!
Kamilk12l 6 months ago
elif? seriously? lol, nice tutorial.
dandymcgee 2 years ago 10
@dandymcgee What's wrong with elif?
Jonte135 1 year ago
Theres no way that can be wrong , CAN IT=?!
LuXxenatorX 2 years ago
awsome video
scooterboys56 2 years ago 2