Um. Okay. I hope I'm not doing the batch thing wrong.
Here goes:
#_____________________________________________
import pyglet
from pyglet import clock, font
from pyglet.gl import *
#___________________________
#___________________________
#___________________________
class Basic_Tile(pyglet.sprite.Sprite): # Tile CUADRADO.
def __init__(self, archivo, t_x, t_y, cx, cy, centeredAP):
image = pyglet.image.load(archivo)
if centeredAP == False:
image.anchor_x, image.anchor_y = 0, 0
elif centeredAP == True:
image.anchor_x, image.anchor_y = image.anchor_x
+image.width/2, image.anchor_y+image.height/2
#pass it all on to the superclass constructor
pyglet.sprite.Sprite.__init__(self, image, cx, cy, batch =
batch)
self.color = (255,0,0)
self.type = "Basic Tile."
#dado en TILES (coords. en tiles):
self.X = t_x
self.Y = t_y
#dado en pixeles (coords. del centro)
self.x = cx
self.y = cy
#_____________________________________
class Tile_Engine(): #Para tiles CUADRADOS.
def __init__(self):
self.type = "Tile Engine"
#self.tileside = 10 # Magnitud del LADO del tile.
self.tileside = 15.0
self.Map_Width = 3
self.Map_Height = 3
#___________
self.Tile_Map = [] #Mapa de los tiles.
self.tst = []
#_____________________________________
def Set_Map(self):
l = self.tileside
cols = self.Map_Width
rengs = self.Map_Height
T = self.Tile_Map
#_
n = 0# para renglones
m = 0# para columnas
#_
k=l/2#contador de x
j=l/2#contador de y
#_____________________________________
while n<rengs:
T.append([]) #agrega un elemento de renglon.
while m<cols:
#T[n].append([Basic_Tile("10X10.png", n, m, j, k,
True)])#agrega elemento de una columna.
T[n].append([Basic_Tile("15X15.png", n, m, j, k,
True)])#agrega elemento de una columna.
#T[n].append([Sprite("10X10.png",j, k, True)])
#T[n].append([n,m])
j=j+l
m=m+1
m=0
j=l/2
k=k+l
n=n+1
#_____________________________________
batch = pyglet.graphics.Batch()#Defino un batch( en donde guardo
Sprites)...
#_____________IMPLEMENTACION + PYGLET:
E = Tile_Engine()
E.Map_Width = 15
E.Map_Height = 11
E.Set_Map() #Para calcular el mapa.
window = pyglet.window.Window(100, 100,resizable=True, vsync = False)
glClear(GL_COLOR_BUFFER_BIT) #Borra lo que sea que este en pantalla
(por si acaso)
#_____Create a font to display FPS
ft = font.load('Arial', 28)
#_____pyglet.font.Text object
fps_text = font.Text(ft, y=10)
@window.event
def on_draw():
glClearColor(0.5, 0.5, 1.0, 1.0)#El color del fondo.
glClear(GL_COLOR_BUFFER_BIT)
n = 0
m=0
while n<E.Map_Height:
while m<E.Map_Width:
E.Tile_Map[n][m][0].draw()
m=m+1
m=0
n=n+1
#___dibujando el frame rate.
fps_text.text = ("fps: %d") % (clock.get_fps())
fps_text.draw()
pyglet.app.run()
#_____________________________________________
#My apologies if the odd spanish mix-up is a problem.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.