[Tutor] Fwd: circular movement in pygame
Oscar Benjamin
oscar.j.benjamin at gmail.com
Tue Apr 28 21:00:09 CEST 2015
On 28 April 2015 at 19:37, diliup gabadamudalige <diliupg at gmail.com> wrote:
>
> I thank all those who responded to my question
>
> Here is the code that I had written.
>
> When updating is applied to a surface object the rotation works but when it
> is applied through a class to an object it goes wrong in about 3 rotations.
> As far as I can see the code is the same. What is wrong? If you can correct
> some code and show me would help.
Your code is too long and complicated for me to read through it all.
You should simplify your problem before posting it somewhere like
this. Make a simpler program that does something similar but without
all the pygame stuff. For example your program might just loop through
printing out the positions of the object at different times e.g.:
# game.py
#
# This program simulates a ball moving at constant speed
# in a two dimensional space.
#
# Initial position of ball
xpos = 0
ypos = 0
# Horizontal and vertical speed
xspeed = 1
yspeed = 2
# Timestep
deltat = 0.125
# Run through 10 iterations of simulation
for n in range(10):
# Update state
xpos += xspeed * deltat
ypos += yspeed * deltat
# Output current state
print('Position = (%.3f, %.3f)' % (xpos, ypos))
$ python game.py # Show the output
Position = (0.125, 0.250)
Position = (0.250, 0.500)
Position = (0.375, 0.750)
Position = (0.500, 1.000)
Position = (0.625, 1.250)
Position = (0.750, 1.500)
Position = (0.875, 1.750)
Position = (1.000, 2.000)
Position = (1.125, 2.250)
Position = (1.250, 2.500)
Once you have made a simpler program carefully explain what it is that
you want it to do and show us how what it does is different. Don't
expect people on this list to download your code and run it.
Also please put your code in the email and not in an attachment and
please reply back to the tutor list rather than directly to me.
--
Oscar
More information about the Tutor
mailing list