• Advertisement
Sign in to follow this  

Python - strange behaviour

This topic is 1928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,
Yesterday I got my homework from my math teacher. We are studing graphs ( f(x) = x^2 for example ) and how to visualize them( yeah I know, easy )
So she gave me the task to write a programm that will print the graph on the screen. I've chosen python because its high lvl language and I do't have exp with it. (I''m using pygame)
I came to the part where I need to grab the mouse coordinates, substract them from the last mouse coords so I can get a vector represention my movement.

elif event.type == MOUSEMOTION:
self.mousepos1 = self.mousepos2
self.mousepos2.x, self.mousepos2.y = event.pos
self.mousemotion.x = self.mousepos2.x - self.mousepos1.x
self.mousemotion.y = self.mousepos2.y - self.mousepos1.y

Sorry for the possibly dumb question but why the hell this prints something like:

[ 614 , 258 ]
[ 625 , 212 ]
[ 0 , 0 ]
[ 0 , 0 ]

NOTE: I was using functions for +, -, * , /, however I put everything here because I have no idea why it is behaving this way(I assumed the functions may be the problem, but it isn't)
EDIT: I'll post the whole code if requiredq just ask - its only 100 lines. I'm using python ver 3.2.2 Edited by Nickie

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement