2014-06-21 23:58:01

hay folks i am interested in this python thing, and to see if it's easy to code. I am needing an NVDA addon to vocaloid, because i can see how difficult is for us to change singer's voices, and well that's why i am interested in python. So it's easy or not? where can i get it? how i can use it? where i can edit .pi files? how to convert them in an executable?

thancs!

if you want to give me more n advanced help, you could add me @ skype.

raton.miguelito.glps.

bye folks! aw and thanks again!

no matter what you do, alwais, ghosts will be there. Demonic spirits waiting for you. Charlie Charlie are you here? suddenly, charlie appears with a knife. He killed me! charlie charlie are you here? tell me if it's yes. Are you gonna persew me or you're leaving me in peaze? oh my gosh charlie is indeed here! he's about to kill me!
:D

2014-06-22 09:34:22

Terminator, well a lot depends on what you are comparing Python too, but coming from a programmers point of view Python is fairly easy compared to the various flavors of the C language such as C, C++, Java, etc. It doesn't have a lot of the symbols and punctuation marks you have in other programming languages, and blocks of code are determined more by the formatting than any special syntactical rules. It doesn't require that you declare your variables before using them which saves time and makes Python much easier to work with in terms of writing code on the fly. So yes I'd say Python is easy to learn and use comparatively speaking.

As for where to get Python the latest python runtimes for your platform can always be found at
http://www.python.org
and at this time there are two different versions. there is the older stable 2.7 release and version 3.3 for newer more up to date development. If you have Mac or Linux usually a basic Python interpreter is already installed.

As far as editing py files any text editor will do. You can use Windows Notepad on Windows, Gedit on Linux, or the default text editor on Mac. Basically, any text editor will work, and it doesn't have to be anything too fancy.

As for compiling Python programs in to Windows *.exe files there are a number of different tools for this purpose. One tool I use is called Pyinstaller which is a script that compiles  py files into pyc files, and then bundles them into an *.exe file for your platform.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-06-23 18:08:56

hay thomas.
how can i get that thingy? the compiler i mean

no matter what you do, alwais, ghosts will be there. Demonic spirits waiting for you. Charlie Charlie are you here? suddenly, charlie appears with a knife. He killed me! charlie charlie are you here? tell me if it's yes. Are you gonna persew me or you're leaving me in peaze? oh my gosh charlie is indeed here! he's about to kill me!
:D

2014-06-23 20:39:06

Terminator, the Pyinstaller script can be found at
http://www.pyinstaller.org
as is documentation on how to modify it to build your Python projects for various platforms, add modules,  etc. Its not a compiler in the traditional sense the way a C++ compiler works, but byte compiles Python files into pyc files and then creates a special executable which is more or less a zipped folder of your pyc files and the Python runtime for redistribution.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-06-26 00:10:25

is there an easy way to just like learn the programming languaje?

no matter what you do, alwais, ghosts will be there. Demonic spirits waiting for you. Charlie Charlie are you here? suddenly, charlie appears with a knife. He killed me! charlie charlie are you here? tell me if it's yes. Are you gonna persew me or you're leaving me in peaze? oh my gosh charlie is indeed here! he's about to kill me!
:D

2014-06-26 03:12:33

Terminator, well, there is lots of free documentation for Python. There is all of the official documentation at
http://docs.python.org
and if you are a Bookshare member they have a few programming books for beginners in daisy format. There is also the book Learn Python the Hard Way which is available on line that is sort of a crash course in Python. It all depends on how much documentation and newbie friendly you want it to be.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-06-26 16:38:17

k thanks Thomas, i will learn with the official documantation. Aw! and, well can i make here a sidescroller?

no matter what you do, alwais, ghosts will be there. Demonic spirits waiting for you. Charlie Charlie are you here? suddenly, charlie appears with a knife. He killed me! charlie charlie are you here? tell me if it's yes. Are you gonna persew me or you're leaving me in peaze? oh my gosh charlie is indeed here! he's about to kill me!
:D

2014-06-27 04:54:43

Terminator, I don't see any reason why you couldn't make a side-scroller in Python. However, you would have to understand a fair amount of the language and a good game API like Pygame or PySDL2 in order to be able to do that though.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-06-28 17:15:02

To be honest I've noticed many pygame games are very unstable and have huge amounts of loading time on startup. I do have to say, though, that games like sound rts or soundmud have a ridiculously stable online gameplay which I've never seen anywhere else besides maybe top speed or other small games.

A fight we cannot lose.
An enemy we cannot defeat.
A destiny we cannot escape.
Follow me on twitter @guilevi2000

2014-06-29 15:09:59

Guilevi, well, honestly that is one of the major drawbacks to using Python for games. Its an interpreted language, and will never get the speed and efficiency of a native executable built using C or C++. If someone wants the simplicity of a language like Python they need to understand that it comes at a cost not having the performance and efficiency as a native language.

Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com

2014-07-13 00:32:23

yah tword, that's why i'm also dealing with BGT

no matter what you do, alwais, ghosts will be there. Demonic spirits waiting for you. Charlie Charlie are you here? suddenly, charlie appears with a knife. He killed me! charlie charlie are you here? tell me if it's yes. Are you gonna persew me or you're leaving me in peaze? oh my gosh charlie is indeed here! he's about to kill me!
:D

2014-07-13 02:02:18 (edited by camlorn 2014-07-13 02:05:08)

