Ejemplo n.º 1
0
screen = pygame.display.set_mode((400, 400))
pygame.display.set_caption('2048')

font = pygame.font.Font('font/ahronbd.ttf', 50)


move = Move()
move.generate_structure()
keyboard = Keyboard()
render = Render()
cont = True
game_lose = False
while cont:
	screen.fill(h333)
	key = keyboard.check()
	
	if key == "down":
		move.down()
	elif key == "up":
		move.up()
	elif key == "left":
		move.left()
	elif key == "right":
		move.right()
	elif key == "end":
		cont = False
	if key in ("down", "up", "left", "right"): 
		if not move.add_nb():
			game_lose = True
Ejemplo n.º 2
0
WF = Wheel(NG, 128, -800)  # front wheel
WB = Wheel(NG, 0, -800)  # back wheel
C = Car(WB, WF)

run = True

# main loop

while run:
    R.delay(20)

    # event handle
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        K.check(C)

    # engine update

    WF.update(1)
    WB.update(1)

    R.lookAt(WF.x, WF.y)

    c = WB.distance(WF)
    C.x = c[0]
    C.y = c[1]
    C.angle = c[2]

    WF.setLastRotation()
    WB.setLastRotation()