Skip to content

Instantly share code, notes, and snippets.

@ccanepa
ccanepa / pyglet_centered.py
Created November 19, 2017 21:00
to test pyglet screen geometry
"""shows the string '--- o ---', screen center shoud be on the 'o'
"""
from pyglet.gl import *
import pyglet
from pyglet.window import key
window = pyglet.window.Window(640, 480)
@ccanepa
ccanepa / noisy_simplified.py
Created May 6, 2015 14:11
simplified pyglet's noisy.py for testing purposes
'''Simplified noisy.py without sound, text or events to diagnose basic problems with sprites,
shows ten bouncing balls
'''
import os
import random
import sys
from pyglet.gl import *
import pyglet
from __future__ import print_function
import timeit
setup = (
"import cocos.collision_model as cm;" +
"import cocos.euclid as eu;" +
"rect1 = cm.AARectShape(eu.Vector2(1.0, 1.0), 2.0, 3.0);" +
"rect2 = cm.AARectShape(eu.Vector2(3.0, 3.0), 2.0, 3.0)")
res = timeit.repeat(stmt="a = rect1.distance(rect2)", setup=setup, repeat=3, number=1000000)
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="10" height="10" tilewidth="128" tileheight="128">
<tileset firstgid="1" name="road-tiles" tilewidth="128" tileheight="128">
<image source="road-tiles.png" width="640" height="512"/>
</tileset>
<layer name="map0" width="10" height="10">
<data encoding="base64" compression="zlib">
eJxjZGBgYCaAWYCYDYhZCWA+qDp2IBaEYg4keXYoH6aOE4i5oJgNzRxuMtTxADETFPMiqeOB8vkYSPMHNdUJIIUJLiwMxAAjRgMf
</data>
</layer>