Ejemplo n.º 1
0
def create_star(game_set, screen, stars, star_x, star_y):
    """Create a single star and add it to the group of stars with random position"""
    star = Star(game_set, screen)
    star_width = star.rect.width
    star_height = star.rect.height
    star.x = star_width * (1 + 2 * star_x)
    star.rect.x = rand_int(0, game_set.screen_width)
    star.rect.y = rand_int(0, game_set.screen_height)
    stars.add(star)
Ejemplo n.º 2
0
 def random(*args):
     if len(args) == 1 and isinstance(args[0], list):
         result = rand_item(args[0])
     elif len(args) == 2 and isinstance(args[0], int) and isinstance(
             args[1], int) and args[1] > args[0]:
         result = rand_int(args[0], args[1])
     else:
         return None
     return result.strip() if isinstance(result, str) else result
Ejemplo n.º 3
0
def random_string(max_length, min_length=-1):
    if min_length < 0 or min_length > max_length:
        return ''.join([
            random.choice(string.ascii_letters + string.digits)
            for i in range(max_length)
        ])
    else:
        return ''.join([
            random.choice(string.ascii_letters + string.digits)
            for i in range(random.rand_int(min_length, max_length))
        ])
Ejemplo n.º 4
0
 def get_random_node(self):
     node_no = random.rand_int(1, self.size)
     node = self.find(node_no)
     return node
Ejemplo n.º 5
0
 def _read(self, address, register, length):
     return bytes(bytearray(
         random.rand_int(0, 0xFF) for i in range(length)))
Ejemplo n.º 6
0
 def __init__(self, screen):
     self.screen = screen
     self.x = rand_int(0, 600)
     self.y = -rand_int(0, 100)
     self.speed = rand_int(10, 20)
     self.len = rand_int(0, 75)
Ejemplo n.º 7
0
 def fall(self):
     self.y += self.speed
     if self.y > 600:
         self.y = -rand_int(0, 100)
         self.speed = rand_int(10, 20)
Ejemplo n.º 8
0
import turtle
from turtle import TurtleScreen
from turtle import bgcolor
from turtle import setworldcoordinates
from random import*
from random import randint as rand_int
'''import Tkinter
from Tkconstants import*'''
sam3 = rand_int(180,100000)
sam = turtle.Turtle()
sam.shape('turtle')

sam.begin_fill()
sam.fillcolor('yellow')
for i in [0,1,2,3]:
    sam.speed(2)
    #sam.color('maroon')
    sam.forward(150)
    sam.right(90)
    sam.backward(50)
sam.end_fill()
sam.begin_fill()
sam.fillcolor('red')
sam.left(45)
sam.forward(210)
sam.right(75)
#sam.color('green','red')
sam.forward(210)
sam.speed(3)
sam.right(137)
sam.forward(186)