space
from kandinsky import * from ion import * from time import sleep WIDTH, HEIGHT = 320, 222 WHITE = color(255,255,255) BLACK = color(0,0,0) player_x = WIDTH//2 bullet = None aliens = [[x*30+20,20] for x in range(8)] score = 0 while True: # Besturing if keydown(KEY_LEFT) and player_x>0: player_x -= 4 if keydown(KEY_RIGHT) and player_x<WIDTH-20: player_x += 4 if keydown(KEY_OK) and bullet is None: bullet = [player_x+8,HEIGHT-20] # Beweeg kogel if bullet: bullet[1]-=5 if bullet[1]<0: bullet=None # Check botsing if bullet: for a in aliens: if a[0]<bullet[0]<a[0]+20 and a[1]<bullet[1]<a[1]+15: aliens.remove(a) bullet=None score+=1 break # Teken fill_rect(0,0,WIDTH,HEIGHT,BLACK) fill_rect(player_x,HEIGHT-15,20,10,WHITE) if bullet: fill_rect(bullet[0],bullet[1],2,5,WHITE) for a in aliens: fill_rect(a[0],a[1],20,15,WHITE) draw_string("Score:"+str(score),5,5,WHITE,BLACK) if not aliens: draw_string("YOU WIN!",120,100,WHITE,BLACK) break sleep(0.05)