Pygame Tutorial for Beginners - Python Game Development Course

Pygame Tutorial for Beginners - Python Game Development Course

freeCodeCamp.org

5 лет назад

2,044,007 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@tienmy4521
@tienmy4521 - 27.11.2023 13:27

Although I struggle for 3 days, but nice for beginners like me. Thank you so much! Hope u have the best when prodiving very detailed and free-acess education for people!

Ответить
@NPRojas
@NPRojas - 11.12.2023 23:15

Es una gran introducción a PyGame.
¡Felicitaciones!

It is a great introduction to PyGame.

Congratulations!

Ответить
@Zkauba24
@Zkauba24 - 13.12.2023 03:56

<3

Ответить
@LeraxTheChilledLonelyBoy
@LeraxTheChilledLonelyBoy - 22.12.2023 19:30

Freecodecamp, please try to post a video on the tutorial ursina python 3d game engine.

Ответить
@GetRealwithMike
@GetRealwithMike - 25.12.2023 04:40

You should make something like this for teachers to teach certain chunks of knowledge and then the person can play if they get the answers right. Work, then play, then work, then play

Ответить
@eduardorocha2767
@eduardorocha2767 - 01.01.2024 15:56

Tremendous, thanks for the tutorial!

Ответить
@Dragonforge-Studios
@Dragonforge-Studios - 14.01.2024 12:29

Good course but you have a bad habit of using too much comments

Ответить
@Garuna_techz
@Garuna_techz - 30.01.2024 12:39

Hey screen fill is not working

Ответить
@greeng448
@greeng448 - 30.01.2024 16:13

some how I have to press alt and spacebar at the same time in order to shoot the bullet. strange..... :V

Ответить
@godfryddolbinczykunical1571
@godfryddolbinczykunical1571 - 15.02.2024 22:36

Szkoda tylko że nie ma mechaniki FPS, a to podstawa nawet w najprostszych grach w pygame.

Ответить
@sakthivelmaribe8120
@sakthivelmaribe8120 - 03.03.2024 14:18

Really is wonderful journey for gaming

Ответить
@AryanPancholi-u9m
@AryanPancholi-u9m - 08.03.2024 01:13

amazing

Ответить
@sidratulmuntaha4050
@sidratulmuntaha4050 - 28.03.2024 19:33

How to atually add photos in vs code
as png files

Ответить
@HausianGamingYT
@HausianGamingYT - 11.04.2024 01:22

I've been searching for how to add the PNG images to the Pycharm Directory, or in other words, the sidebar list. That was skipped in the tutorial -- the file was already there when that chapter started.

I have the image I'd like to use for my player icon (spaceship). Any advice on how this is properly done?

I'm using a Mac.

Ответить
@poojaingole2536
@poojaingole2536 - 11.04.2024 13:32

Everyone who just got learned properly because of this man and i learned this in just some minutes people who think that this man should get the best teacher award (Like)

Ответить
@AwesomeUvomata-c1d
@AwesomeUvomata-c1d - 20.04.2024 21:06

this video is good

Ответить
@abeloiscauchy8009
@abeloiscauchy8009 - 09.05.2024 14:08

i love this guy

Ответить
@nadirikram5612
@nadirikram5612 - 21.05.2024 04:46

This tutorial is nothing short of amazing, I am working on a school project and using this video, I was taught how to use something I was considered a complex topic, so efficiently. Big thanks to you guys at freeCodeCamp. Cheers!

Ответить
@abominablemusic
@abominablemusic - 23.05.2024 13:18

just finished this tutorial - it's great. Many thanks for making this and making it easy to follow.

Ответить
@jitteshwaransaktivel1414
@jitteshwaransaktivel1414 - 11.06.2024 17:53

My player and enemy are glitching

Ответить
@debokikantalahirichowdhury4986
@debokikantalahirichowdhury4986 - 20.06.2024 09:40

PNG file image is not loading in mine, the image does not get loaded, when I try to run the code, it shows "Unsupported Image Format" !! What should I do ??

Ответить
@BMO-28
@BMO-28 - 24.06.2024 20:23

best tutorial about pygame❤‍🔥

Ответить
@NElectronicSoul
@NElectronicSoul - 25.06.2024 17:35

this is fucking terrible

Ответить
@dileepkm3940
@dileepkm3940 - 27.06.2024 17:29

How to add the downloaded png to your poroject

Ответить
@dileepkm3940
@dileepkm3940 - 04.07.2024 02:42

Showing many errors don't know why

Ответить
@VinodKhutekar-dq2ko
@VinodKhutekar-dq2ko - 13.07.2024 11:44

