Pygame (Python Game Development) Tutorial - 8 - Moving Objects

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

This is the best pygame tutorial I have seen!! The others are so are so fast and now I actually understand what I'm doing. I'm not just copying code

vihashah
Автор

first tutorial which is actually good! thanks sentex

TheRealAthex
Автор

i had wayyyy too much fun with the super fast square of quickness

MrZeroBrains
Автор

Your my hero, watching this video helped me solve a problem!!!

cheeseisnice
Автор

WHAT HE THIS IS WORKING THANKS MORE POWER TO COME

francisganapin
Автор

need this soo badly for my a lvl project :D

ThePerfect
Автор

I love how he laughed about it disappearing

dominigai
Автор

Is there a list of the completed code for each tutorial number. Sometimes my code does not quite behave like the one here and I feel that somewhere there is difference between what I have and what you have. I also like to play with a modified version on the code here when I have a question about something in the code and how exactly it does what it does. I would be nice to have a list of completed code for each of the tutorials. Thanks, you are doing, well, have done a great job.

mikebronosky
Автор

if you know python you can basically just look one frame each 20 seconds just to read his code and you learn how to program gamesway faster.
An advice for starters is that you lear Python before diving into game development.

josueanyosa
Автор

If you put the lead_x +=lead_x_change, indented wid the if cas of KEYDOWN, it works fine and it doesn't woosh also, so why is it neessary to indend wid the while loop of program.

Just a query, I'm a bit confused with both.

PratyushGarg
Автор

hello friend i want to write a clone of guitar hero with theading but when many points is falling the interface start to flicker change the fps but not

eliseotorres
Автор

Can someone explain the use of lead_x = lead_x_change for me? Thanks in advance.

sethdoescpp
Автор

Here's a cleaner solution to keys being held courtesy of stackoverflow:
This goes in the game loop.

keys = pg.key.get_pressed()
if keys[pg.K_RIGHT]:
#do whatever

spencer
Автор

To fix it running off the screen (without setting max FPS) you could use this code:
(
import pygame
import os
import sys
import time
)
and then at:
(
lead_x += lead_x_change
)
add a time.sleep() function so it can become
(
lead_x += lead_x_change
time.sleep(0.4)
)
I'm using 2.7 so I don't know if it works in 3.4, but it works on my project.

lowerurgrades
Автор

i dont know what's happening but whenever i run my pygame it shows black screen and when i close the game it shows the actual stuff which i have coded

Robin-fgjv
Автор

instead of changing fps you could have just decreased to size of lead_x_change from 10 to 1

ghostkr
Автор

Won't be just adding code: pygame.key.set_repeat() be enough to take care of this problem ?

madhukar
Автор

so, my square isn't super fast, but it moves every time i press the key AND every time i release it. Is there anything wrong with my code?
import pygame

pygame.init()

white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)

gameDisplay = pygame.display.set_mode((800, 600))



gameExit = False

lead_x = 300
lead_y = 300
lead_x_change = 0

while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
lead_x_change = -10
if event.key == pygame.K_RIGHT:
lead_x_change = 10

lead_x += lead_x_change
gameDisplay.fill(white)
pygame.draw.rect(gameDisplay, black, [lead_x, lead_y, 10, 10])
pygame.display.update()


pygame.quit()
quit()

steamonkey
Автор

i really need the sub caption cuz' my listen skill is very bad!!!
anyway...still wanna say thank so much!!

tahongtrung
Автор

Right after the event loop, add these lines:
---
lead_xy %= (your display width)
lead_xy %= (your display height)
---
It's way more fun like that.

someaccount
join shbcf.ru