Esempio n. 1
0
def update():
    global x, dx
    game2d.canvas_fill((255, 255, 255))
    game2d.draw_circle((255, 0, 0), (x, y), 25)
    if not (0 <= x + dx <= ARENA_W - W):
        dx = -dx
    x += dx
def update():
    game2d.canvas_fill((255, 255, 255))

    for b in balls:
        b.move(True, True, True)
        x, y, r = b.get_coord()
        game2d.draw_circle((0, 0, 0), (x, y), (r + 2))
        game2d.draw_circle((b.getter()), (x, y), (r))
Esempio n. 3
0
def update():
    game2d.canvas_fill((255, 255, 255))

    ball.move()

    x, y, r = ball.get_coord()
    game2d.draw_circle((0, 0, 0), (x, y), (r + 3))
    game2d.draw_circle((ball.getter()), (x, y), (r))
def update():
    game2d.canvas_fill((255, 255, 255))

    ball.move_sin()
    x, y, r = ball.get_coord()
    game2d.draw_circle((0, 0, 0), (x, y), (r))

    game2d.draw_line((150, 150, 150), (0, arena.get_size()[1] // 2),
                     (arena.get_size()[0], arena.get_size()[1] // 2))
def update():
    arena.move_all()  # Game logic

    game2d.canvas_fill((255, 255, 255))
    for a in arena.actors():
        x, y, w, h = a.rect()
        # use the following lines to cut a sprite from a larger image
        xs, ys = a.symbol()
        game2d.image_blit(sprites, (x, y), area=(xs, ys, w, h))
def update():
    global dx, dy, verso

    game2d.canvas_fill((255, 255, 255))
    game2d.image_blit(image, (dx, dy))

    if dx < screen_x - 150 and dy < screen_y - 150:
        dx = (dx + 20)
        dy = (dy + 60)
    elif dx < screen_x - 150 and dy == screen_y - 150:
        dx = (dx + 20)
Esempio n. 7
0
def update():
    DX = 5
    DY = 5
    global x
    global y
    game2d.canvas_fill((255, 255, 255))
    game2d.draw_rect((0, 0, 255), (x, y, 100, 100))
    if x < 1100:
        x += DX
    if y < 700:
        y += DY
Esempio n. 8
0
def update():
    global dx,dy,verso

    
    game2d.canvas_fill((255,255,255))
    game2d.image_blit(image, (dx, dy))

    if (0 < dx < screen_x - 160 and x_on != 0) and (0 < dy < screen_y - 160 and y_on != 0):
        dx += 10 * x_on
        dy += 10 * y_on
        print("1^Ciclo Dy: ",dy,"Dx: ",dx)
    elif (dx == 0 or dx == screen_x - 160) and 0 < dy < screen_y - 160:
        dy += 10 * y_on
        print("2^Ciclo Dy: ",dy,"Dx: ",dx)
    elif (dy == 0 or dy == screen_x - 160) and 0 < dx < screen_x - 160:
        dx += 10 * x_on
        print("3^Ciclo Dy: ",dy,"Dx: ",dx)
Esempio n. 9
0
def update():
    global dx
    global dy
    global x
    global y
    game2d.canvas_fill((255, 255, 255))
    game2d.draw_rect((0,0,255),(x,y,SIDE,SIDE))
    if ((x+dx)<0):
        x=0
    elif((x+dx)>(WIDTH-SIDE)):
        x=(WIDTH-SIDE)
    else:
        x+=dx
    if ((y+dy)<0):
        y=0
    elif ((y+dy)>(HEIGHT-SIDE)):
        y=(HEIGHT-SIDE)
    else:
        y+=dy
Esempio n. 10
0
def updateall():
    game2d.canvas_fill((255, 255, 255))
    for b in balls:
        b.update()
Esempio n. 11
0
        self._dx = 5
        self._dy = 5
        self._w = 20
        self._h = 20

    def move(self):
        self._x += self._dx
        if (self._x > (ARENA_W - self._w)):
            self._x = self._w
        self._y = (math.sin(self._x) * 10) + (ARENA_H / 2)

    def rect(self) -> (int, int, int, int):
        return self._x, self._y, self._w, self._h

    def draw(self):
        game2d.draw_circle((0, 0, 255), (self._x, self._y), self._w)


game2d.canvas_init((ARENA_W, ARENA_H))
b1 = Ball(150, 40)
b2 = Ball(80, 40)
print('Ball 2 @', b2.rect())

while input() != 'x':
    game2d.canvas_fill((255, 255, 255))
    b1.move()
    b2.move()
    b1.draw()
    b2.draw()
    print('Ball 2 @', b2.rect())
Esempio n. 12
0
def update():
    global palla
    game2d.canvas_fill((255,255,255))
    palla.move()
    valori_palla = palla.rect()
    game2d.draw_circle((150,150,150),(valori_palla[0],valori_palla[1]),(valori_palla[2]))
import game2d


def sierpiski(livello, x0, y0, w, h):
    ws = w // 2
    hs = h // 2
    if livello == 0 or ws == 0 or hs == 0:
        return
    for x in range(2):
        for y in range(2):
            xs = x0 + x * ws
            ys = y0 + y * hs
            if x == 1 and y == 0:
                game2d.draw_rect((255, 255, 255), (xs, ys, ws, hs))
            else:
                sierpiski(livello - 1, xs, ys, ws, hs)


screen = 400

livello = int(input("A quale livello vuoi arrivare? "))

game2d.canvas_init((screen, screen))
game2d.canvas_fill((0, 0, 0))
w = h = screen

sierpiski(livello, 0, 0, w, h)