 |
|
 |
Hi,
I am making a game, where I want to move the character with mouse click. It is a tile based game with isometric view.
# mouse move
if e.type==pygame.MOUSEBUTTONDOWN:
#movehero
movehero=True
if e.type==pygame.MOUSEBUTTONUP:
movehero=False
if movehero==True:
# the movement code
Can anyone tell me how to get the position of mouse click so that the character will move there itself?
Kindly help
Thanks
|
|
|
|
 |
|
|
 |
|
 |
Any Python Gurus online?
If so please help me with the following error. I am the middle of writing a program and every time it runs the Python core crashes. After debugging and stepping through code the following block of code precedes the crash:
x = 16
while x > 0
x = x * x
Whats the error?
lol.......
|
|
|
|
 |
|
 |
Mike Stratton wrote: x = 16
while x > 0
x = x * x
Have you looked carefully at these statements?
|
|
|
|
 |
|
 |
The answer is simple really, I actually purposely created this code while learning python via MIT OpenCourseWare.
This code creates an infinte loop with the number calculations increasing beyond Pythons capabilities very quickly.
I thought it was kind of funny as the code says:
x is equal to 16
If you find that x is greater then 0 then do the following:
redefine x as is equal to 16*16
Second loop:
x is equal to 256
if you find that x is greater then 0 then do the following
redefine x as equalt to 256*256
Third loop:
x is equal to 65536
if you find that x is greater then 0 then do the following
redefine x as equal to 65536 * 65536
A few loops and python cannot compute.
|
|
|
|
 |
|
 |
x = 16
while x > 0:
x = x * x
You were just missing a :
and statements under a while, or for, or if, etc
must be indented
try it now
Mike
|
|
|
|
 |
|
 |
x = 16
while x > 0 :
x = x * x
Pavan Pareta
|
|
|
|
 |
|
 |
Is this supposed to add some value here?
|
|
|
|
 |
|
 |
The value added is a good laugh.
I am just having fun learning to code.
|
|
|
|
 |
|
 |
And the purpose of posting the question was what?
|
|
|
|
 |
|
 |
post = "function"
while input = 'function?':
print 'That was funny!'
else:
print 'That was Stupid'
|
|
|
|
 |
|
 |
My purpose was to try and find other programmers that share my enthusiasm for learning.
Have a good day.
|
|
|
|
 |
|
 |
This answer is partially correct.
Yes I forget the operative of : when typing this but the real problem is that it creates an infinite loop that causes Pythong to crash.
|
|
|
|
 |
|
 |
If you understand why it crashed, then it was a worthwhile exercise.
Clue: the infinite loop isn't why it crashed. It crashed after just 3 iterations, so there must be something else happening here. (Another clue: think powers of 2)
|
|
|
|
 |
|
 |
I would have to say it is neither the infinite loop, nor the multipication. The reason for the crash is quite clearly evidence of the programmers inability!
|
|
|
|
 |
|
 |
This question was rhetorical, and intended as a joke.
Looks like my humor is about as good as my programming skills and grammor.
----- Just excited to be learning about Python -----
|
|
|
|
 |
|
 |
I for one thank you for the test.
I know c and pascal and... but just learning python. this exercise was vary useful for me and I got several loops (18) before the system bogged down for 1 min and the printout started to mess up.
|
|
|
|
 |
|
 |
How to write a script that uses a control statement (such as FOR loops, WHILE loops, etc...) to print out 50 lines using variables as shown in Figure 1. Note that Line 3 is derived by adding Line 1 & 2. Line 4 is derived by adding Line 2 & 3 and so on…
Line 1 : 1
Line 2 : 1
Line 3 : 2
Line 4 : 3
Line 5 : 5
Line 6 : 8
Line 7 : 13
Line 8 : 21
…
…
Figure1.
Output from executed script
Smaini
|
|
|
|
 |
|
 |
q = [0,1]
for i in range(1,50):
sum = q[0] + q[1]
print 'Line %d : %d' % (i,sum)
if i > 1:
q = [ q[1], sum ]
MBH
|
|
|
|
 |
|
 |
Ok thanks for your suggestion!!
|
|
|
|
 |
|
 |
Hey, i was wondering where i can find some decent python tutorials that i can download in the PDF format???
Your help will be greatly appreciated.
Todd.
|
|
|
|
 |
|
 |
Greetings:
Although you'll end up getting all of the Python documentation, including the language reference and C API, the tutorials over at Python's official site, python.org are still some of the best around: http://docs.python.org/download.html[^]
For practical applications and uses for Python, Mark Pilgrim's Dive Into Python is also a tremendous resource: http://diveintopython.org/#download[^]
I hope this was of help....
|
|
|
|
 |
|
|
 |
|
 |
Is there any module in python for extracting cab files.
|
|
|
|
 |
|
|
 |