Re: [Tutor] Game lag

2012-01-05 Thread Nate Lastname
Thanks for the profilers - never had hear of 'em. Also, no, I cannot strip
out unnecessary parts, 'cuz I don't know what part is slowing it down.
 Thanks a lot, though Hugo.

On Thu, Jan 5, 2012 at 11:02 AM, Hugo Arts  wrote:

> On Thu, Jan 5, 2012 at 3:56 PM, Nate Lastname  wrote:
> > Hello all,
> >
> > The attached zip file contains a file called 'cameramovement.py'.  As you
> > can see, this file is extremely laggy.  After searching through my code,
> I
> > can't find anything that is slowing it down.  Could someone help me out?
>  It
> > takes a while to load due to a large map.  This is not the problem.
> >
> > Thanks,
> > The Defenestrator
> >
> > P.S. Yes, I am new here.  Hello, all!
> >
>
> 1) although posting here is a good idea, you're gonna be better off
> asking the pygame mailing list about this as well, they're the experts
> 2) that's a lot of code for me to read all in my spare time man, isn't
> there any way you can simplify it or strip out unnecessary parts?
> 3) did you profile it? Do this! Now! rather than guess where your code
> is slow, this will tell you exactly. Use cProfile:
>
> http://docs.python.org/library/profile.html
>
> HTH,
> Hugo
>



-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Delay Between iterations

2012-01-12 Thread Nate Lastname
Hello ANKUR,

Just add a timer variable to the plane class.  Every time it is
updated, subtract time from the timer.  When it hits 0, the bullet can
be fired.  Else, it cannot.  When the bullet is fired, reset the timer
to a delay value.  It's that simple :)

Cheers,
Nathanael Lastname.

-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Installing Modules

2012-01-18 Thread Nate Lastname
Have you looked at help(sys)?  sys stores the PYTHONPATH variable.  Just run
>>> import sys
>>> help(sys)
at the python prompt.

On 1/18/12, Downey, Patrick  wrote:
> Hello,
>
> I'll start by saying that I have a math/stats background, not a computer
> science one. I've found lots of great material to help with Python
> programming, but have had a much harder time getting my head around setup
> issues, like installing modules.
>
> I'm currently running Python version 2.7 through IDLE on a Windows machine.
> I'm trying to use numpy and scipy. I downloaded both modules from the scipy
> website and unzipped the files into:
> C:\Python27\Lib\site-packages
>
> I try to load them using this at the beginning of my program.
> from numpy import *
> from scipy import *
>
> And I get this error:
> Traceback (most recent call last):
>   File "D:/Documents and Settings/pdowney/My Documents/Actual
> Projects/Foreclosures/Python/Program (1-18-12).py", line 3, in 
> from scipy import *
> ImportError: No module named scipy
>
> Numpy loads just fine. Both are in the same folder. That is, there's a file
> called setup.py in the folder:
> C:\Python27\Lib\site-packages\numpy
>
> And also in the folder:
> C:\Python27\Lib\site-packages\scipy
>
> I don't understand what is being done differently between the two packages.
> According to Chapter 6 of the Python documentation, "When a module named
> spam is imported, the interpreter searches for a file named spam.py in the
> directory containing the input script and then in the list of directories
> specified by the environment variable PYTHONPATH." Unfortunately, I haven't
> figured out how to look at PYTHONPATH, so I don't know where it's looking.
 print PYTHONPATH
> Traceback (most recent call last):
>   File "", line 1, in 
> print PYTHONPATH
> NameError: name 'PYTHONPATH' is not defined
>
> Importantly, there is no file scipy.py in the scipy folder, as the
> documentation suggests there should be, but there's also no numpy.py in the
> numpy folder and that module loads successfully. Clearly I'm missing
> something in the setup of these modules. Any guidance would be greatly
> appreciated.
>
> Thank you,
> Mitch
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Issue with a shapefile (ArcGIS) library (pyshp) "unpack requires a string argument of length 8"