Anyone from 8std

Ответить
@ArmandoAguilar-e2g
@ArmandoAguilar-e2g - 16.07.2024 18:34

For some reason it wont let me insert a image

Ответить
@t.kaystkays6514
@t.kaystkays6514 - 19.07.2024 12:35

This tutorial helped me in preparation of using Unreal engine and studying software engineering at university level

Ответить
@muhammadhuzaima6026
@muhammadhuzaima6026 - 04.08.2024 13:33

For some reason my bullet isnt appearing on the screen.

import pygame
import random

pygame.init()
running = True
# Screen
screen = pygame.display.set_mode((1200, 800))
image = pygame.image.load('rocket.png')
pygame.display.set_icon(image)
# Background
background = pygame.image.load('background.jpg')

# player
player_image = pygame.image.load('spaceship.png')
playerX = 550
playerY = 650
playerchange = 50

# Enemy
enemy_image = pygame.image.load('enemies.png')
enemyX = random.randint(0, 1200)
enemyY = random.randint(50, 150)
enemychangeX = 0.3
enemychangeY = 30

# Bullet
bullet_image = pygame.image.load('bullet.png')
bulletX = 0
bulletY = 650
bullet_state = False
bulletchangeY = 10


# Drawing spaceship on the surface
def player(x, y):
screen.blit(player_image, (x, y))


def enemy(x, y):
screen.blit(enemy_image, (x, y))


def bullet_fire(x, y):
global bullet_state
bullet_state = True
screen.blit(bullet_image, (x + 16, y + 10))


# Game loop
while running:

for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
playerX = playerX - playerchange
if event.key == pygame.K_RIGHT:
playerX = playerX + playerchange
if event.key == pygame.K_SPACE:
bullet_fire(playerX, bulletY)
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
playerX = playerX

if playerX <= 0:
playerX = 0
if playerX >= 1072:
playerX = 1072
enemyX += enemychangeX
if enemyX <= 0:
enemychangeX = 0.3
enemyY += enemychangeY
elif enemyX >= 1072:
enemychangeX = -0.3
enemyY += enemychangeY
if bullet_state is True:
bullet_fire(playerX, bulletY)
bulletY -= bulletchangeY

screen.fill((0, 0, 0))
screen.blit(background, (0, 0))
player(playerX, playerY)
enemy(enemyX, enemyY)
pygame.display.update()


(Can anyone tell me whats the problem)

Ответить
@stephimalzkorn
@stephimalzkorn - 04.08.2024 20:45

You come up with the idea of a game, teaching everything one needs to accomplish it. Much better than any book or tutorial I ever read!

Ответить
@DexterTheDamned
@DexterTheDamned - 08.08.2024 12:43

I watched it one sitting

Ответить
@CaptainL3v1
@CaptainL3v1 - 14.08.2024 14:56

can someone please tlel me how to get the autofill thing cuz they don't come up for me

Ответить
@prabudhanasekar3786
@prabudhanasekar3786 - 14.08.2024 18:14

code is correct but spaceShip is not moving

Ответить
@Aolves
@Aolves - 18.08.2024 05:42

Wayyy better

Ответить
@AlcottWendy-r6x
@AlcottWendy-r6x - 16.09.2024 08:51

Hernandez Maria Hall Sarah Gonzalez Brian

Ответить
@OmnionicX_YT
@OmnionicX_YT - 22.09.2024 13:55

Im indian and I think this man has destroyed everyone's expectations of our english

Ответить
@somshridhar
@somshridhar - 28.09.2024 22:47

Wow Finally I successfully completed coding , implemented and played the game. Thanks a lot

Ответить
@dileepkm3940
@dileepkm3940 - 04.10.2024 19:11

can print our score on the game window

Ответить
@rijultandon728
@rijultandon728 - 08.10.2024 16:07

excellent

Ответить
@AshikulIslam-py1hf
@AshikulIslam-py1hf - 10.10.2024 13:24

loved the video

Ответить
@muhammeduzair5804
@muhammeduzair5804 - 12.10.2024 12:52

using flaticon u have to use 500 px just download it then open where its saved then change its size

Ответить
@AffectionateCentaur-sd7do
@AffectionateCentaur-sd7do - 15.10.2024 17:02

Whenever i am trying to run the program the screen of pygame doesn’t work
Is there any solution for me?

Ответить
@pokemonpockt
@pokemonpockt - 20.10.2024 19:36

bullet wont stay with the ship. fires from left side of screen only. how to fix?

Ответить