• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Eamonn Dev Rea

PyGame, Cocos2d or PyGlet?

5 posts in this topic

Yes, I switch from language to language, but I want to learn a lot of languages. This isn't a bad thing, is it? I think it keeps me interested in programming(and has done for the past 3 and a half years!). Not that programming is boring, but I think you know what I mean :)

 

Anyway, the reason I've made this thread is because I want to know what Python library to use, explain to you what my issues are with them all and hopefully you can help me make the right choice.

 

Actually, before I say what my problems are, don't just get angry and say "LOL N00B! Use C++! Python is for N00BZ!", because that isn't true(first of all), and a few awesome programs that I've seen have been made in Python. And there's PyWeek, and I know there's a pure Python 3D MMO that's like $20 or something. That says something! I believe Python is a great language, simplistic and really good to use for game programming. I know CoderDojo, and I go there. They teach GameMaker, AppInventor and HTML/CSS/JavaScript. I already know how to use these(and I am against stuff like GameMaker, Scratch, AppInventor etc because I don't think it's right to use it. You should code a game, not have software do 80% if the work. This is just my opinion though and maybe you feel the same) and know Python. They are planning on teaching C/C++/Ruby soon, but that's beside the point. They have Raspberry Pi's to teach Python, and the Pi's come built in with PyGame. So they teach kids to code in Python. Point: Python is great for kids, and PyGame seems good. Now that that's out of the way, on to the point!

 

 

 

PyGame

 

PyGame is probably the most popular 2D game development for Python. If you google Python Game Development, PyGame is the first result(as of my posting this). It's one of my favourite game libraries for any language, but it's not my favourite Python game library. Here are the pro's and con's:

 

Pros:

• Simple to use

• Powerful

• Support for PyOpenGL

• Based on the very powerful SDL library for C/C++

• Designed for game development

 

Cons:

• Based on SDL, which is a C/C++ library so it doesn't feel as "Python"-e as Pyglet

• Not many guides

• The docs are alright

• Doesn't have support for loading TMX(Tiled) maps

• Designed for 2D games(but does offer support for 3D if needed)

 

My problems:

• Can't figure out how to have smooth player movement(1)

• Can't figure out how to have delta time(2)

• Can't figure out how to check if a key is held down(3)

 

 

Problem 1:

I cant figure out how to have smooth player movement and how to tell if a key is held down! Maybe I've been spoiled with LÖVE, but when I check for a key press and add 10 to the players X position, it jumps 10 pixels and doesn't transition there.

 

Problem 2:

I can't figure out how to have delta time in my game! Does PyGame handle this? Can I store it in a variable called DT or does PyGame do this for me?

 

Problem 3:

I can't find out how to check if a key is being held down. Event name or something?

 

 

 

 

 

Cocos2d

 

Cocos2d is one of the few Python Game libraries, other then for PyGame. It's based on PyGlet, which is my personal favourite Python Library in general. It's designed for games, but there are a few problems and a few upsides:

 

Pros:

• Supports TMX maps

• More "Python"ish

• Designed for game development

• Powerful

• Based on PyGlet

• Active(Updated less then a year ago)

• Has support for smooth player movement( Cocos.Sprite.Transition method )

 

Cons:

• The docs are SO BAD.

• Lack of guides

• Confusing(Uses Nodes, which make no sense to me!!!), probably due to lack of tutorials or guides in general

• Locked to 2D games(unlike PyGlet and PyGame)

 

My Problems:

• Cannot find an understandable guide(1)

• Cannot find Delta Time(2)

 

Questions:

• Can I use PyGlet alongside it?

 

 

Problem 1:

Cocos2d is a fabulous framework... from examples I've looked at and from what I've heard people say. The fact that it has smooth player movement overjoys me. The problem I'm having is finding a good tutorial. Even a book would be awesome at this point(and I hate reading books to learn programming, but when I have to I have to :P )! I think I saw a paid tutorial for like $35 somewhere, but I wouldn't pay to learn it, I'd rather learn C++ and use that with SDL or something!

 

Problem 2:

Delta time is something I can't seem to find in any of these libraries!

 

 

Question 1:

Knowing that Cocos2d is built on PyGlet, that made me question whether or not it's possible to use Cocos2d along with it.

 

 

 

 

 

PyGlet

 

PyGlet is by far my favourite library for Python... even if it wasn't designed for games, I saw someone make a simple Minecraft clone is PygGlet. It was pretty inspiring in my opinion! Despite it being my favourite, I still have a few things to say about it:

 

Pros:

• Simple to use

• Powerful

• Has support for 3D(Possibly using PyOpenGL, but I'm not sure. I know it uses OpenGL either way)

• Very good tutorials & Reference guides -- In fact it's the best that I've seen!

• Good for any type of application

• Very "Python"ish

 

Cons:

• Not designed for game development

 

My Problems

• Cannot figure out how to use Delta Time(1)

• Cannot figure out how to use smooth player movement(2)

 

 

Problem 1:

I assume since I'm having this problem will every library I've mentioned that the libraries handle it for me.

 

Problem 2:

Smooth player movement still remains a mystery! I can check if a key is held down, but (as like in PyGame) the player jumps there and doesn't transition there.

 

 

 

 

 

I know, a long topic, but hopefully I provided all the information needed for you to give me an informative answer. I've been told I don't give enough information, so maybe this is enough!

 

So yeah! Thanks! Any help is appreciated!!

1

Share this post


Link to post
Share on other sites

Thanks! I'll look into both of them! I looked into them briefly and I'm sure they'll be a big help! Thank you! :)

0

Share this post


Link to post
Share on other sites

Thanks for the post -Pyglet is also my firm favourite here. Unfortunately its been very quiet since its last 2012 release.

 

As for your pros/cons another point might be python 3 support. Pyglet's last release began the process but its still an early alpha -Im not sure about pygame.

1

Share this post


Link to post
Share on other sites

Problem 1: others have answered this - most systems won't handle transitions automatically. You have to change the value yourself over time, or find someone else's code to do it for you.

 

Problem 2: you can calculate delta time yourself by calling pygame.time.get_ticks each frame. Cache the value of the previous call and check the difference each time. In pyglet, you choose how often you want an update function to get called, which means you will know the delta time value in advance. Here's the way to schedule an update - http://www.pyglet.org/doc/programming_guide/calling_functions_periodically.html

 

Problem 3: in Pygame, it's http://www.pygame.org/docs/ref/key.html#pygame.key.get_pressed and in pyglet it's http://www.pyglet.org/doc/programming_guide/keyboard_events.html#remembering-key-state

2

Share this post


Link to post
Share on other sites

On your third problem you are probably having trouble with the pressed/down concept.

 

Most frameworks will give you two different functions to access the keyboard:

 

1) Button pressed: this will be set ONCE when the key is pressed and will only be set again when the user releases the key and presses it again.

2) Button is down: this will be set from the time the button press a key untill the moment it releases it.

 

If you are using the first implementation type, you probably need to set some value telling you that the key is pressed and check this value every frame, you also will need to find a function that tells you when the button is released.

 

If you check the pygame documentation (which I found really good to be honest), you will find several examples of implementations with they keyboard interface (they use the 2nd method I described above). Here is a link for the examples:

http://nullege.com/codes/search?cq=pygame.key.get_pressed

 

And here is a link for the full documentation:

http://www.pygame.org/docs/ref/key.html

 

On the time, use the Clock object, call the get_time() to get the dt and call the tick() at the end of your loop to update it

Link for the clock documentation:

http://www.pygame.org/docs/ref/time.html

Edited by KnolanCross
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0