2012-02-03 Thread Nate Lastname
On Fri, Feb 3, 2012 at 10:46 AM, Simeon Tesfaye <
simeon.tesf...@eaudeparis.fr> wrote:

>  Hello everyone,
>
> I am having a bit of trouble here with my code, which uses a shapefile
> library, named pyshp, to import, edit, and save GIS files within Python.
> So, I open up my shapefile (data is polylines, meaning, not points or
> polygons)
> "shapefile=shapefile.Reader("file.shp")
> shps=shapefile.shapes()
> shprec = shapefile.records()
> "
> Then I carry out some edits, and I save my file.
> When I want to open it again, within the same script, in order to access
> some of the data I just modified, I get this message :
>
> "Traceback (most recent call last):
>   File "", line 1, in 
> troncop=troncon.shapes()
>   File "C:\Python25\Lib\shapefile.py", line 310, in shapes
> while shp.tell() < self.shpLength:
>   File "C:\Python25\Lib\shapefile.py", line 222, in __shape
> print(f.read(8))
>   File "C:\Python25\lib\struct.py", line 87, in unpack
> return o.unpack(s)
> error: unpack requires a string argument of length 8"
>
>
> I reckon this part tries to import header information for shape data,
> which would be stored in C (?), and fails to "unpack" it in PYTHON.
>
> I've tried putting an "IF" to check whether f.read(8) was actually a
> string (type) and of length equal to 8. I still get the same error message.
> I've also tried skipping the "unpack" part altogther, not with much
> success.
>
> I'm really not too familiar with Python, si if anyone could help me out
> with this, I'd be really grateful.
>
> Thanks in advance,
>
> S.T.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
All that this error means is that you have an array longer than the number
of values that you are assigning to it.
I.E:
array = [1, 2, 3]
a, b = array
This causes an error since there are too many values in the array.  To fix
this, just change the second line to:
a, b = array[:2]
in my example.

-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-05 Thread Nate Lastname
>
> More details:  I want it to be something similar to this: powdertoy.co.uk.
>  It will have different elements, though.
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Sandbox Game

2012-02-05 Thread Nate Lastname
Hey List,

I am thinking about making a sandbox game.  Where should I start?  Has
anyone done this before?  I'm having trouble in MANY places, and I couldn't
find any similar projects with a Google search.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-05 Thread Nate Lastname
Hello Robert,

I appreciate the reply, but I have two things to say:
1. Your nastiness is not appreciated or really needed.
2. If you look at the results, none of them actually give relavant info.  I
DID do research before I asked here, extensively, and found nothing.

Thanks,
The Defenestrator.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hello List,

I am quite sorry for my attitude.  I will look more thoroughly into the
search results.  Thanks for the link to Epik.  I had found this, but I
didn't realize that it was Python.  I apologize once again, and thank you
for your help.  I did give you a link to a sandbox game (powdertoy.co.uk)
as an example of what I wanted, but that must not have been delivered
properly.

My Apologies,
The Defenestrator
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
P.S.:  I also would like to say that I am a noob at Python, Pygame, and the
list.  I'll try not to post more stupid questions, though.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hey all,

The basic idea is that there are different types of sand.  They fall
and move (or don't, if they are solid) and interact with each other in
different ways.  I.E.; there is a lava type;  it falls, and when it
hits other sand types, it heats them up.  If it gets cold, it becomes
sand.

I don't want to copy the game, I want to make my own to play around
with Py(thon/game).  Thanks for your help!

-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] exercise with classes

2012-02-06 Thread Nate Lastname
Hey Tonu,

The problem is that in your statement definition, you are not
including the self argument.  Your definition needs to be something
like:
def dolt(self):
   # Do stuff.
For more info on the self keyword, see
http://docs.python.org/tutorial/classes.html, section 9.3.2.

