SgtMe 46 Veteran Poster Featured Poster

It really depends on what you are doing. Is this game 2D? If so, you will want to use either of the following:

Python with the pyGame library (recommended!)
C++ with the allegro graphics library

I recommend python because the syntax is a lot easier. Also, pygame is a lot easier to understand than Allegro

For 3D games, you're probably best off using C++ or another derivative of C. This is because the main 3D libraries like GLUT, OpenGL and DirectX are almost 'native' to that language. You can use these in python, but it's harder, and you have to have other library wrappers installed. I was choose OpenGL and GLUT over DirectX, as it is a lot simpler.

Hope this helps you!
Mark

PS: Pygame has support for OpenGL bindings when using python, but again, python isn't the main language that OpenGL is used in.

bperiod commented: Well, good post. +1
SgtMe 46 Veteran Poster Featured Poster

may I recommend that, on the design side, you seperate the buttons into blocks...it just looks a bit neater.
Good work so far and good luck!

SgtMe 46 Veteran Poster Featured Poster

you want to open the text file in your python program?
http://lmgtfy.com/?q=Python+File+IO

SgtMe 46 Veteran Poster Featured Poster

have a look at the system calculator...or just any sci-calculator

SgtMe 46 Veteran Poster Featured Poster

M+ is adding display to the memory
MR is recalling the memory. Ie: You do a sum and get the result 6.3322 and you need this for another sum. So, you press M+ to ad 6.3322 to the memory, then you type in the next sum. When you need 6.3322, you press the MR button, which insterts the current value of the memory (6.3322 in this case) into the display.
MC is obviously deleteing the contents of the memory (set to 0?).
I'm not sure about the difference between M+ and MS though...

Try looking at the system calculator...hope this helps!

SgtMe 46 Veteran Poster Featured Poster

I recommend that you place print statements in various places in your code, so that you can find the actual place of the issue. It may not be the function that is not working, it could be one of your if() statements or whatever. Work through your code, so that you can work out if you actually get to the right place in the code.

Hope this makes sense
SgtMe

SgtMe 46 Veteran Poster Featured Poster

I reached the recursion depth thingy near instantly (above code is example!), but I've managed to get round it. Thanks anyway.

PS.
Nice pic vegaseat ;)

SgtMe 46 Veteran Poster Featured Poster

Let's say I have this:

class main:
     def add(self):
          print '1 + 2 = 3'

I then want to be able to call the add function again from within itself. Like this (BUT THIS DOESNT WORK!!!)

class main:
     def add(self):
          print '1 + 2 = 3'
          self.add()

I've tried using other classes all looped round...but that doesnt work either... :(

This should be simple but I have forgotten :(

Thanks
Mark

SgtMe 46 Veteran Poster Featured Poster

haha lol :) ... smartass

SgtMe 46 Veteran Poster Featured Poster

No offence, but you are being slightly stupid :D
There should be no difference in window size in either of your attemps. This is because you are calling

root = Tk()

which is what makes the window.

You can use stuff like this:

root = Tk()
root.title('hello')
root.minsize(100, 100)
root.maxsize(400, 400)
root.geometry("231x326") #Not exactly sure how u do this 1!
root.wm_iconbitmap('icon.ico')
#etc.

That or ur window thingy is messin around wif it...

SgtMe 46 Veteran Poster Featured Poster

No I don't think so...only GNU/Linux :(
Still, Windows is win :D

SgtMe 46 Veteran Poster Featured Poster

Are you using 64-bit Python?
If so, this is likely to be the issue. Unfortunately, you will need to uninstall all the python modules you have and reinstall them on a 32-bit version of Python. Some modules such as Pygame and PyQt4 do not yet have support for 64-bit Python.

I am running 64-bit Windows 7 Home Premium with Python 2.6.4, and since I did this for pyGame, I have had no further issues.

SgtMe 46 Veteran Poster Featured Poster

It's printing you lose because you are trying to use the module 'random' as a variable. Therefore, no statements in your loop for win checking are excepted, apart from, of course, the else statement, which prints 'You lose'.

You need to make a variable for the computers' choice. So this line, for example:

print "You picked", counter, "and the computer picked", random.choice()

Becomes:

#compCount is variable for the computer's turn
compCount == random.choice(['1', '2', '3'])
print "You picked", counter, "and the computer picked" compCount

PS:
Please use code tags, like I have, next time!

SgtMe 46 Veteran Poster Featured Poster

What are you trying to do? What do you need to find out? What does it do? Why should we help you? Why aren't you using code tags? What the hell are you even talking about...

SgtMe 46 Veteran Poster Featured Poster

that has nothing to do with it

SgtMe 46 Veteran Poster Featured Poster

solv-èd

I just changed it to JPEG format and it works lol.

SgtMe 46 Veteran Poster Featured Poster

yes i no. Look at Gribs code. It has line = line.rstrip(). I just cba 2 write out the whole bit in my post

SgtMe 46 Veteran Poster Featured Poster

Nope. In your code, which I copied and pasted in, the line.rstrip("\n") bit was in there already. I use line.strip() but that didn't work...

