Python Pygame Tutorial - Episode 4! Create a Player Object, and Define Player Controls and Movement!

preview_player
Показать описание
Learn to develop video games using python and pygame!! This is episode 4 in an intro to Pygame series from LeMaster Tech. This episode covers creating a player object and defining player controls and movement in the code!

Be sure to check out our channel for tons of additional python tutorials and practice problems and be sure to like and subscribe if you find our content useful!!

If you want to see anything specific on the channel or have technical questions about anything leave a comment on our of our videos and we will get back as soon as we can!

Thanks for watching and supporting the channel!
Рекомендации по теме
Комментарии
Автор

There is a much simpler way to make your character move:
#define the position of your character, do it outside of the loop
x = 20
y = 40
# note: the more you higher x or y, the faster your character will move.

# put this inside the loop, of where you want the character to move.
keys = pygame.key.get_pressed()

if keys[pygame.K_LEFT]:
x -= 3
if keys[pygame.K_RIGHT]:
x += 3
if keys[pygame.K_UP]:
y -= 3
if keys[pygame.K_DOWN]:
y += 3

# the character you want to move, assuming you already have assigned the image
screen.blit(current_character, (x, y))

hamidaferoz
Автор

The code works perfectly but notice that when we change direction along x, it takes a bit of time like a second to load. How do we solve that

qydpgjs
Автор

sir, can i get the
code of this tutorial ?? plz reply fast ...

tejendrakanwar