On 2/6/12, Tonu Mikk  wrote:
> Alan, thanks for explaining about passing objects to classes.  This is an
> important concept for me to understand.
>
> I tried running the code, but run into an error that I could not resolve:
>
> TypeError: doIt() takes no arguments (1 given).
>
> Tonu
>
> On Thu, Feb 2, 2012 at 7:09 PM, Alan Gauld wrote:
>
>> On 02/02/12 17:36, Tonu Mikk wrote:
>>
>>  So far I have searched for info on how to pass variables from one class
>>> to another and have been able to create a small two class program
>>> (attached).   But I seem unable to generalize from here and apply this
>>> to the game exercise.  What would you suggest for me to try next?
>>>
>>
>> Remember that OOP is about creating objects from classes.
>> You can pass an object to another rather than just the
>> variables, in fact its preferable!
>>
>> Also remember that you can create many objects from one class.
>> So just because you have one Room class doesn't mean you are
>> stuck with one room object. You can have many and each can
>> be connected to another.
>>
>> You can get rooms to describe themselves, you can enter a room.
>> You might even be able to create new rooms or destroy existing ones. These
>> actions can all be methods of your Room class.
>>
>> Here is an example somewhat like yours that passes objects:
>>
>> class Printer:
>>   def __init__(self,number=0):
>>  self.value = number
>>   def sayIt(self):
>>  print self.value
>>
>> class MyApp:
>>   def __init__(self, aPrinter = None):
>>   if aPrinter == None: # if no object passed create one
>>  aPrinter = Printer()
>>   self.obj = aPrinter  # assign object
>>   def doIt()
>>   self.obj.sayIt() # use object
>>
>> def test()
>>   p = Printer(42)
>>   a1  MyApp()
>>   a2 = MyApp(p)   # pass p object into a2
>>   a1.doIt()   # prints default value = 0
>>   a2.doIt()   # prints 42, the value of p
>>
>> test()
>>
>> HTH,
>>
>> --
>> Alan G
>> Author of the Learn to Program web site
>> http://www.alan-g.me.uk/
>>
>>
>> __**_
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor
>>
>
>
>
> --
> Tonu Mikk
> Disability Services, Office for Equity and Diversity
> 612 625-3307
> tm...@umn.edu
>


-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Some more info:

It's in pygame.
It's 2d.
I cannot find any python versions out there.  Yes, there is a
graphical interface, and yes, it is a user-controlled game.
Thank you all for your help!

The Defenestrator