SgtMe 46 Veteran Poster Featured Poster
FILE DOES NOT EXIST 'icon.png\n'
Traceback (most recent call last):
  File "C:\Users\TN30RY\Documents\Programming\Python\Projects\App Platform\Platform001\src\main.py", line 74, in <module>
    app = appPlat()
  File "C:\Users\TN30RY\Documents\Programming\Python\Projects\App Platform\Platform001\src\main.py", line 15, in __init__
    self.readConfig()
  File "C:\Users\TN30RY\Documents\Programming\Python\Projects\App Platform\Platform001\src\main.py", line 46, in readConfig
    icon = pygame.image.load(line)
pygame.error: Couldn't open icon.png

Wha?
Here is my src folder.

src/
	doc.txt    #Text document
	error.ico 
	icon.png #I have paint.net and PNG is stated as Paint.net image? It still has .png extension
	main.py
	success.ico
	warning.ico

Also, it still has the newline chars on the end (On the FILE NOT EXIST thing).

SgtMe 46 Veteran Poster Featured Poster

Now I have new problem.
With the icon in the text document in the first post, I use the following code:

line = self.confFile.readline()
        if line == '<ICON>\n':
            line = self.confFile.readline()
            line.rstrip("\n")
            icon = pygame.image.load(line)
            pygame.display.set_icon(icon)

Python just says that it can't open icon.png. I have checked the source folder and everything is there. I've tried putting qoutes and double qoutes around the icon path in the text document but none of that works.

SgtMe 46 Veteran Poster Featured Poster

Thank you very much. It works fine now :)

SgtMe 46 Veteran Poster Featured Poster

Hi again.

I want to have a file for one of my python programs, that looks something like this:

<WINDOW> #Window size
640
480
<WINDOW TITLE>
App Platform Test
<ICON>
icon.png

I have a function that reads each line of, and uses the data to make a window. What happens is, if the program reads a line of text from this file (using 'file.readline()'), which is, say, <WINDOW TITLE>, it will read the next line and that will be set as the title.

The problem is with the window size. 'readline()' returns with a newline (\n) thing on the end, and it is also in single qoutes. I can't find a function to remove these so I can use the line as an int.

Please help!
Thanks
Mark

SgtMe 46 Veteran Poster Featured Poster

Whoops.
I got confuzzled about the y value being upside down (?) and the balls y position was going under the bounding box, I the box was in front of the player, not on them!

SgtMe 46 Veteran Poster Featured Poster

Are you allowed to use other modules? If so use pygame. Look at the documentation at pygame.org under key. I'm pretty sure you can set modifier keys.

SgtMe 46 Veteran Poster Featured Poster

New problem.
I am not using the sprite class for my images. I want to create my own collision function.

Here is the code for the ball colliding with each player

if ballx < player5x + 33 and ballx > player5x and bally < player5y + 25 and bally > player5y:
        playerWBall = 5

I use playerWBall as the variable for drawing a different set of images in my draw function. This code does not work. I tried just putting a print command in, but that didn't work. I think my bounding box is wrong.

This is the code for the ball going out. This works:

if ballx < 0 or ballx > 640:
        balloutbounds = 1
        ballx = 320
SgtMe 46 Veteran Poster Featured Poster

Wow. Well, what can I say?
I put in the code for the keypress, thinking that might not register if the key was held, and it works fine. What I wanted was for the ball in my game (see first post) to be passed left/right, but if you held the left/right arrow key, nothing happens.

Thanks very much!!!
Mark

SgtMe 46 Veteran Poster Featured Poster

Okay. Thanks. I wanted to steer away from 'event' but it looks like I'll have too...

SgtMe 46 Veteran Poster Featured Poster

Hi guys!

I am in the process of making a game...similar to this one:
http://www.miniclip.com/games/nfl-lateral-collateral/en/

I am using the following code to detect key presses:

pygame.event.pump()
key = pygame.key.get_pressed()

if key[pygame.K_LEFT]:
     ...

How can I detect if a key is released? I have seen this done with using 'event' instead of 'key.get_pressed()', but I don't want to switch to event because I have had many previous problems with it.

Is there a way to detect if a key is released, or even just not pressed, using the 'key.get_pressed()' method of doing things? If not, then I will switch to event, but it would save me loads of time.

Thanks for your time
Mark

SgtMe 46 Veteran Poster Featured Poster

You may want to do some serious editing. Rename 'top' to 'root' and call the canvas 'canvas' or something like that. I don't know how your trying to create a cascade menu, but it obviously doesn't work. Check out my tutorial:

http://www.youtube.com/watch?v=AxFOIaFYJq4

There is an annotated link to the extension on the video.

SgtMe 46 Veteran Poster Featured Poster

Tkinter. It have you noticed how the notepad buttons look better? That's because of Windows 7, not a new GUI.

SgtMe 46 Veteran Poster Featured Poster

I have some basic Tkinter tutorials on youtube if anyone wants to look.
http://www.youtube.com/pyProgrammer96

