I'm trying to make a shooter game with pygame, but when I run my game, it displays the pygame window, but gives an error:
Traceback (most recent call last):
File "C:\Users\Nnamdi\AppData\Local\Programs\Python\Python36-32\game.py", line 26, in <module>
SCREEN.blit(text)
TypeError: Required argument 'dest' (pos 2) not found
Here's my code:
import pygame, sys
from pygame.locals import *
pygame.init()
ammo = "10" # you have ten ammo, use it wisely...
WIDTH = 600
HEIGHT = 600
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Bomber')
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
DARKBLUE = (2, 9, 129)
YELLOW = (255, 255, 255)
SCREEN.fill(DARKBLUE)
pygame.display.flip()
basicfont = pygame.font.SysFont(None, 48)
text = basicfont.render('Bomber', True, (255, 0, 0), (255, 255, 255))
SCREEN.blit(text, dest)
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
pygame.quit()
Hopefully, you can help.
You must define the dest
variable. You should also call the function pygame.display.flip()
. For example:
import pygame, sys
from pygame.locals import *
pygame.init()
ammo = "10" # you have ten ammo, use it wisely...
WIDTH = 600
HEIGHT = 600
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Bomber')
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
DARKBLUE = (2, 9, 129)
YELLOW = (255, 255, 255)
SCREEN.fill(DARKBLUE)
pygame.display.flip()
basicfont = pygame.font.SysFont(None, 48)
text = basicfont.render('Bomber', True, (255, 0, 0), (255, 255, 255))
dest = (100, 100)
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
SCREEN.blit(text, dest)
pygame.display.flip()
pygame.quit()
Screenshot:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments