File simulatie/sim.py added (mode: 100644) (index 0000000..71db790) |
|
1 |
|
#!/bin/env python |
|
2 |
|
|
|
3 |
|
import sys, pygame |
|
4 |
|
import rabbit |
|
5 |
|
import thread |
|
6 |
|
|
|
7 |
|
pygame.init() |
|
8 |
|
|
|
9 |
|
speed = [2,2] |
|
10 |
|
|
|
11 |
|
screen = pygame.display.set_mode((800, 600)) |
|
12 |
|
|
|
13 |
|
ball = pygame.image.load("ball.png") |
|
14 |
|
ballrect = ball.get_rect() |
|
15 |
|
|
|
16 |
|
#thread.start_new_thread(rabbit.connect, ()) |
|
17 |
|
|
|
18 |
|
def drawMap(): |
|
19 |
|
kruispunt = pygame.image.load("../kruispunt.png") |
|
20 |
|
screen.fill((255,255,255)) |
|
21 |
|
screen.blit(kruispunt,kruispunt.get_rect()) |
|
22 |
|
# drawSpoorlijn() |
|
23 |
|
drawStrook35() |
|
24 |
|
# drawStrook25() |
|
25 |
|
# drawStrook16() |
|
26 |
|
# drawStrook15() |
|
27 |
|
# drawStrook14() |
|
28 |
|
# drawStrook18() |
|
29 |
|
# drawStrook22() |
|
30 |
|
|
|
31 |
|
def drawSpoorlijn(): |
|
32 |
|
pygame.draw.lines(screen, (100,100,100), False, [(799,450),(1,550)], 3) |
|
33 |
|
pygame.draw.lines(screen, (100,100,100), False, [(799,460),(1,560)], 3) |
|
34 |
|
for i in range(0, 27): |
|
35 |
|
pygame.draw.lines(screen, (139,62,17), False, [(30*i,545-3.7*i),(30*i,565-3.7*i)], 2) |
|
36 |
|
|
|
37 |
|
def drawStrook35(): |
|
38 |
|
pygame.draw.rect(screen, (120,120,120), (30*16,599,5,5),10) |
|
39 |
|
pygame.draw.rect(screen, (120,120,120), (30*15.8,500,5,5),10) |
|
40 |
|
pygame.draw.rect(screen, (120,120,120), (30*14,450,5,5),10) |
|
41 |
|
pygame.draw.rect(screen, (120,120,120), (30*11,390,5,5),10) |
|
42 |
|
pygame.draw.rect(screen, (120,120,120), (30*9,360,5,5),10) |
|
43 |
|
pygame.draw.rect(screen, (120,120,120), (30*6,340,5,5),10) |
|
44 |
|
pygame.draw.rect(screen, (120,120,120), (1,360,5,5),10) |
|
45 |
|
|
|
46 |
|
def drawStrook25(): |
|
47 |
|
pygame.draw.lines(screen, (166,46,46), False, [(30*16+10,599),(30*15.8+10,500),(30*14,385),(30*11,355),(30*8,327),(30*6+10,320),(1,340)], 10) |
|
48 |
|
|
|
49 |
|
def drawStrook16(): |
|
50 |
|
pygame.draw.lines(screen, (90,90,90), False, [(30*18,599),(30*15,355),(30*12,320),(30*8,295),(30*4,295),(1,320)], 20) |
|
51 |
|
|
|
52 |
|
def drawStrook15(): |
|
53 |
|
pygame.draw.lines(screen, (90,90,90), False, [(30*19,599),(30*15,275),(30*12,240),(30*8,225),(30*4,245),(1,290)], 20) |
|
54 |
|
|
|
55 |
|
def drawStrook14(): |
|
56 |
|
pygame.draw.lines(screen, (90,90,90), False, [(30*20,599),(30*16,290),(30*15.5, 150),(30*16, 1)], 20) |
|
57 |
|
|
|
58 |
|
def drawStrook18(): |
|
59 |
|
pygame.draw.lines(screen, (90,90,90), False, [(1,320),(30*4,295),(30*8,275), (30*12,290),(30*16,345),(30*19,380),(30*22,390),(799,380)], 20) |
|
60 |
|
|
|
61 |
|
def drawStrook22(): |
|
62 |
|
pygame.draw.lines(screen, (166,46,46), False, [(30*16+10,599),(30*15.8+10,500),(30*14,385),(30*10,330),(30*11.5,1)], 10) |
|
63 |
|
|
|
64 |
|
drawMap() |
|
65 |
|
# Mainloop |
|
66 |
|
while True: |
|
67 |
|
for event in pygame.event.get(): |
|
68 |
|
if event.type == pygame.QUIT: sys.exit() |
|
69 |
|
|
|
70 |
|
# ballrect = ballrect.move(speed) |
|
71 |
|
# if ballrect.left < 0 or ballrect.right > width: |
|
72 |
|
# speed[0] *= -1; |
|
73 |
|
# if ballrect.top < 0 or ballrect.bottom > height: |
|
74 |
|
# speed[1] *= -1; |
|
75 |
|
|
|
76 |
|
# screen.fill(0,0,0) # Black background |
|
77 |
|
# screen.blit(ball, ballrect) |
|
78 |
|
# drawMap() |
|
79 |
|
pygame.display.flip() |