Commits

Pierre Surply committed 4f018a8

Added snow tree, dead tree and infected tree

  • Participants
  • Parent commits bcfa0b0

Comments (0)

Files changed (4)

File res/img/floor.png

Old
Old image
New
New image

File res/img/lvl_elts.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 Thu Aug 30 11:50:35 2012 Pierre Surply
+## Last update Sun Sep  2 16:50:51 2012 Pierre Surply
 ##
 
 import os
 from robot import mothership, woodcutter
 
 class Env(savable.Savable):
-    temp_tiles = [((255, 255, 255, 255), 0, "Grass", 0.7),\
+    temp_tiles = [((255, 255, 255, 255), 0, "Grass", 0.5),\
                   ((150, 100, 0, 255), 1, "Dirt", 0.4),\
                   ((0, 0, 100, 255), 2, "Water", 0),\
                   ((255, 255, 150, 255), 3, "Sand", 0.2),\
                   ((0, 0, 150, 255), 4, "Deep water", 0),\
-                  ((100, 100, 100, 255), 5, "Stone", 1),\
+                  ((100, 100, 100, 255), 5, "Stone", 0.6),\
                   ((255, 0, 0, 255), 6, "Lava", 0),\
                   ((20, 20, 20, 255), 7, "Gravel", 0.4),\
-                  ((10, 10, 10, 255), 8, "Volvanic stone", 1),\
-                  ((100, 0, 100, 255), 9, "Meteorite dirt", 1),\
-                  ((100, 0, 255, 255), 10, "Meteorite stone", 1),\
-                  ((101, 101, 101, 255), 11, "Stone", 1)]
-
-    temp_elts = [((0, 100, 0, 255), 0, "Tree"),\
-                 ((150, 150, 150, 255), 1, "Stone"),\
-                 ((100, 100, 100, 255), 2, "Bricks"),\
-                 ((100, 50, 0, 255), 3, "Wood"),\
-                 ((100, 0, 50, 255), 4, "Meteorite"), \
-                 ((200, 200, 200, 255), 5, "Iron")]
+                  ((10, 10, 10, 255), 8, "Volvanic stone", 0.6),\
+                  ((100, 0, 100, 255), 9, "Meteorite dirt", 0.6),\
+                  ((100, 0, 255, 255), 10, "Meteorite stone", 0.6),\
+                  ((101, 101, 101, 255), 11, "Stone", 0.6)]
+
+    temp_elts = [((0, 100, 0, 255), 0, "Tree", 0),\
+                 ((200, 200, 200, 255), 1, "Snow tree", 0),\
+                 ((0, 50, 0, 255), 2, "Dead tree", 0),\
+                 ((0, 150, 0, 255), 3, "Infected tree", 0),\
+                 ((150, 150, 150, 255), 4, "Stone", 1),\
+                 ((253, 253, 253, 255), 5, "Snow", 2)]
 
     biomes = [([(0.3, 4),\
                    (0.8,2),\
                   ([(0.3, 2),\
                        (0.33, 3),\
                        (0.6, 1),\
-                       (1.0, 0)], [(0.4, 0)]),\
+                       (1.0, 0)], \
+                       [(0.2, 4), (0.25, 2), (0.4, 0)]),\
                   ([(0.1, 2),\
                        (0.2, 1),\
                        (0.4, 11),\
                        (0.6, 5),\
                        (0.7, 7),\
                        (0.8, 8),\
-                       (1.0, 6)], [(0.4, 1)]),\
+                       (1.0, 6)], \
+                       [(0.3, 0), \
+                            (0.4, 2),\
+                            (0.5, 4)]),\
                   ([(0.5, 6),\
                        (0.8, 8),\
-                       (1.0, 5)], []),\
+                       (1.0, 5)], [(0.3, 4),\
+                                       (0.5, 2)]),\
                   ([(0.2, 2),\
                        (0.5, 1),\
                        (0.7, 11),\
                        (1.0, 5)], \
-                       []),\
+                       [(0.5, 1), \
+                            (0.9, 5)]),\
                   ([(0.2, 2),\
                        (0.21,3),\
                        (0.4,1),\
                        (1.0,5)], [(0.5, 0)]),\
                   ([(0.5, 6),\
                        (0.8, 8),\
-                       (1.0, 5)], []),\
+                       (1.0, 5)], [(0.4, 3)]),\
                   ([(0.1, 2),\
                        (0.3, 9),\
                        (0.6, 10),\
                        (0.8, 5),\
-                       (1.0, 11)], []),\
+                       (1.0, 11)], [(0.4, 3)]),\
                   ([(0.4, 4),\
                        (0.8, 2),\
                        (1.0, 3)], []),\
         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]
+        model = self.temp_elts[self.tile_elts[x][y]][3]
         glPushMatrix()
         glTranslated(x, y, z)
-        if id_elt == 1:
+        if model == 1:
+            glCallList(self.list_elt_cube)
+        elif model == 2:
+            glScalef(1, 1, 0.2)
             glCallList(self.list_elt_cube)
         else:
             glCallList(self.list_elt)
                 elt = self.get_rndelts(x, y, n, biome)
                 tile = self.tile[x][y]
                 self.tile_elts[x][y] = None
-                if elt == 0:
+                if elt in [0, 1]:
                     if tile in [0,1]:
                         self.tile_elts[x][y] = elt
-                elif elt == 1:
+                elif elt in [2, 3, 4, 5]:
                     if tile in [0,1, 5, 7, 8, 9, 10, 11]:
                         self.tile_elts[x][y] = elt
                 else:

File src/robot/robot.py

 ##    along with BASIC-RoBots.  If not, see <http://www.gnu.org/licenses/>.
 ## 
 ## Started on  Sun Jul  1 15:34:10 2012 Pierre Surply
-## Last update Wed Aug 29 15:10:39 2012 Pierre Surply
+## Last update Sun Sep  2 13:36:14 2012 Pierre Surply
 ##
 
 import os
                                              "",\
                                              "",\
                                              (0, []),\
+                                             {}), \
+                            "finditem": (self.radar_item, \
+                                             "",\
+                                             "",\
+                                             (0, []),\
                                              {})}
         self.os = robotsos.RoBotsOS(self, "saves/"+world+"/robots/"+self.name+"/fs", \
                                         self.mem, \
                 return 1
         else:
             return 0
+
+
+    def radar_item(self):
+        item = self.mem["A"]
+        nearest = None
+        dist = None
+        for y in range(self.env.size):
+            for x in range(self.env.size):
+                if self.env.tile_elts[x][y] == item and \
+                        (nearest == None or dist > (x-self.pos_x)**2 + (y-self.pos_y)**2):
+                    nearest = (x, y)
+                    dist = (x-self.pos_x)**2 + (y-self.pos_y)**2
+        if nearest is not None:
+            self.mem_stack.append(nearest[1])
+            self.mem_stack.append(nearest[0])
+            return 1
+        else:
+            return 0