Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

error, center argument must be a pair of numbers. newbie

Just trying to draw a circle within a window as a player class, but having some trouble. Can’t get past this error, looked up other posts on the issue but to no avail. Understood that error stems from the need for x,y to be integers and tuple but don’t see how to solve.

import pygame
import os




pygame.init()
window = pygame.display.set_mode((720, 1000))
clock = pygame.time.Clock()
pygame.display.set_caption('Geopocalypse')
bg = pygame.image.load(os.path.join('geobg2.png'))
white= [255, 255, 255]




class Player():
    def __init__(self):
        self.player_surface = window
        self.player_color = white
        self.player_radius = 20
        self.player_width = 0
        self.player_spawn_pos_x = pygame.Vector2(int(window.get_width() / 2))
        self.player_spawn_pos_y = pygame.Vector2(int(window.get_height() / 1.05))
       
    def character(self):
        self.player_character = pygame.draw.circle(self.player_surface, self.player_color, self.player_radius, (self.player_spawn_pos_x, self.player_spawn_pos_y), self.player_width)        
        



player = Player()
run = True  
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
    player.character()
    window.fill((0,0,0))
    window.blit(bg, (0,0))  
    pygame.display.update()   




pygame.quit()             

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

center is the 3rd parameter of draw.circle, not the 4th

You may try passing keyword arguments when you have a long list of them. That should help.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading