Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
Hey everyone, I was trying to find a thread that offered help with Python, but I had little luck, so I created one. Today, I'm having difficulty figuring out how some of the variable types work in Python. So far as I can tell, it's (Python) extremely type independent. Specifically, I just throw a name into the code and assign a value. Well, my current trouble is that I want to work with booleans. When coding, I really prefer a basic true/false over working with integers when possible. I know that a simple Google search would probably help me with this, but I wanted to see what kind of responses I would get here. Thanks for the help! Right now, I'm working on a simple Asteroids-style game, and I thought it worth pointing out that I haven't been (entirely) slacking with game development (though I did give a lot of my available time to Final Fantasy XII this last week). ------------------ |
|
Lazarus![]() Member Posts: 1668 From: USA Registered: 06-06-2006 |
If I recall, they added a boolean type in Python 2.3, and the constants True and False. If you do the interpreter returns True, and likewise with bool(0). HTH. |
|
Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
HTH? Thanks for the info. I'm not sure that that helps in my case. Also, I'm fairly new to using the PyGame toolset as well. I'm using something like the following for detecting input (slightly modified from a tutorial I found), but I want to figure out how to respond to key release instead of responding only to key press. for event in pygame.event.get(): I added "up = event.type == KEYUP" with the hope of being able to get something to work, but it seems that "event.key" only works when a key is pressed, and doesn't pay attention to when a key is released. Any advice would be greatly appreciated! EDIT: I had a little bit of insight as to how this system of movement was working, and I've figured it out. I now have a sprite soaring around on screen (like Asteroids), and have included a boost function that gives a fast start and double the speed, but punishes the player with a half a second stall at the end of the boost to keep the player from going right away. The boost is presently unlimited. ------------------ [This message has been edited by Xian_Lee (edited March 23, 2007).] |
|
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
quote: Not sure what you mean.
------------------ "Oh, bother," said the Borg. "We've assimilated Pooh." "Socialism works great... if there are no people involved." -- Pastor David Ginter, Union Church of Guatemala. |
|
Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
That's more or less what I was hinting at. In C++, for example, I would do something like this. (Sorry about not being able to do your fancy code block trick.) // Beginning of app/character class. // Instantiating a character object. // Game loop. Does that make a little more sense? Anyway, I've made a bit of progress in my Asteroid-like. You can read about it in the weekly updates thread and/or my work log on Google (link is in the signature). Thanks for the help. ------------------ [This message has been edited by Xian_Lee (edited March 24, 2007).] |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
How about: isalive = True #the T in True is caps in Python while isalive: #or while isalive == True is that what you ment? and for the input thing you could do: if event.key == K_UP: note: the *s are represent spaces or one tab ------------------ [This message has been edited by evdude (edited March 25, 2007).] |
|
Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
Awesome. Thanks for that. "True" and "False" are the keywords used for boolean? I'm just so used to everything being lowercase, so I didn't think to try that. Thanks! ------------------ |
|
buddboy![]() Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
yeah you can also do TRUE and FALSE I think. don't remember. shout at me if I'm wrong, CPU. ------------------ |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
Ha Ha! Wrong!!
------------------ |
|
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
quote: Me and Python are shouting at you ![]()
------------------ "Oh, bother," said the Borg. "We've assimilated Pooh." "Socialism works great... if there are no people involved." -- Pastor David Ginter, Union Church of Guatemala. |
|
Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
I'm confused now. I should probably just go test these things for myself, but are True and False (with that capitalization) legitimate boolean values? I knew that true and false (written as such) are not, and, as CPU has just pointed out, TRUE and FALSE are not either. Anyway, I didn't mean for this thread to be a "help me" thread, but a "come here for help" thread. As such, I wanted anybody to be able to come in and ask for help should they get hung up in Python. ------------------ |
|
Lazarus![]() Member Posts: 1668 From: USA Registered: 06-06-2006 |
True and False(as spelled that way) are the constants. It only takes three seconds to check out in the python interpreter. ![]() |
|
buddboy![]() Member Posts: 2220 From: New Albany, Indiana, U.S. Registered: 10-08-2004 |
well in my defense I did ask you to tell me if I was wrong, so I was anticipating my wrongness. haha. hey XL that asteroids thing looks cool. you mentioned a tutorial. what tutorial is it? I've been looking for a good Pygame tutorial. ------------------ |
|
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
quote: To settle any doubts, go to: http://www.python.org/doc/2.4.2/lib/node31.html and http://www.python.org/doc/2.4.2/lib/types.html
quote: These tutorials really helped me: http://rene.f0o.com/mywiki/PythonGameProgramming http://www.pygame.org/docs/tut/newbieguide.html Awaretek also has over 300 links to various Python tutorials: www.awaretek.com/tutorials.html covering everything from console programming, gui programming, web programming, to multimedia stuff. ------------------ "Oh, bother," said the Borg. "We've assimilated Pooh." "Socialism works great... if there are no people involved." -- Pastor David Ginter, Union Church of Guatemala. My Programming and Hacker/Geek related Blog [This message has been edited by CPUFreak91 (edited March 26, 2007).] |
|
Xian_Lee![]() Member Posts: 345 From: Registered: 03-15-2006 |
Hey Buddboy, The tutorial I was referring to was written by Richard Jones. It was one of the first links on the Tutorials section of the PyGame website. The title of the tutorial is Rapid Game Development. You can get it here: http://richard.cgpublisher.com/product/pub.84/prod.11 I should stop feigning ignorant. ------------------ |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
quote: All Right! does any one here know of a good 3D module for Python? ------------------ [This message has been edited by evdude (edited March 26, 2007).] |
|
HanClinto![]() Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
PyOgre has an installer, as does Panda3d. Steveth45 will be working on a binding for Irrlicht, and he actually just posted about it over in the weekly updates thread. Hope that helps! --clint |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
Thanks! I'm going to try panda3D. I'm going to download it over night, since it's going to take 5+ hour to download ![]() ------------------ [This message has been edited by evdude (edited March 26, 2007).] |
|
D-SIPL![]() Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
I used Panda3D a while ago. It was to prototype an Othello game that used the MiniMax and AlphaBeta algorithms. I think Panda3D was worked on and used by Disney, possibly for an MMORPG too!? don't quote me on that though ![]() ------------------ |
|
HanClinto![]() Administrator Posts: 1828 From: Indiana Registered: 10-11-2004 |
quote: Oops, just quoted you. But at least you can rest assured that you are correct -- Disney put a lot of work into Panda3D as the rendering engine for their first MMORPG called Toontown Online. It's a decently fun game, but it's a bit of a grind at times. They made things much more casual with their second MMORPG, called Virtual Magic Kingdom. |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
![]() yes! finally, a 3D thing that works! thanks hanclinto!
------------------ |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
Aaack! well, panda works fine for our family's computer, but directx stuff doesn't work on my laptop. is there an installer for some openGL thing? ------------------ |
|
Lazarus![]() Member Posts: 1668 From: USA Registered: 06-06-2006 |
Depends on your 3D card - you can download drivers for ati cards and such. | |
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
how? ------------------ |
|
Lazarus![]() Member Posts: 1668 From: USA Registered: 06-06-2006 |
Start here: http://ati.de/support/driver.html | |
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
Hmmm..... That doesnt work, it doesnt have my driver. thanks any way. ------------------ [This message has been edited by evdude (edited April 09, 2007).] |
|
evdude![]() Member Posts: 135 From: Earth Orbit Registered: 03-14-2007 |
Ok, I got panda3D working. Had to change hardware to software in the config file. ------------------ |
|
CPUFreak91![]() Member Posts: 2337 From: Registered: 02-01-2005 |
quote: Nice. I'm trying to get Panda3D to work too, except my problem is a dependency conflict which I will work out soonish. ------------------ "Oh, bother," said the Borg. "We've assimilated Pooh." "Socialism works great... if there are no people involved." -- Pastor David Ginter, Union Church of Guatemala. |
|
D-SIPL![]() Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
It was a pain to get working on Slackware, I did post my solution in the forum. ------------------ |