jueves, 15 de noviembre de 2012

Imitación computacional de texturas naturales


La idea de la textura era hacer un cielo animado
el cielo seria un recorrido de colores
por ejemplo



en el programa hace un recorrido de azul dejando el texto en blanco
para la simulación o animación de estrellas

asi en la cadena de texto se le incluye un random que imprima un punto
y por lo tanto simulara una estrella



Simulación de las stars :P


Se alcanzan a ver muy leves los puntos


código


from Tkinter import *

def onclick():
   pass

root = Tk()
text = Text(root)
i=1
while i > 100:
   text.insert(INSERT, "       \n  ")
   i = i+1

#text.insert(END, "         .    ")
text.pack()
i=1
while i > 100:
   p=i+".0"

   text.tag_add("here", p, p)
   text.tag_config("here", background="blue", foreground="white")

    i=i+1

#text.tag_add("start", "2.0", "1.13")
#text.tag_config("start", background="darkcyan", foreground="white")


for i in range(100):
        x1=random.randint(1,100)
        y1=random.randint(1,100)
        ad.create_oval(x1, 10, y1, 10,width = 0, fill = white)


root.mainloop()


Este fue el primer código sin recorrido


from Tkinter import *

def onclick():
   pass

root = Tk()
text = Text(root)
i=1
#while i > 100:
text.insert(INSERT, "                                       .                    .                    . \n  ")
text.insert(INSERT, "      .            .               .  \n  ")
text.insert(INSERT, "          .                .                 .              .  \n  ")
text.insert(INSERT, "     .          .                         .      .   \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "  .      \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "               .                   .                    .   \n  ")
text.insert(INSERT, "             .    \n  ")
text.insert(INSERT, "      .                   .                  .                .  \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "  .     \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "    .   \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "      .  \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "        \n  ")
text.insert(INSERT, "       \n  ")
text.insert(INSERT, "        \n  ")
 #  i = i+1

#text.insert(END, "         .    ")
text.pack()
text.tag_add("here", "1.0", "2.0")
text.tag_add("here", "2.0", "3.0")
text.tag_add("here", "3.0", "4.0")
text.tag_add("here", "4.0", "5.0")
text.tag_add("here", "5.0", "6.0")
text.tag_add("here", "6.0", "7.0")
text.tag_add("here", "7.0", "8.0")
text.tag_add("here", "8.0", "9.0")
text.tag_add("here", "9.0", "10.0")
text.tag_add("here", "10.0", "11.0")
text.tag_add("here", "11.0", "12.0")
text.tag_add("here", "12.0", "13.0")
text.tag_add("here", "13.0", "14.0")
text.tag_add("here", "14.0", "15.0")
text.tag_add("here", "15.0", "16.0")
text.tag_add("here", "16.0", "17.0")
text.tag_config("here", background="blue", foreground="white")
#text.tag_add("start", "17.0", "18")
#text.tag_config("start", background="darkcyan", foreground="white")
#text.tag_add("start", "2.0", "1.13")
#text.tag_config("start", background="darkcyan", foreground="white")


for i in range(100):
        x1=random.randint(1,100)
        y1=random.randint(1,100)
        ad.create_oval(x1, 10, y1, 10,width = 0, fill = white)

root.mainloop()


Aportación Grupal


he estado investigando la interacción entre objetos y monos, restricciones
creando varias capas en el tmx y cada capa asignando valores

Ejemplo
este es una parte del código del juego


   LAYER_PISABLE = 0
    LAYER_SUELO = 1
    LAYER_OBJETOS = 2
    LAYER_OBJETOS_SUPERPUESTOS = 3
    LAYER_CIELO = 4



 def es_pisable(self,fila,columna):
        #si se intenta mover fuera del mapa, no se permite
        if ((fila >= self.height) or (fila < 0) or (columna >= self.width) or (columna < 0 )):
            return False
        else:
            return not (self.capas[Mapa.LAYER_PISABLE][fila][columna])

1 comentario:

  1. hubiera facilitado bastante el hacer que el fondo sea más oscura; van 5 por el modelo y 3 extra por los colores. En los puntos base van además 2 por haber aportado en el proyecto grupal. 7 + 3 por la última semana de tareas.

    ResponderEliminar