Jump to content
Unity Insider Forum

Flugzeug spiel


oskar
 Share

Recommended Posts

import pygame

import sys

 

# Initialisierung von Pygame

pygame.init()

 

# Bildschirmgröße

screen_width = 800

screen_height = 600

 

# Farben

black = (0, 0, 0)

white = (255, 255, 255)

 

# Erstellen des Bildschirms

screen = pygame.display.set_mode((screen_width, screen_height))

pygame.display.set_caption("Flugzeugspiel")

 

# Spieler Flugzeug

player_img = pygame.image.load('player.png')

player_x = 370

player_y = 480

 

def player(x, y):

    screen.blit(player_img, (x, y))

 

# Spiel Schleife

running = True

while running:

    for event in pygame.event.get():

        if event.type == pygame.QUIT:

            running = False

 

    # Bewegung des Spielers

    keys = pygame.key.get_pressed()

    if keys[pygame.K_LEFT]:

        player_x -= 5

    if keys[pygame.K_RIGHT]:

        player_x += 5

 

    # Hintergrundfarbe setzen

    screen.fill(black)

 

    # Spieler zeichnen

    player(player_x, player_y)

 

    # Bildschirm aktualisieren

    pygame.display.update()

 

# Pygame beenden und das Programm schließen

pygame.quit()

sys.exit()

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...