Commits

Pierre Surply  committed bcfa0b0

Added anim lava + fix elt bloc

  • Participants
  • Parent commits 166adc4

Comments (0)

Files changed (3)

File res/img/lvl_elts.png

Old
Old image
New
New image

File res/img/water.png

Old
Old image
New
New image
 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>. 
 ##
 ## Started on  Thu Jun 28 13:22:05 2012 Pierre Surply
-## Last update Wed Aug 29 17:45:40 2012 Pierre Surply
+## Last update Thu Aug 30 11:50:35 2012 Pierre Surply
 ##
 
 import os
         glEnd()
         glEndList()
 
+        self.list_elt_cube = glGenLists(3)
+        glNewList(self.list_elt_cube,GL_COMPILE)
+        glBegin(GL_QUADS)
+        glTexCoord2d(0,0); glVertex3d(0, 1, 1)
+        glTexCoord2d(0,1); glVertex3d(0, 0, 1)
+        glTexCoord2d(1,1); glVertex3d(1, 0, 1)
+        glTexCoord2d(1,0); glVertex3d(1, 1, 1)
+        glEnd()
+        glBegin(GL_QUADS)
+        glTexCoord2d(0,0); glVertex3d(0, 1, 1)
+        glTexCoord2d(0,1); glVertex3d(0, 1, 0)
+        glTexCoord2d(1,1); glVertex3d(1, 1, 0)
+        glTexCoord2d(1,0); glVertex3d(1, 1, 1)
+        glEnd()
+        glBegin(GL_QUADS)
+        glTexCoord2d(0,0); glVertex3d(0, 0, 1)
+        glTexCoord2d(0,1); glVertex3d(0, 0, 0)
+        glTexCoord2d(1,1); glVertex3d(1, 0, 0)
+        glTexCoord2d(1,0); glVertex3d(1, 0, 1)
+        glEnd()
+        glBegin(GL_QUADS)
+        glTexCoord2d(0,0); glVertex3d(0, 0, 1)
+        glTexCoord2d(0,1); glVertex3d(0, 0, 0)
+        glTexCoord2d(1,1); glVertex3d(0, 1, 0)
+        glTexCoord2d(1,0); glVertex3d(0, 1, 1)
+        glEnd()
+        glBegin(GL_QUADS)
+        glTexCoord2d(0,0); glVertex3d(1, 0, 1)
+        glTexCoord2d(0,1); glVertex3d(1, 0, 0)
+        glTexCoord2d(1,1); glVertex3d(1, 1, 0)
+        glTexCoord2d(1,0); glVertex3d(1, 1, 1)
+        glEnd()
+        glEndList()
+
         self.list_robot = glGenLists(3)
         glNewList(self.list_robot,GL_COMPILE)
         glBegin(GL_QUADS)
         self.light = [[0] * self.size for i in range(self.size)]
         for i in self.robots:
             self.rec_calculate_light((i.pos_x, i.pos_y), 0, 0xEE)
+        for y in range(self.size):
+            for x in range(self.size):
+                if self.tile[x][y] == 6:
+                    self.rec_calculate_light((x, y), 0, 0x55)
 
     def rec_calculate_light(self, (org_x, org_y), dist, intens):
         if intens > 0:
         tile = self.tile[x][y]
         if tile == 2:
             glBindTexture(GL_TEXTURE_2D, self.sprite_water[self.id_sprite_water])
+        elif tile == 4:
+            glBindTexture(GL_TEXTURE_2D, self.sprite_water[self.id_sprite_water+4])
+        elif tile == 6:
+            glBindTexture(GL_TEXTURE_2D, self.sprite_water[self.id_sprite_water+8])
         else:
             glBindTexture(GL_TEXTURE_2D, self.sprite_floor[tile])
         z = self.temp_tiles[self.tile[x][y]][3]
         self.set_color_corner((x+1, y+1))
         glTexCoord2d(1,0); glVertex3d(1, 1, 0)
         glEnd()
-        self.set_color((x, y+1))
+        self.set_color((x, y))
         #glCallList(self.list_floor)
         if (not self.tile[x][y] in [2, 4]):
             if (y >= self.size-1 or self.temp_tiles[self.tile[x][y+1]][3] < z):
         glPopMatrix()
 
     def render_elt(self, x, y): 
-        glBindTexture(GL_TEXTURE_2D, self.sprite_elts[self.tile_elts[x][y]])
+        id_elt = self.tile_elts[x][y]
+        glBindTexture(GL_TEXTURE_2D, self.sprite_elts[id_elt])
         z = self.temp_tiles[self.tile[x][y]][3]
         glPushMatrix()
         glTranslated(x, y, z)
-        glCallList(self.list_elt)
+        if id_elt == 1:
+            glCallList(self.list_elt_cube)
+        else:
+            glCallList(self.list_elt)
         glPopMatrix()
 
     def render_robot(self, r):
             for x in range(max(select_x-7, 0), min(select_x+11, self.size)):
                 self.render_case(x, y)
                 if self.tile_elts[x][y] != None:
-                    light = self.light[x][y]
-                    glColor3ub(light, light, light)
                     self.render_elt(x, y)
         glColor3ub(0xFF, 0xFF, 0xFF)
         for i in self.robots:
             x = random.randint(0, self.size-1)
             y = random.randint(0, self.size-1)
         self.robots.append(r)
+        self.calculate_light()
 
     def get_pos_robot(self, n):
         if n < len(self.robots):