Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6584293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:31:07+00:00 2026-05-25T16:31:07+00:00

When I try to make a shape using variables, I keep getting this error

  • 0

When I try to make a shape using variables, I keep getting this error message:

“TypeError: integer argument expected, got float”

import pygame._view
import pygame, sys
from pygame.locals import *
import random

pygame.init()

…

barrel = pygame.image.load("images\Barrel.gif")
barrel_create = 0
barrelx = screen.get_height()- barrel.get_height()
barrely = screen.get_width()/2 - barrel.get_width()/2
barrel_exist = 0
explosion_delay = 0

…

while running:

    if barrel_exist == 0:
        if barrel_create == 500:
            barrely = 200
        barrelx = random.randint(0,400)
        barrel_exist = 1
    if barrel_exist == 1:
        barrely = barrely + 0.1
        if barrely > 400:
            barrel_exist = 0

    if explosion_delay > 0:
        pygame.draw.circle(screen, (0,255,0), (barrelx, barrely), 64, 0)
    explosion_delay = explosion_delay + 1

    if explosion_delay == 100:
    explosion_delay = 0

The explosion_delay > 0 when the barrel is “shot”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:31:08+00:00Added an answer on May 25, 2026 at 4:31 pm

    barrely = barrely + 0.1

    barrely must be a float at some point because of this line.

    I think you should do pygame.draw.circle(screen, (0,255,0), (int(barrelx), int(barrely)), 64, 0) to truncate the variables to integers as the function requires.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll try and make this clear; I've got two classes; GPU(Object) , for general
In my application i try to make custom shapes by using addPoly , but
I started to read the book numerical recipes in C... I try make my
I am trying to make a bunch of files in my directory, but the
I'm working on a sketch search engine that correlates whatever someone's sketching with a
I am currently faced with the task of importing around 200K items from a
I'm trying to use the ncurses-0.2 library from hackage, however whenever I'm trying to
I have created a ShapeDrawable and placed it within an imageview that is dynamically
I've been playing around with HTML5 and canvas and sprites and I've managed to
I have a thread class and in the run method I am making a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.