Tag Info

Hot answers tagged

9

Some Options for Python: Multiplatform (Win/Linux/Mac): PyInstaller Multiplatform (Win/Linux/Max): cx-freeze Windows: py2exe Mac: py2app The bad news is that, as far as I can tell, you can't create binaries for a platform from another platform. The reason seems to be dependencies on platform-specific libraries. Edit: By the way, you might be interested ...


8

At the request of commenters... Warning to Pyglet professionals: There may be a nice Pyglet way to do this, and this isn't it. It's a nice OpenGL way. You have been warned! You can do this in OpenGL by first binding the texture, then calling glTexParameteri or similar varients. You can do this in Pyglet by importing OpenGL: from pyglet.gl import * You ...


4

The concept of a surface in this situation is simply describing a texture. To understand this better, you should also understand the rendering process. When rendering anything using modern graphics API's, the end result is always going to be the same, a buffer (texture) of color data that is presented to the screen. How you get to that buffer can vary quite ...


4

Just use the maximum height of the window for your calculations: When setting: py_Y_Value = max_Screen_Height - my_Y_Value or when getting: my_Y_Value = max_Screen_Height - py_Y_Value The best way to utilize these would be to abstract away their use in wrapper functions.


4

py2exe + NSIS works well enough, though it can take some voodoo to figure out the right py2exe config usually (but you only have to do that once). You can also look at setuptools' entry-point-based script generation and the pkg_resources API for working with data files.


3

For those like me, who are simply making a retro-style game where they want EVERYTHING scaled to be pixelated, the simple quick answer is start your code with: from pyglet.gl import * glEnable(GL_TEXTURE_2D) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) Then all your usage of sprites, etc. from there on out stay nice and pixelated.


2

Ended up figuring out the answer myself through trial and error, solution follows. You need to import openGL to get access to the scaling function: from pyglet.gl import * Next, toss in the following code after your game's window has been initialized: #These arguments are x, y and z respectively. This scales your window. glScalef(2.0, 2.0, 2.0) At ...


2

I would recommend PyGlet, it has both GL and GLU built in, you can also use PyOpenGL(if you're ready to type a million OpenGL calls) for the best result, download it at CheeseShop: http://pypi.python.org/pypi


2

People post things made using Pyglet and PyOpenGL to pygame.org. The games list is open to anything in Python, not just the Pygame library.


2

There were no normals, so nothing was displaying. I updated the git repo to warn on missing normals. Unfortunately, I have no ground-breaking debugging techniques to report. I opened up the working .obj file and the "broken" .obj file, and by comparing them I noticed that one of the files had normals, and the other one didn't.


2

I tried out billboards a while back. I just created a quad that faced the camera. Using the position I want the object at and the up and right vectors (normalized) of the camera, you can set the four corners of the quad like so: a = position - ((right + up) * scale); b = position + ((right - up) * scale); c = position + ((right + up) * scale); d = position ...


2

Like this: import pyglet # Create and open a window window = pyglet.window.Window(200, 200) # Load sprites s0 = pyglet.resource.image('01.jpg') s1 = pyglet.resource.image('02.jpg') sprites = [s0, s1] # Animation anim = pyglet.image.Animation.from_image_sequence(sprites, 0.5, True) sprite = pyglet.sprite.Sprite(anim) @window.event def on_draw(): ...


2

To support drawing tile-based map of arbitrarily large bounds, you want to take the approach of not rendering every tile all the time. You only need to attempt to draw what the player could see, any other draw attempts are a waste of processing time and resources. This is an API-agnostic approach and it doesn't matter whether you are using Pygame, cocos2d, ...


1

vsync = True just means to wait with swapping buffers until the next vertical retrace, which is the point in time where a frame is completely drawn on the monitor, instead of somewhere halfway through, which can cause visible tearing during animations. Enabling vsync (on whatever platform) will simply tell OpenGL to wait for the next retrace. It will do ...


1

Yes, you can do this, but as the error tells you, you must use ctypes instead of Python types for it. RGB values are unsigned byte triplets, which means c_ubyte in ctypes, also available in pyglet.gl as GL_ubyte. So you can do this: pixels = [ 255, 0, 0, 0, 255, 0, 0, 0, 255, # RGB values range from 255, 0, 0, 255, 0, 0, ...


1

I pursued the pyglet_obj_test solution further and got it working. So, to answer my own question, here's a complete example: Using Blender, create a mesh with a UV-mapped texture. The UV-mapping is important! If it is working properly, you will see the texture applied within Blender's 3d view. Export the mesh from Blender using the Wavefront format, ...


1

I use my own sprite class, which has an timer variable which accumulates the dtime in the update_frames() message. By this you have an exact timestamp and can easily change the image based on certain timings.I do not have a source available but I will add this later, if needed Update: Here is a small piece of code: It loads two frames and displays flip flop ...


1

I wrote a lengthy post about producing retro vector graphics using OpenGL from pyglet: http://tartley.com/?p=1142



Only top voted, non community-wiki answers of a minimum length are eligible