On 2/6/12, bob gailer  wrote:
> On 2/6/2012 11:16 AM, Nate Lastname wrote:
>> Hey all,
>>
>> The basic idea is that there are different types of sand.  They fall
>> and move (or don't, if they are solid) and interact with each other in
>> different ways.  I.E.; there is a lava type;  it falls, and when it
>> hits other sand types, it heats them up.  If it gets cold, it becomes
>> sand.
> Thanks for a top-level overview. I have no practical experience with
> game /programming /, just some general concepts which I offer here, and
> leave it to others to assist.
>
> You might add more specifics - do you want a graphics display? User
> interaction? Anything you add to your description helps us and helps you
> move to your goal.
>
> I suggest you start simple, get something working then add another feature.
>
> Simple? Could be as simple as 1 grain falling till it hits bottom. Does
> it have an initial velocity? Does it accelerate under the pull of
> gravity? Velocity means speed and direction. What happens when it hits
> bottom?
>
> Then add a 2nd grain. What happens if the 2 collide?
>
> What is your update rate (how often do you recompute the positions of
> all the grains)? What is the smallest increment of position change?
>
> I assume you will create a class for each type of sand grain. with
> relevant properties and methods.
>
> You will need a program that runs in a loop (probably with a sleep) to
> -  update positions and  velocities of each grain (by invoking class
> methods)
> -  detect and manage collisions
> -  display each grain (by invoking class methods)
>
> If you are using a graphics package I assume you will have a "canvas" on
> which you will draw some kind of object to represent a particular class
> of grain at the current x,y(,z?) coordinates of each grain.
>
> It is possible to change the base class of an object on-the-fly, so a
> lava drop could become a sand grain.
>
> That's all for now. Good coding!
>
> I don't want to copy the game
>
> Is there a Python version out there?
>> , I want to make my own to play around with Py(thon/game).
>>
>
>
> --
> Bob Gailer
> 919-636-4239
> Chapel Hill NC
>
>


-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Hold on... I just found one!  It's not ideal, but it will work at
least for a base -
http://www.pygame.org/project-pysand-1387-2577.html.  Thanks again,
all, for your excellent help!

The Defenestrator

On 2/6/12, Nate Lastname  wrote:
> Some more info:
>
> It's in pygame.
> It's 2d.
> I cannot find any python versions out there.  Yes, there is a
> graphical interface, and yes, it is a user-controlled game.
> Thank you all for your help!
>
> The Defenestrator
>
> On 2/6/12, bob gailer  wrote:
>> On 2/6/2012 11:16 AM, Nate Lastname wrote:
>>> Hey all,
>>>
>>> The basic idea is that there are different types of sand.  They fall
>>> and move (or don't, if they are solid) and interact with each other in
>>> different ways.  I.E.; there is a lava type;  it falls, and when it
>>> hits other sand types, it heats them up.  If it gets cold, it becomes
>>> sand.
>> Thanks for a top-level overview. I have no practical experience with
>> game /programming /, just some general concepts which I offer here, and
>> leave it to others to assist.
>>
>> You might add more specifics - do you want a graphics display? User
>> interaction? Anything you add to your description helps us and helps you
>> move to your goal.
>>
>> I suggest you start simple, get something working then add another
>> feature.
>>
>> Simple? Could be as simple as 1 grain falling till it hits bottom. Does
>> it have an initial velocity? Does it accelerate under the pull of
>> gravity? Velocity means speed and direction. What happens when it hits
>> bottom?
>>
>> Then add a 2nd grain. What happens if the 2 collide?
>>
>> What is your update rate (how often do you recompute the positions of
>> all the grains)? What is the smallest increment of position change?
>>
>> I assume you will create a class for each type of sand grain. with
>> relevant properties and methods.
>>
>> You will need a program that runs in a loop (probably with a sleep) to
>> -  update positions and  velocities of each grain (by invoking class
>> methods)
>> -  detect and manage collisions
>> -  display each grain (by invoking class methods)
>>
>> If you are using a graphics package I assume you will have a "canvas" on
>> which you will draw some kind of object to represent a particular class
>> of grain at the current x,y(,z?) coordinates of each grain.
>>
>> It is possible to change the base class of an object on-the-fly, so a
>> lava drop could become a sand grain.
>>
>> That's all for now. Good coding!
>>
>> I don't want to copy the game
>>
>> Is there a Python version out there?
>>> , I want to make my own to play around with Py(thon/game).
>>>
>>
>>
>> --
>> Bob Gailer
>> 919-636-4239
>> Chapel Hill NC
>>
>>
>
>
> --
> My Blog - Defenestration Coding
>
> http://defenestrationcoding.wordpress.com/
>


-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sandbox Game

2012-02-06 Thread Nate Lastname
Thanks, Greg.  I actually have two projects on the pygame website, and
I already have a great book, too.  But thank you very much :D

-- 
My Blog - Defenestration Coding

http://defenestrationcoding.wordpress.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question on how to do exponents

2012-02-06 Thread Nate Lastname
Exponents and remainder (modulus) are **(or ^) and % respectively.  I.E.;
d = a ** b (exponent)
c = a % b (modulus)

There you are!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] two-dimensional color map

2012-02-09 Thread Nate Lastname
Have you considered pygame and its surfarray module?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor