2019-02-09 05:12:24

I'm pretty sure iterating through the event queue is enough for pygame to handle it.

Deep in the human unconscious is a pervasive need for a logical universe that makes sense. But the real universe is always one step beyond logic.

2019-02-09 17:03:23 (edited by amerikranian 2019-02-09 17:06:53)

Alright, we have another issue on our hands here:
Here's my code. Note: A seperate test.py file is being used to run this.

import sys
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path)
import lib_openal as al
import lib_alc as alc
print("Done")

Here's the error I get upon running the script.

Traceback (most recent call last):                                              
File "C:\Users\amerikranian\Desktop\python\test.py", line 6, in <module>       
import lib_alc as alc                                                       
File "C:\Users\amerikranian\Desktop\python\lib_alc.py", line 156, in <module>  
alcGetStringiSOFT = _lib.alcGetStringiSOFT                                  
File "C:\python3\lib\ctypes\__init__.py", line 369, in __getattr__            
func = self.__getitem__(name)                                               
File "C:\python3\lib\ctypes\__init__.py", line 374, in __getitem__            
func = self._FuncPtr((name_or_ordinal, self))                               
AttributeError: function 'alcGetStringiSOFT' not found                          

Here are the files I have in my folder:
lib_openal.py
lib_alc.py
lib_efx.py
OpenAL32.dll
test.py
Some others that just sit there without being used. They're not imported, the script above is meant to see if everything works correctly.
So any tips?
Edit: I just tried downloading the latest version and replacing the dll. Still no luck, same error.

2019-02-10 02:09:55

Hm, that seems to indicate that the version of OpenAL its finding doesn't support that OpenAL Soft function. Do you have OpenAL installed on your system? If so it could be the non-OpenAL Soft version, and its going to try and default to that over whats in the working directory, so you'll either have to overwrite the version you have installed or uninstall it.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-02-10 04:47:55 (edited by amerikranian 2019-02-10 04:55:20)

So, @post 53, I had pyglet installed. When I removed pyglet, open al gives me the "No module named pyglet error." Tips?
I would go and use pyglet, but I understand Jack shit about it, literally. I much prefer writing my own event loops, even if it breaks from time to time.

2019-02-10 07:32:24 (edited by magurp244 2019-02-10 08:33:58)

Oops. Sorry, lib_openal.py and such do have a pyglet dependancy, specifically they use pyglet.lib to load OpenAL.DLL. You can install pyglet, but you don't have to use any of its functions for this. Alternatively you can edit the lib scripts and try swapping this:

_lib = pyglet.lib.load_library('openal', win32='openal32',
        framework='/System/Library/Frameworks/OpenAL.framework')

For this:

_lib = ctypes.CDLL('OpenAL32.dll')

And comment out import pyglet.lib.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-02-10 21:29:43

@post 55, thanks, that worked.
Now: To a question of a different nature.
Suppose I'm building an idel gathering game. Let's assume that we'll use a list for storing our resources. We'll use index to iterate and move through the list. The problem? The index doesn't keep it's value. what I mean is this:

index = 0
def addtoindex(index):
 index+=1

That code won't work. It will simply assign a value to a variable called index and won't update the index I declared above the function. However, this will work.

index=0
def index():
 global index
 index+=1

The problem I'm facing? Well, it's the global part. I don't want to do global x, global y, global z every time I want to change a value. That seems highly redundent. I could do return statements, but what if I don't always want to break a function by returning?
While I am not building a game per say, I still am trying to learn sounds and other concepts, and this is another problem I ran into. So tips? Suggestions? Am I stuck with globals or return statements and there's no other way?

2019-02-11 01:28:59

This has to deal with name spacing, variables made in a function live and die in that function unless passed to an outside source, so global or return functions are usually required. With return functions its more about deciding under what conditions you want to return and to perform the operations you want before hand, it might be a bit tricky in some cases, but you can always get results.

There is another way to go about this though, and thats with classes. In a class, a variable can be treated as a global internally to that class, and it can have its own internal functions for manipulating that data, which can make them very useful. For example:

class example(object):
 def __init__(self):
  self.index = 0
 def addtoindex(self):
  self.index += 1
 def addto(self,data):
  data += 1

box = example()
box.addtoindex()
box.addto(box.index)

This class treats index as a global within itself and has two functions, addtoindex() and addto(). Addtoindex() does a simple operation on self.index and those changes are retained because self.index exists outside that function, but with addto() you'll notice we don't use the "self" prefix anywhere, so the variable data is created and dies within that function since its not being returned anywhere. You can also access the index variable externally with the name of the class and the name of the variable, like the variable we pass to addto() on the last line of the example. So, going with your resource list idea, here's an example of what that might look like:

class example(object):
 def __init__(self):
  self.index = 0
  self.resource = ['wood','rock','iron','grain']
 def addtoindex(self):
  self.index += 1
 def inventory(self):
  print(self.resource[self.index])

box = example()
box.addtoindex()
box.inventory()
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2019-02-11 03:51:45

@post 57, Thanks again. I knew about the classes, but I already set up my project in such a way that the classes would force me to rewrite the thing from scratch. Oh well, lesson learned.