from scene import *
import random
class Column(SpriteNode):
def __init__(self, **kwargs):
SpriteNode.__init__(self, 'plf:Tile_BoxCrate_double', **kwargs)
class Game(Scene):
def setup(self):
self.background_color = '#99d7ff'
x = 0
ground = Node(parent=self)
while x < self.size.w:
lower_tile = SpriteNode('plf:Ground_Stone', (x, 30))
higher_tile = SpriteNode('plf:Ground_Stone', (x, 738))
x += 60
ground.add_child(lower_tile)
ground.add_child(higher_tile)
self.add_column()
def add_column(self):
lower = random.randint(0, 360) // 64
higher = random.randint(0, 360) // 64
y = 45
for i in range(lower):
column = Column(parent=self)
column.anchor_point = (0.5, 0)
column.position = (self.size.w, y)
y += 64
y = 738
for i in range(higher):
column = Column(parent=self)
column.anchor_point = (0.5, column.size.h)
column.position = (self.size.w, y)
y -= 64
run(Game())
This only makes ground and two columns at the end of the screen. The problem is that whenever I run this, the columns always at the same size. But I use random here, so they should get different each time. I can't get why is it so