Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 30 Jun 2009
Offline Last Active Aug 21 2016 11:48 AM

#5130880 Environment for Python?

Posted by on 12 February 2014 - 02:14 PM

Hi cgeo,


If you're using Windows, you can use the IDLE IDE that ships with Python. It's not the most beautiful thing in the world, but it's already there. Just open it up and create a new file with it. You can run it natively in IDLE, so that's a good start.


If you're not on a Windows machine or you don't like IDLE (I wouldn't blame you, really), then you need to create and edit your Python programs in a text editor. I personally prefer SublimeText, but Notepad++ works just as well. Just save your file with a ".py" extension. To run a Python program on Windows, you can either navigate to the file in Windows Explorer and run it - this will open up the command line like you've already seen, or you can (and this is my personal preference) right click on it, "Edit with IDLE" and run it from there. It's not the most elegant solution, but IDLE provides good feedback on errors and won't just close when the program terminates for one reason or another. If you're on a Mac or *NIX, open up a terminal and run "python filename.py" where "filename" is whatever you named your file (prepended by the directory it's not in your current working directory).


I hope this helps!

#5121780 Pygame importing images

Posted by on 06 January 2014 - 06:39 PM

You just need to make sure you know where the root folder of your game is - i.e. make sure you know the structure of the files and folders and they are all contained in a single folder. Say you have "C:\Users\user\Desktop\Game" and the entirety of your game, including the images and code, are in Game. Say your code is in "Game\code" and your image is in "Game\images\Entities", you can load the image with the following:

image = pygame.image.load("..\\images\\Entities\\image.png")

Where the ".." tells the computer to check what directory you're in right now and go up one level - in this case, the computer sees you're in the code directory, goes up to the Game directory, then follows the remaining path. If the image is in a subdirectory of the directory the code is in, just use a single ".". If you need to go up multiple directories, add a "..\\" for each level you need to go up.

That way it doesn't matter where on the computer the entire folder is stored, as long as the files are in the same position relative to one another.

#5115235 Best place to learn C++

Posted by on 07 December 2013 - 05:22 PM

Python's syntax really isn't that different when you get down to it. It's a little more intuitive in my opinion, and it'll be a nice stepping stone for you. It certainly doesn't spoon-feed you, but it's not as finicky as many other languages, so it should help you to get a handle on things without overly aggravating you. Good luck!

#5112290 Modifying an open source game engine for your needs:Where should I start

Posted by on 26 November 2013 - 06:32 PM

I can't really seem to find c++ tutorials or maybe i haven't searched enough


Does this mean you don't know how to program? If so, starting your programming career with modifying the engine to be "really good" is just going to frustrate you.
These engines (including TORQUE 3D) are horribly complex and have taken teams of highly skilled people ages to put together. If you want to make a game using a prebuilt engine, it's probably in your best interest to just use the engine as it is - and even then it's going to take a lot of work.
If you're still looking for C++ tutorials, try www.cplusplus.com. It's not going to tell you how to modify to the source code of any game engines, but if you're just starting out, you're probably months (or more likely years) of full-time study and practice away from understanding enough to make the changes you want.
It's a hard truth, I know, but one you're going to have to live with.

#5110895 Beginner in Programming for games help please

Posted by on 20 November 2013 - 08:01 PM

This gets asked quite a bit. There is no <i>best</i> language. There is a best language for <i>you</i>, but that's not necessarily going to be the same for everyone else. Try picking a language, look up [language name] tutorial on Google, and go from there. If you like that language, go with it. If not, try another one. It might be a good idea to look at why some people like a language, or why it was developed - was it designed to give the programmer intimate control over the system, but it wasn't supposed to be user-friendly? Was it meant to get the most out of expensive programmers while relinquishing control of the system and perhaps wasting memory or processor time? These are some questions you might want to ask yourself when picking a language or moving forward.

A game won't just happen overnight. You're going to have to spend a lot of time on the basics of any language you choose before you get to anything you might consider a game, so you'll just have to stick with it.

Also, there's a difference between enjoying playing games and enjoying making them. Don't get aggravated, discouraged or confused if you don't immediately take to the game development process, it happens. Try to stick with it, ask questions if you get stuck, take a break, come back to it, try a different approach. It's a challenge, but it's not for everyone.


Good luck!

#5108457 Randomly generated circles in pygame.

Posted by on 11 November 2013 - 07:50 AM

The pygame draw function returns a Rect, so blit the Rect onto the screen Surface after the other shape has been blitted.

#5108183 Randomly generated circles in pygame.

Posted by on 09 November 2013 - 08:12 PM

It would probably be a good exercise for you to figure out. Use what FLeBlanc gave you as well as http://docs.python.org/2/library/random.html#random.randint.

#5107435 Need help with pygame images.

Posted by on 06 November 2013 - 08:40 AM

Does the Pygame distribution you're using support .png file formats? Try saving it as a .bmp and open that file. .bmp images are always going to be supported (according to the people maintaining Pygame) but other file formats may not be, or may go in and out of support.

