pyglet

pyglet when using draw() instead of eventloop

南楼画角 提交于 2019-12-11 07:46:08
问题 I'm trying to draw a circle with pyglet. But it is not visible when I use the draw() function instad of the app.run() loop. Any suggestions what I can do? thanks from math import * from pyglet.gl import * window = pyglet.window.Window() def makeCircle(x_pos, y_pos, radius, numPoints): verts = [] glClear(pyglet.gl.GL_COLOR_BUFFER_BIT) glColor3f(1,1,0) for i in range(numPoints): angle = radians(float(i)/numPoints * 360.0) x = radius *cos(angle) + x_pos y = radius *sin(angle) + y_pos verts += [x

How to make a 2d map with perlin noise python

落爺英雄遲暮 提交于 2019-12-11 06:28:10
问题 I have been experimenting on making a random map for a top down RPG I am making in Python. (and Pyglet) So far I have been making island by starting at 0,0 and going in a random direction 500 times (x+=32 or y -=32 sort of thing) However this doesn't look like a real image very much so I had a look at the Perlin Noise approach. How would I get a randomly generated map out of this :/ (preferably an island) and is it better than the random direction method? 回答1: a perlin map can be generated

Python Pyglet Using External Fonts For Labels

十年热恋 提交于 2019-12-11 06:27:16
问题 I'm working on a project at the moment and I have been trying to change the fonts of the labels in the pyglet library to fonts that I found online but I couldn't get it to work. I tried searching online for an hour now and nothing seems to be working. Added some code for reference: font.add_file('ZukaDoodle.ttf') ZukaDoodle = font.load('ZukaDoodle.ttf', 16) PlayLabel = pyglet.text.Label('Go', font_name='ZukaDoodle', font_size=100, x=window.width // 2, y=window.height - 450, anchor_x='center',

Loading image from a remote server in pyglet or PIL / python

 ̄綄美尐妖づ 提交于 2019-12-11 06:03:12
问题 I would like to feed images from a remote machine into pyglet (though I am open to other platforms where I can present images and record user's mouse clicks and keystrokes). Currently I am trying to do it using flask on the remote server and pulling it down with requests import requests from PIL import Image import io import pyglet import numpy as np r = requests.get('http://{}:5000/test/cat2.jpeg'.format(myip),) This does not work: im = pyglet.image.load(io.StringIO(r.text)) # Error: File "

trying to draw over sprite or change picture pyglet

瘦欲@ 提交于 2019-12-11 04:29:00
问题 I am trying to learn pyglet and practice some python coding with a questionnaire thing, but I am unable to find a way to make the background picture be removed or drawn on top of or something for 10 seconds. I am new and am lacking in a lot of the knowledge I would need, thank you for helping! import pyglet from pyglet.window import Window from pyglet.window import key from pyglet import image import time card1 = False cat_image = pyglet.image.load("cat.png") dog_image = pyglet.image.load(

Pyglet uses too much cpu

久未见 提交于 2019-12-11 03:21:10
问题 I recently startet getting into pyglet and rabbyt from pygame, but I have hit something of a brick wall. I created a basic example where one Sprite (of the type found in pyglet.sprite.Sprite) is displayed at 60 frames per second. The problem is that this simple program is using up 50% of the CPU time somehow. I repeated the experiment with the sprite type found in the rabbyt library with the same result. I decided to render 1000, then 10 000 sprites at 60 frames per second, and to my surprise

Using pyglet in python, why does my frame rate speed up if I mouse-drag?

前提是你 提交于 2019-12-11 03:15:00
问题 I wrote a simple image display using python's pyglet package. On my Linux laptop, the code worked how I expected, displaying a constant 60 frames per second. On my Windows 7 desktop (reasonably new from @Xi with a GeForce GTX 550 Ti), however, the frame rate is very very low (~10 FPS or less). I don't think this is a hardware limitation, however, because mouse-drag events speed the frame rate up drastically (60 FPS or more). Why is my frame rate so low on Windows when I'm not mouse-dragging,

Check whether a point exists in circle sector or not with Python

这一生的挚爱 提交于 2019-12-11 02:21:59
问题 I am aware that on the net and also here the question has already been asked, but unfortunately not in the Python environment. Looking on the net, I found this (Link) and from there I started working on it. Since I'm using Pyglet, I wrote the function as a thread. But first, I show you what I thought and wanted to accomplish: P = Sprite Player Position M = Mouse Position C = An imaginary circle, having as its radius the distance between P and M. 0, 1, 2, 3, 4, 5, 6, 7 = Directions that the

Using glGetFloatv to retrieve the modelview matrix in pyglet

前提是你 提交于 2019-12-11 01:05:33
问题 I'm doing 3d visualization in python using pyglet, and need to retrieve the modelview and projection matrices to do some picking. I define my window using: from pyglet.gl import * from pyglet.window import * win = Window(fullscreen=True, visible=True, vsync=True) I then define all of my window events: @win.event def on_draw(): # All of the drawing happens here @win.event def on_mouse_release(x, y, button, modifiers): if button == mouse.LEFT: # This is where I'm having problems a = GLfloat()

pyglet on_draw event occurs only when mouse moves

淺唱寂寞╮ 提交于 2019-12-10 18:09:50
问题 I have a strange problem. When pyglet app starts it just draws 1-2 frames then freezes. on_draw event just stops occuring. But everytime I move mouse or press keys, on_draw event dispatches as well. In short I have to move mouse to make my pyglet application basically work. This is actually happens in Windows. In Ubuntu with compiz I've to move mouse just once then application starts working normally. This is my code example: #!/usr/bin/env python import pyglet win = pyglet.window.Window