Added: 2 years ago
From: thenewboston
Views: 21,923
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (134)

Sign In or Sign Up now to post a comment!
  • never mind

  • Please help it works for everything except the ball wont go right. Ive gone over the code many times and there are no mistakes

  • it wont work for me, it wont load the window, its just frozen on my screen and i dont know why :(

  • 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 If you followed the last couple videos, you may have left in some code from the first basic program.

  • I't keeps saying:

    There's an error in your program:

    unindent does not match any outer indentation level

  • @MinecraftFasds go on the format tab and click dedent region

  • i tried running my program and the window came up and then didnt respond....any help?

  • screen-blit(background,(0,0))

    NameError: name 'blit' is not defined

  • @iEatgunz .blit not -blit :)

  • @iEatgunz did you mean, screen DOT blit? check for dots and extra whitespaces.

  • i keep getting errors about the blit things

  • 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.

  • I type this in exactly ad get a syntax error that points to the elif statement. help please!

  • i've got a syntax error, even if i made that perfectly. why?

  • @AlexTheBulgarianMan Did you make sure the elif statement is lined up with

    the if statement above it, that was the problem with mine.

  • @italyhorse45 yes, i did, the problems isn't there. I have an error called "no module named locals"

  • @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

  • ;') hear that? he just follows his heart *sniffle sniffle*

  • Comment removed

  • 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 you must make sure your 'elif' is all line up in the straight line,hope this help...... :)

  • how do we run what we have created???

  • @2810Mad Have you watched his python tutorials?

  • @carlaraya256 sry I havent im new to this stuff

  • @2810Mad You can either go to the run option in the top of the screen, or press f5.

  • @Programminggonebad thx mate ^^

  • 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

  • Wow. I don't believe it, I actually did it! c:

  • Help! it keeps saying "Couldn't open 003.jpg" (my picture) I made it look exactly like his and its not working.. helapalpal!

  • @Alaskanbisk make sure its in the same directory, for example both the python file and the image could be on your desktop.

  • 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.

  • 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...

  • You my friend, are amazingly helpful.

  • i keep getting the same problem it says unident does not match any outer identation

    can any1 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

  • 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 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 thanks

  • @MrEldrane lol add ".png" after "ball"

  • My image moves like a damn turtle lol but it works thanks for the video keep up the great work.

  • 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?

  • my ball wont stop moving and i did everything just like this tutorial and i dont know why it wont stop moving lol...

  • Is my program unresponsive because of IDLE? No errors occur,just the pygame window starts black and the is unresonponsive.

  • Comment removed

  • @turtleanj is it saved to your desktop?

  • i get an error every time saying it cant open bg.jpg

  • how do you make your character keep movingif you hold down the key

  • @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!!!

  • follow your heart, thats what i do.

  • 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 Check that you have commas in the right places in:

    screen.blit(background,(0,0))

    screen.blit(mouse_curs,(x,y))

  • 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 nevermind, I've had the rows wrong. Thank you again for the videos :)

  • Comment removed

  • 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

  • @MrJoshPeach If you still need help with this, move the x,y = 0,0 to before the while True loop

  • @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 are u sure it is properly indented? remember that python is really annoying with indentation.

  • @fafase It was indentation. Thanks for the help!

  • 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 did you include pygame.display.update()

  • @ProgaKun I have this issue aswell.

  • Comment removed

  • Does relative directory searching work?

    I.E: ".../graphics/ball.png"

  • 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

  • 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.

  • you can go off screen with the ball!!!

    LOL

  • 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!

  • "Uhum um bla bla...it changes by negative down.."

    LOL? Nice tutorials xD

    I luve ur style of teaching.Tuna.

  • 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

  • if event.type==KEYUP:  movex, movey=0,0

    isn't this more easyer than that longer one

  • @Dexdix2 yes but after i tried it, your version is a bit laggier with the controls.. so i prefer this longer one :)

  • Bucky, you are so owesome..!!

  • Why my program keep freezing when I run it

  • my left button don't work

  • How can just: event.key==KEYUP: Screw up the entire thing...?

  • 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.

  • 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 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 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.

  • @Jonte135 use this instead jonte, works perfectly hehe

    if event.type==KEYUP:  movex,movey=0,0

  • I got this :( please help me

    Traceback (most recent call last): File "C:/Python26/del.py", line 11, in <module> background=pygame.image.load(b­if).conver()

    AttributeError: 'pygame.Surface' object has no attribute 'conver'

  • @LennyHandsome

    hi -

    You forgot a "t" at 'convert'...

  • @Diekatzeful yes I noticed thanks

  • @LennyHandsome Come on dude the typo is right in your face, is conver a word? Didnt think so. make it convert...

  • when i run it and press on the navigation keys nothing happens

    :( please help

  • Comment removed

  • give me the ball image, i cant make a ball.png!

  • @ownz100 Don't you have paint? Or if you don't have Windows try GIMP.

  • cool... i can even use 0.1 to slow down.

  • when i compile it the window is just black

  • Comment removed

  • 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?

  • 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)

  • 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?

  • 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

  • dude love your vids but once i have made the program how do i run it and test it?

  • under the run, click run module, or just press F5

  • It works :D. It didn't at first due to a typo.

    Thanks.

  • pygame window not responding wwhyyyyy!!!!!!!

  • THANX

  • Comment removed

  • Comment removed

  • 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..

  • wrong whitespace (tabs, spaces)

  • ah okay, thank you you are right, now it finally works

  • 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!

  • That's because there is no animation framerate control implemented yet!

  • i can never get the images to load!

    heres what i have in image loading

    back = pygame.image.load("bg.jpg").co­nvert()

    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

  • back = pygame.image.load("bg.jpg").co­nvert()

    no space in covert?

  • That's YouTube's fault.

  • Are your images even in the directory your code is in? -_-

  • either you call update or flip,not both, I'd for flip, so when you use double buffer it still works.

  • Comment removed

  • kik ass dude =)

  • Can't you just make them yourself using a simple image editor? It would only take a few minuets.

  • @bebebo30 how??

  • @ownz100 just make a ball in for example paint. and save as .PNG in stead of .JPG

  • @bebebo30 google image !!!

  • elif? seriously?  lol, nice tutorial.

  • @dandymcgee What's wrong with elif?

  • Theres no way that can be wrong , CAN IT=?!

  • awsome video

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more