#5107322 Need help with pygame images.

Posted by on 05 November 2013 - 07:19 PM

The \t is a tab character (you can see it in your error message). Be sure to escape your \ characters when using them in strings with \\ or you'll end up with weird errors like that.


An easier way to keep your image files would be to have a standard location for them, hardcode that path in, then just concatenate the strings when you reference a file, so you won't have to worry about remembering to escape those pesky \ characters as often.



IMAGE_PATH = "C:\\User\\Documents\\python images\\"

background = pygame.image.load(IMAGE_PATH + "example.bmp").convert()

#5100576 Illegal Instruction, possible causes?

Posted by on 11 October 2013 - 10:00 AM

Illegal instructions are operating system generated exceptions that (outside of errors caused by bad programming - ie referencing a function pointer to some garbage space in memory) are generally machine-specific. I'm not familiar with OpenGL, but perhaps you have it or your compiler configured for a different machine setup. Are you compiling on your laptop and trying to run on your desktop? Since it happens on your first API call I can only imagine OpenGL is configured to your laptop machine, and it's likely that the compiler is generating a system call that isn't available or isn't the same on your desktop The glEnable()/glDisable() functions probably don't generate the same system call, so they won't cause the exception (assuming this is the real reason). Try re-configuring and recompiling on your desktop.

#4998501 Keyboard Layout

Posted by on 07 November 2012 - 12:07 PM

Since right click is often the 'block' button in a number of action melee I went with this.

Block/Guard = G

Given that is close to the movement keys does that make it a fluid part of combat? combined with the mouse?

I think this could cause some serious complaints. Assuming you've done the standard "move slower while blocking" to help balance out the usefulness of blocking, it will further impede movement by preventing the player from strafing right. I personally always find it aggravating when a game forces me to jump or block using one of my WASD fingers because I can't move in that direction anymore (I guess technically I could, but then I'd just be doing finger-acrobatics, which is not what I want to do when I'm gaming). Since the player will be more likely to hold down the block-command, and more likely to simply tap the secondary action command (even if you have to hold it for zooming while shooting an arrow, you'll probably be stationary anyway), you're probably better off leaving block on the secondary mouse button and putting secondary action on the keyboard.

I agree with the issue on the number of hotkeys. Keeping it at a standard 10 is probably your safest bet. I do, however, like the idea of being able to rotate through setups. Obviously not everyone will use them (and if they don't, so be it), but it's a definite plus for those who would like to.

I hate to kill your creativity, but I think the key layout is the way it is because that's the way that GENERALLY works best (your game may be an exception of course).

#4975793 Snowballing and Turtling

Posted by on 02 September 2012 - 12:48 PM

I'm not sure if this is applicable for your game, but I find that allowing more/better units to be trained or hired (say from a different race or faction) based on increased map control is a really effective way to stop players from turtling without making it an extremely obvious cop-out. It can also help to end games quicker as you start to restrict your opponents' unit selection while increasing yours with any captures.

#4967173 Mouse Look + Drag and Drop UI

Posted by on 07 August 2012 - 04:18 PM

It's been a while since I played it, but Mount and Blade had both the camera and your weapon follow the mouse in an interesting way. I think it may have been dependent on your settings too, but I specifically remember the challenge (the good kind, not the "I can't stand this game mechanic" kind) of balancing where you swung your sword with where you were looking. It doesn't have anything to do with the inventory system/moving items around (that was all menu-based) but perhaps that might give you some ideas.
Otherwise, perhaps you could have the camera sit still while the cursor is within a small area on the screen, but start to move as it leaves that area. I'm not sure exactly how that would look since I've never seen it implemented before and never thought about it until now, but that might remove the "unresponsiveness" that I found very annoying in Wii shooters since it would start to rotate shortly after you moved the cursor, rather than at the edge of the screen. Maybe have the camera rotation speed up as the cursor moves further from the centre, and slow to 0 when it's within x distance from the centre.

#4964169 Google Ai Challenge inspired game|competition

Posted by on 28 July 2012 - 07:30 PM

Provided the game is to remain accessible to non-programmers, there can't be too many different, complex logical "sentences" pre-built into the game, otherwise things might get so complicated that unless you were there at release, the learning curve will become too much for new players.

I think some kind of subset of some widely used languages might be most appropriate here.

Expanding on the idea of being able to build a library, perhaps it should be user specific, starting with basic logic, and allow users to compile those pieces into miniature "programs" or "functions", which can then be saved (perhaps as Mratthew said as icons), and then be further combined and compiled into more complex ones.

Say I'm playing the game, here's a vague representation of what I have in mind:
Action A is something I built using basic logic, I want all robots to do this.
Action B is some new action that I want certain robots to do.
A+B is saved as some new Action C, which I can drag and drop onto robots of my choosing.
So technically I've programmed it, but once I've written the basic code once, I don't have to go back and do it again or make it more complex through typing, I just have to click on the icons and combine them to get the result I want.