Python is fast enough that I seriously considered (and still am, in a way) doing my MMO project in it.  Game load times is not a function of language in this case-I suspect that the Pygame games under discussion are not streaming and load all sounds at game startup, which will slow anyone and anything down.  Do not assume that Python is the bottleneck until you know how to use the profiler and can prove it-and even then, it is more likely the algorithm and not the language.  Should Python prove too slow for a specific algorithm--rare in this day and age--you can use ctypes and implement it in C/C++, whereupon it won't be anymore.  The only reason I may drop it for my MMO project is because I've decided to take the approach of brute forcing the problem, and am suddenly talking about allocating, copying, deallocating, and generally doing stuff with a million objects a second (I don't want to get too technical, but Python is fast enough for this too.  I'm leaving it for lack of frameworks that fit the model I want to work in, because writing and optimizing my own is going to take valuable time).
As for Python's easiness: compared to most other languages I've worked with, Python will get complex things done the quickest in most cases (and the exceptional cases I'm thinking of fall under the category of research into computer science and not everyday apps or games).  The indentation habits it forms make you a more valuable programmer on sighted dev teams, and tbh you'll end up wanting indentation in other languages too (it's much more convenient than scrolling up 20 lines with your screen reader to count the braces).  I don't have specific tutorials to link as it's been literally years since I first learned to program, but there is an unbelievable amount of documentation on getting started with it--I strongly suggest a quick Google search.
If your specific goal is an NVDA add-on, you want to learn Python 2.7.  Python 3 is a rework of the language-it's mostly the same, but it broke backward compatibility and has had the effect of splitting the community; we're only just now seeing a merge.  NVDA itself uses 2.7 and not 3.  It is also worth noting that Python itself is easy, but NVDA add-ons are not: you will need enough skill to read the NVDA source, though you need not be able to actually build it yourself.  NVDA's aAPI for add-ons is literally all of NVDA itself (as opposed to Jaws and WE which give you a predefined subset); there are consequently ways to replace literally everything.  The downside is that the API is all of NVDA, so you have to do a bit of poking about in the source to figure out where what you want to work with is and how it works.

@tward:
Do you have any evidence of Python even approaching the point of being too slow for an Audiogame?  The newer versions of SoundRTS (this was one of those it's the programmer's fault for not knowing the difference between an array and a hash table and not putting the UI on a different thread than the networking) handles literally thousands of units with no problem.  There's a few of us who set up very long-running games--my particular favorite for performance testing the game is getting a large number of mages with summon dragon.  This isn't the first time I've seen you call out Python for slowness, so I figured I'd ask.  My personal opinion is that it could implement literally any Audiogame currently available, with no noticeable degradation of performance.

Edit: if you want to make redistributable packages, which I'd not worry about for a while, you want Py2exe or Cx_freeze.  No one uses Pyinstaller anymore.  Beware, for here there be dragons-python makes this a bit harder than it has to be, so I'd not worry about it for a while.

My Blog
Twitter: @ajhicks1992

2014-07-13 14:25:55

I've made games in Java and Javascript and learned my lesson about lag back when I tried to have IE5 update 80 images a frame. Other than using boatloads of transparent gradients, I don't see speed issues in interpreted languages becoming much of a problem (and for most of those, most of the work can be saved in images and reused, and thus lag disappears).

In BGT, I only ever get lag when I have a ridiculous number of collision checks per frame, and even then I suspect there's some inefficiency in there somewhere I haven't been able to track down. So far I've done nothing sensitive enough that spreading out checks over multiple frames can't help.

Yukionozawa did a speed comparison between HSP and BGT shortly after BGT became freeware. I remember BGT being slightly slower (but winning in a different test I don't remember). I wouldn't really expect a significant speed difference between BGT and Python, is what I'm saying.

(I'll second Camlorn on the indentation thing: I'm still focusing mostly on BGT just because it's easier to continue with what I've been using, but I've had one eye on porting to Python if I get a game strong enough that I can support adding graphics, so I've been using indentation and placing braces etc such that they're easy to clean up programmatically. My number of "unexpected end of file" errors has dropped dramatically.)

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2014-07-13 17:57:10

Modern javascript does audio synthesis and is  just-in-time compiled on some browsers--on a modern browser, doing that shouldn't be a problem.
As for collision detection, yeah.  This is one of those programmer knowledge thing.  The specific optimization that you're looking for is a data structure called a spatial hash, but it's so much easier not to bother and to use ODE or Box2d which implement it plus a bunch of other optimizations and stuff.

My Blog
Twitter: @ajhicks1992

2014-07-13 19:46:38

I was thinking in the general direction of a spatial hash myself after the first huge dose of this (it wasn't a spatial hash exactly because I tried to come up with it on my own). Then I decided that was too inconvenient and settled on the memory inefficient technique of using 3D arrays; the objects are still objects, just stored in each "tile" they overlap. This only works for fixed objects, of course, but 99% of objects are likely to be fixed in most games anyway. This will probably wind up pointless if I try to use Box2D (recreating physics from scratch is just tedious), but for now I think what I'm working on can survive on aproximations.
(But if I pick up Sonic again? Definitely moving to Box2D. I've always suspected the original concept was just a physics simulator on a blue ball, then they turned the ball into a hedgehog.)

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2014-07-13 20:40:03

Well, the thing with the physics simulators is that you don't have to use them as such.  If you so choose, just plug in your shapes and ask if they collide.  If you don't tick it, it doesn't simulate.  This may not be true of Box2d, but it is true of ode and some others.
What you're actually describing is voxels.  In that case, converting the voxels to a trimesh and culling the triangles that form surfaces between voxels can quite possibly be efficient (even more so if you divide it into multiple trimeshes intelligently).  If you are using Ode for collision and simulation, it looks like you have to do this (I haven't tried) because Ode apparently has problems with flush edges.  If you only want to use Ode for collision, make each voxel a 1x1x1 meter geom, and use their spatial hash (you will get multiple contact points when the player is on an edge but, because the simulation isn't being handled by Ode, it's not going to literally explode).  trying to make a sidescroller that is accessible and workable with Box2d being used for *all* simulation is on my to-do list, simply because it would be moving us away from the discrete tile approach.  In addition, it can handle proper simulation of things like bullets; that is, objects that have velocities so high that they move multiple lengths in one tick.  Perhaps even more fun, it can handle ricochet, though using this for gameplay purposes is probably not doable in a side-scroller (it might be in a first-person game, however).  Also, that possibly means wall jumps.
And this thread just went very off topic.

My Blog
Twitter: @ajhicks1992

2014-07-26 15:36:31

SoundRTS is only slow in the loading sounds part and it's not Pygame.
I think that the amount of sounds slows a bit the game to load it in
memory.
One of the things that I don't like in BGT is that you need to create
various data types to do a basic thing.
I like Python but creating the panning system can be a bit harder (myne
is not perfect but at least it is working).

2014-07-26 18:24:37

SoundRTS is pygame. I have the source on my hard drive, now that it's open source.  The code is very unpythonic, so be warned if you decide to dive in: my 30-second glance shows at least 3 Python stylistic and best practice violations.  This sounds like I'm being pedantic, but it's important to follow the best practices and style guide of your language if your language bothers to give you one (google "python pep 8", follow it religiously, you'll thank me later when you suddenly don't have to look up if that's a function and when people aren't laughing at your code.  The only concession I allow is 1 tab instead of 4 spaces, and obviously some of the alignment points are basically impossible for us).
As for sounds, loading sounds into ram at game startup is slow in everything.  Even C++.  Even more so if it's not .wav files--ogg and mp3 can easily take a while, not to mention expanding to twice or three times the size.
And as for pan, if this is something you consider hard, then open source your panning module.  The reason it's easy in BGT and the reason it's somewhat harder in other languages is because people write stuff and keep it to themselves.  Since so many people have trouble with this and you've presumably got one, give it to the community.

My Blog
Twitter: @ajhicks1992

2014-07-26 19:10:39

I ported sound_positioning.bgt to Pygame. I don't know if the copy on this computer is the completed version, but I know that I do have a copy that works pretty much identically to the BGT version.
(Disclaimer: other than mapping BGT's sound ranges to Pygame's, I mostly just formatted Phillip Bennefall's code as Python.)

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2014-07-26 19:51:21

Hello.
In my game I load the sounds when I need it and they are freed from
memory when not used.
I think I'll create a topic to share my panning code because I think someone
can have the same problem of creating a panning system for his game.
Sometimes I think that I don't want to share the code because I don't
know trig and these other math stuff yet but I think when I share others can learn from my code
and I can learn by the others replyes and we can end with some code that
is even better.
About Soundrts' code I like the way they've done it.
Anyway, thanks for giving the Pep 8 information, I'll read it.

2014-07-26 20:52:37

You don't want to throw sounds out unless you have to.  The issues that can cause are complex, but basically boil down to hard disk I/O issues.  If you want to make a cache, which is the right way, you should look at the weakref module, but don't throw them out when done.
Basically what happens is, everything is fine until it gets to a computer with a slower hard drive or less CPU power.  Alternatively, someone tries to make a game that wants to load 10 or 15 sounds at once for *immediate* playback, and the entire thing stalls because the hard drive just can't.
There are 3 solutions to this.
The first is to just load everything at game startup, the beginning of a level, or some other time.  This first option works until you or someone using your code gets too big for ram, which almost never happens.  The key here is that you don't want to duplicate sounds that are already loaded: you have to make info on where the sound is panned separate from the sound itself.  If you don't you're looking at each in-game sound from the same file taking as much ram as the size of the file or more if the file was encoded.
The second option when the first becomes too slow is to load all sounds, but use something like the futures module, or some other multithreaded solution.  In Python, this isn't complex at all so long as they don't need to share state (they don't).  For most games, if they reach this point, it's the third that you actually want and not this one.
The third way is called a cache.  It's like your browser cache in most respects, if you're familiar with that.  Supposing that you're not handing out sound objects and are referring to sounds by file, the idea is that you load 20 or 30 or 50 and then stop.  Pick a number, any number.  When the user of the library requests a sound that isn't loaded and the cache is as full as you allow, you kill one of the loaded ones and bring in the new one.  My preferred strategy for this if I had to give one would be least used gets dropped; other options include least recently used, smallest, largest, etc.  One of the things you can do is make cache size based on how much RAM it's using: for a given sampling rate, it's the size of the sample format (2 for 16-bit or 4 for 32-bit) times the sampling rate times the total time of audio in the cache.
But where this last one really shines is this.  If sounds are objects and not just one-off events (you want to support this because then you can move it without stopping it playing, among other things), then you can take advantage of the language.  Each sound object containing panning info and etc, points at a sound data object.  You can keep these data objects in a dict by file name and, when a new sound is requested, look it up there.  The magic is that there is a type of dict in python called the WeakValueDictionary.  When nothing else in the program is using the sound data object, it will automatically be removed from the dict.  This means that, if the lookup fails, you just load and add a new one.  No special code is needed for removal, and the game coder using the library is responsible for, say, not loading 500 hours of audio into ram at once.
But sharing the files behind the scenes and not constantly reloading the files are both very, very important musts.

My Blog
Twitter: @ajhicks1992

2014-07-26 21:33:24

Hello.
I've reread some posts and I think that my english caused a bit of
misunderstanding.
In the previous post I meant that Pygame is  not responsible for the slow
down in the sound loading process.
I tried to say that, but i forgot some words and it meant that
SoundRTS was not using Pygame.
About the sound loading, I'm thinking to load all the sounds at startup
and use a dict to refer to the loaded sounds.
But I have a question now: SDL_mixer will make duplicate memory for the sounds, or
it only stores pointers for the sounds and use less memory, and
make the changes to the sound as necessary in the channels?

2014-07-26 21:54:00

I'm not sure, as my familiarity with sdl_mixer is lacking.  You may end up needing to create a duplicate when you actually want to play it, which is okay.  The thing that you want to avoid is reloading sounds that are already loaded; if a copy is needed for playback, you can probably live with it.
The sdl_mixer that I'm thinking of is a C-only thing.  If you mean Pygame, it separates them, as I recall.  That is, channels are responsible for "playing" and sound objects hold the actual data.  the disadvantage with Pygame is that you'll have to work out a channel reuse strategy--the built-in ones are sufficient only for very basic things.

My Blog
Twitter: @ajhicks1992

2014-08-21 16:13:01

hay thomas.
how can i get that thingy? the compiler i mean

2014-08-22 03:05:08

pyinstaller is awesome! For quick testing of a game, nothing can beat typing:
pyinstaller scripts/scriptname.py
and getting an exe in 30 seconds.
py2exe you need to make a file that has all the info for what you wish the game folders to look like and whatnot. I would use py2exe for a full distribute and pyinstaller for testing.
It is pretty easy to hit some lag time in python, "load a 300 or 400 module package will take a second or so, cycling through 5000000 times in a for statement takes about 1 second with single level checks, but you can always go to c++ for everything intensive.


see this code for example:


import time


def main():
    starttime = time.clock()
    for j in range(5000000):
        f = j
        if j == "f":
            print "yes"
        elif j == "s":
            print "yes!"
    endtime = time.clock()
    print starttime-endtime



main()


to check the same thing in cython, change the range to xrange.
There is about a 0.2 second difference.


But accessible_output makes life worth the trouble!
I have created a little module that you can import into your scripts that will make dealing with pygame super easy. Easy like:

import pygame_scripts as pg

def main():
    pg.screen("my test game")
    pg.speak("You are running through the forest! There is a dragon, press the space bar to kill it!")
    play = True
    num = 0
    while play:
        n = pg.key2() #key1 is the normal intensive key check, but key2 is basicly rest till key input
        if n[0] == "space":
            pg.speak("Great, you killed it!")
            play = False
        else:
            pg.speak("hurry, the dragon will eat you!")
            num += 1
        if num > 7:
            pg.speak("The dragon blows out a nice bit of flame right into your face... Oh, are you not pot-roast? Sorry...")
            play = False


main()
#the key function returns a tupal (key_name, key_mods) key name is like "space" "return" "f" "d" and mods have numbers that I just use right now, but will add in as words later...