SgtMe 46 Veteran Poster Featured Poster

You have two problems:
1. Your code is all over the place
2. Your binding everything to the same window.

1. With your class, you should call root = Tk() inside the __init__ function, this also means that root.mainloop() should go at the end of the __init__ function. Also, I would recommend reordering the code in a more logical order. Because all your functions are in a class, you can ignore the problem of having to declare a function before calling it.

2. You are using two frames, but they are on the same window - root. They will automatically be combined and placed inside the same window. If you want them to be seperate, I suggest having either a second full class (with __init__ function) or a seperate function. Within this, you should call root = Tk() again, to create another window. It may not be exactly what you want, but it'll do for now.

I am making a series of Python and Tkinter tutorials on youtube, including one of the use of classes. Here is my channel:
http://www.youtube.com/pyProgrammer96

I hope this helps. :)

SgtMe 46 Veteran Poster Featured Poster

I use Netbeans. Its great for organising your projects, and it shows you errors as you type. It can do pretty much any language as well, if you download the plugins (python is a plugin!). Just download the base IDE and get the python plugin.

SgtMe 46 Veteran Poster Featured Poster

Just use 32-bit Python then... that's all I'm doing

SgtMe 46 Veteran Poster Featured Poster

Hi.

Note for next time: GIVE MORE INFO!

You were having an error with the top.config() command. This is backed up by the fact that I took the not working code and changed it to this:

from Tkinter import *

root = Tk()

menubar = Menu(root)
frame = Frame()
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New")
filemenu.add_command(label="Open")
filemenu.add_command(label="Save")
filemenu.add_command(label="Save as...")
filemenu.add_command(label="Close")
filemenu.add_separator()
filemenu.add_command(label="Exit", command=frame.quit)
menubar.add_cascade(label="File", menu=filemenu)
root.config(menu=menubar)


root.mainloop()

it worked fine. However, this is not a top level menu.

I've had a look round but I can't see what's wrong. Now we've indentified the problem I hope that somebody can shed some light upon it...

SgtMe 46 Veteran Poster Featured Poster

Well I'm actually doing some tutorials on Youtube ATM, covering lots of stuff in Tkinter. I did a vid on cascade menus but I didn't cover parent to child.

Anyway here is a link to my vids:
http://www.youtube.com/pyProgrammer96

SgtMe 46 Veteran Poster Featured Poster

I disagree. Though there are advantages to using full IDEs such as netbeans, Notepad's simplicity still does it for me. It's free from clutter, and you don't have to fiddle around with settings and installation and whatever. It's there, it works, it's done. Just like using a belt sander to sand down a 1cm by 1cm piece of wood...

SgtMe 46 Veteran Poster Featured Poster

I don't like IDLE. I was using netbeans but it got annoying, cos even if I wanted to test something small before I put it in a program, I had to make a new project. The only advantages of netbeans is that it shows typing errors as you go, and freezes any errors that come up so you don't have to print screen and paste in paint!

SgtMe 46 Veteran Poster Featured Poster

sorry vegaseat, but I use Notepad, NOT NOTEPAD++

Ich bin der MS-Noob

SgtMe 46 Veteran Poster Featured Poster

I always use the tab key. It just looks neater to me...

SgtMe 46 Veteran Poster Featured Poster

For a menu, just make a new function. Have it print out the choices on screen, including a number, and then the option is chosen by inputing a number. You could use the raw_input() function, but this is rather crude, as it throws errors, if it recieves a value that it does not have a statement for.

I suppose you could use an 'else' statement, which then starts the menu again. Try it and come back to me if you need more help.

SgtMe 46 Veteran Poster Featured Poster

ah that's ok.

Thanks for all you've done!
Mark

SgtMe 46 Veteran Poster Featured Poster

Dang...Didn't work...again.
I ran the installer of the CD as admin.
Took ownership of the program folder.
Could take control of folders on CD?:
ERROR: File ownership cannot be applied on insecure file systems; there is no support for ACLs.

Then I ran it.

SgtMe 46 Veteran Poster Featured Poster

OK. Soz I'm not online all the time. I'm like, on and off daniweb all the time.

SgtMe 46 Veteran Poster Featured Poster

no I just took ownership of the already installed folder that was already there. Where can I download it from? I mean the full version not demo?

SgtMe 46 Veteran Poster Featured Poster

i took ownership of installed folder in Programs(x86). Cant do disc tho.

it didn't work. :(

SgtMe 46 Veteran Poster Featured Poster

thanks for doing all this work for me :D

SgtMe 46 Veteran Poster Featured Poster

Oh w8 it's doi...ah no, check that...no its doing the same thing :(

I tried:
putting renamed dll in sysWow64
putting re-other-named dll in windows and running ejay in xp comp
putting renamed dll in Windows
putting re-other-named dll in sysWow64

dang...

SgtMe 46 Veteran Poster Featured Poster

I've already done DEP but ill try frogaspi

SgtMe 46 Veteran Poster Featured Poster

nah soz dude install in XP compatibility didn't work. :(