Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 05:16:56 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsUseful Pygame Tips, Tricks, and Secrets
Pages: [1]
Print
Author Topic: Useful Pygame Tips, Tricks, and Secrets  (Read 9343 times)
NinthPower
Level 2
**



View Profile
« on: September 09, 2013, 08:01:00 AM »

Hey all, I have been a 'Lurker' around TigSource (and Venus Patrol) for a little while so I figured it's time to start contributing.

I have been delving into Pygame with Andy Harris' great book "The L Line: Game Programming" (http://tinyurl.com/q777frv). Its probably the best beginner book for anyone who wants to learn Pygame (and even gets you started with Python).

There are great books (like Harris') and videos on general Pygame tutorials, so this won't be that. In short, I'd love to legitimize Pygame as much as possible. It really is a great library and I hope some tricks will help anyone who wants to make a game in Python/Pygame useful and hey! even FUN!? Tongue

I've set up a YouTube page (http://tinyurl.com/nt4gk6m) where I will start putting up tutorials on important things you'd want in a game (controller input, fading scenes/sprites, etc.), which can be accomplished with Pygame, but that aren't explicit in the documentation or other tutorials. Gomez

Post any useful links and videos you've used with Pygame to do cool things.

LIST OF FUTURE TIPS, TRICKS, and SECRETS:
- Multiple Joysticks/GamePads

- Examples of coding/implementing Particle Effects

- Fade Transistions

- RPG-syle Text Boxes

- Game-save feature

- Using Physics

- Managing Game States

- Screen Shake (added)

- Using Sprite Sheets (added)
« Last Edit: September 16, 2013, 01:36:06 PM by NinthPower » Logged

Intravenous
Level 0
***



View Profile
« Reply #1 on: September 09, 2013, 12:39:14 PM »

Good stuff, I've never even heard of pygame and I suspect the same of most others.

I suppose it's your job now to make us interested Smiley
Logged
NinthPower
Level 2
**



View Profile
« Reply #2 on: September 09, 2013, 12:47:23 PM »

Ya I will try my best to start posting some good stuff I've found/made. School starts up for me soon but I will definitely come back to this often!
Logged

jamesrm9235
TIGBaby
*


View Profile
« Reply #3 on: September 14, 2013, 10:33:19 AM »

I've been waiting for some support for Pygame in this forum  Grin

I've been teaching myself to program in Python since late July after I found Pygame.  It seems like a good library to start off with for someone who hasn't developed a game.  I'm going to follow this thread and check out your channel.  Thanks man.
Logged
NinthPower
Level 2
**



View Profile
« Reply #4 on: September 16, 2013, 03:55:28 PM »

Crossfade Part One is now up   Cheesy (

). I have the second half (going between different backgrounds) ready but YouTube isn't letting me upload it for some reason. I'll get it up soon.

Enjoy!
Logged

NinthPower
Level 2
**



View Profile
« Reply #5 on: September 16, 2013, 04:11:17 PM »

Here is the second half using the CrossFade class from the first video to fade between different sets of backgrounds/sprites. You could easily extrapolate the use of the CrossFade class as a global variable to transfer between different game states/functions.

 Wink Enjoy!:

Logged

NinthPower
Level 2
**



View Profile
« Reply #6 on: November 02, 2013, 10:49:41 AM »

Hey all, school is sucking my will to live (biochemistry major  Tongue ), but I was able to put a new video up.

It covers making games fullscreen, including maintaining resolutions, continuous input from the keyboard, and using transformations:




Next video should be on some game physics with pygame and pymunk!

much love.
Logged

mind_heist
Level 0
*


View Profile
« Reply #7 on: October 02, 2014, 01:14:29 PM »

Interestingly , No one seems to have mentioned http://programarcadegames.com/index.php?lang=en ; Its an amazing resource to learn pygame . Each chapter also has a few 10 minute videos explaining the tutorial code , If you already know enough python and just want to learn pygame ( and basics of Game Programming ) ,I guess you could skip directly to the 14th Chapter ( Introduction to Sprites).
Logged
NinthPower
Level 2
**



View Profile
« Reply #8 on: October 03, 2014, 11:38:54 AM »

That is a great resource. Unfortunately I haven't posted anything in here for awhile (and switched to GameMaker). If anyone ever had any questions I'd definitely be willing to help Smiley
Logged

mind_heist
Level 0
*


View Profile
« Reply #9 on: October 07, 2014, 07:41:53 PM »

Hi 9thPower ,

I checked out your game's trailer & its pretty cool . I suppose you did not use pygame for that project. So I had a couple of questions , for game using pygame -

(1) How do you include music ?

(2) How do you package and give it to some one to play ?

I have extensively used the tutorial mentioned above to write my game so far.

-Thanks
Logged
NinthPower
Level 2
**



View Profile
« Reply #10 on: October 08, 2014, 08:54:52 AM »

I'm pretty sure pygame has an audio library. Something like pygame.music?... ya it's here in the documentation: http://www.pygame.org/docs/ref/music.html.

I never packaged a game, but I think the most-used library is py2exe -> http://www.py2exe.org/.


And yes, I have since moved on to GameMaker from pygame  Tongue After you get real comfortable with python and pygame, jumping to GameMaker and GML is a really natural transition and it's much easier to make games.
Logged

mind_heist
Level 0
*


View Profile
« Reply #11 on: October 16, 2014, 11:56:18 AM »

Thanks a Lot 9th Power. I found these two tutorials apart from the pygame documentation about music.

1.



2. http://programarcadegames.com/index.php?chapter=bitmapped_graphics_and_sound ( section 12.4)

Some files seems to work as expected , but some other music files are very inconsistent. Its either jittery or I can hear echoes , or it sounds like its being scratched on a turntable.. I can hear the same track as two overlapping tracks with the second one lagging by a couple of seconds. Not sure how to fix it yet.
Logged
mind_heist
Level 0
*


View Profile
« Reply #12 on: October 16, 2014, 12:17:59 PM »

Interesting ; its the frequency - I played around with the frequency a lil bit and got closer to the accuracy ( I m using a ripped ogg music file ; as my loop for now).But I m still trying to figure out what the exact frequency is.
Logged
NinthPower
Level 2
**



View Profile
« Reply #13 on: October 16, 2014, 01:13:25 PM »

That's good to hear. I think it works best with with .wav but I can't remember...
Logged

temoo
Level 0
*



View Profile WWW
« Reply #14 on: October 31, 2014, 04:56:10 AM »

Thanks for posting this, they look like some good tutorials. It's good to see pygame getting some love on this forum. I personally find Python a great language for game development. It may run slow, but but as long as you are OK with its limits then it is lovely to code in.

It's interesting that you switched from pygame to GameMaker. I went the other way, as I found GameMaker too restrictive. I was always fighting against the language (maybe because I wasn't making a platformer).

The main problem I've had with pygame however is sound. My sounds always played with a small delay, and I ended up using winsound instead (a very messy workaround).
Logged
NinthPower
Level 2
**



View Profile
« Reply #15 on: October 31, 2014, 05:31:44 AM »

GameMaker has allowed me to do more in less time. I wonder what it was you were getting hung up on...

You are right about sound. The pygame libraries aren't great. I will say that using pygame with pymunk was a lot more satisfying than GameMaker and Box2d.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic