Debugging in Pygame

preview_player
Показать описание
How to access information in order to debug games. The major problem we have to overcome is that the game loop produces too much output if we use the if statement. This video goes through how to create a debug panel to access information, which makes debugging drastically easier.

(You also get lots of perks)

Social stuff:
Рекомендации по теме
Комментарии
Автор

Apriciate it! It is really hard to keep making new topics on pygame, especially tutorials! Great job!

tarantula
Автор

Thanks, it's way better than print debugging, and here is the source code (i changed names a bit and add offset of '10' by default):


import pygame

pygame.init()
font = pygame.font.Font(None, 30)


def logd(info, y=0, x=0):
surface = pygame.display.get_surface()
text = font.render(str(info), True, 'white')
rect = text.get_rect(topleft=(x + 10, y + 10))
pygame.draw.rect(surface, 'Black', rect)
surface.blit(text, rect)

rudomir-__-
Автор

the moment i pressed the like button under this video was when you showed the cute pixel cat

Damrok
Автор

Hello, I am really happy that you are preparing these tutorials, so thank you. Can you also show us how to make inventory systems in pygame? Or you already planned?

MustafaTuncay..
Автор

good job! This is what i needed for my code

Bonfere
Автор

Hey i always have a problem where everything i write past exit() comes as code is unreachable and i have tried everything and i cant fix it. Do you have any idea why. It might be a simple code like the one from 1:18 but still it doesn't work .

dennys.
Автор

Quick question. While working in multiple files, is it possible to run the debug function in different file than main.py?
I can't get it to work even if i import debug.

jirka_wazi
Автор

If u want to make it a little bit more advanced, maybe u can put it in a class so it can keep track of the debug texts, and can auto adjust the nex text pos. Maybe a bit over complicating, but it can be helpful is some situation.
But anyway it is a nice one, and i should start using something like this instead of print :D
So far did not had that much problem debuging with print. Most bugs come from my stupidity such as refering to a list when i recreate the list instead of use its own clear method, and then wondering why my projectile is still keep moving after it collided with an enemy. :D This one made me headache. But could find it out when i print out the list memory adress and could see 2 different function using 2 different adress.

Klannahar
Автор

Generally, on a Black background, the colour that is most legible (for most people) is Yellow.

carlfranz
Автор

Could you please do a tutorial about simple shaders? Such as: simple 2d lighting (day and night, torches), outline, water effect, glow effect. I really need these tutorial.

jk-gnfu
Автор

It would be really good if you introduced type hints in the debugging file. It would help us what exactly it takes and does, or returns.

mohiuddinsyed
Автор

Debug package for sublime text is not useful?

MrTega
Автор

it's a bit offtopic, but I just noticed when trying to implement this debug function in my code.
Does anybody know why I get the error "TypeError: invalid color argument" when passing colors in as string ?
screen.fill((0, 0, 0) works, but screen.fill('black') doesn't (so does every other color of the colordict in pygame documentation when I pass it as a string)

affezippel
Автор

Please start kivy🙏 and thanks for this tutorial

angadsingh
Автор

Please make a tutorial on endless runner 2d game in Godot

lahalrahman
Автор

By Cython as well.
That makes it very fast.
Even IronPython...

SkyFly
Автор

Pls start kivy for ios/Android since it runs pygame under the hood.

chigstardan
Автор

Please tutorials on algorithms like A*
Game AI
🙏🙏🙏🙏🙏🙏🙏🙏🏿🙏🏿🙏🏿🙏🏿🙏🏿

azgaming
Автор

Want some AI based games brother. 🙏🙏🙏 !!!

Pradeep.