Ask coding questions

← Back to all posts
Why isn't this callable?
Graydog6 (2)

I am trying to create a shooter game. But whenever I try to create an enemy, it says:

"enemy = character([255, 0, 0], 10, enemy_locate_x, enemy_locate_y, 100, 100)
TypeError: 'character' object is not callable"

I don't know why. Please help me.

Commentshotnewtop
Coder100 (8720)

Hello, you already have a character variable on line 154. The solution is to rename the variable to something else, like char

Mark as correct answer if it has helped you!

Graydog6 (2)

@CodeLongAndPros well, I think it worked. But now I’m getting a new error.

adl212 (127)

@Graydog6 What is the new error?

Graydog6 (2)

@adl212 When you shoot you get this:
"if bullets.check_collision(enemy):
TypeError: check_collision() missing 1 required positional argument: 'guy'"

adl212 (127)

@Graydog6 Let me look through your code.

adl212 (127)

@Graydog6 currently, when I run your code, it states

NameError: name 'bullet' is not defined

I think this is because you also make an variable to iterate on line 257 and you aren't calling the correct variable.

Graydog6 (2)

@adl212 So what do I have to change? This code was working. But then I tried to add more enemies. Now it doesn't work. What variable do I have to call?

Coder100 (8720)

Hmmm. The code seems to work for me. I see 2 enemies. Is that expected? @Graydog6

adl212 (127)

@Graydog6 I believe you want to call the class bullets, but you are using bullet as the class directly. You have define a variable for the class to use it with the class's functions.

Graydog6 (2)

@Coder100 Well, there was supposed to be 25 enemies, only on the right side of the screen. But that is a different problem. When you click(Normally makes you shoot), it gives an error. Altho I have a coding instructor I'm meeting with today. I'll just ask him. Thanks for the help!

Coder100 (8720)

alright. No problem! Good luck! @Graydog6

Graydog6 (2)

@Coder100 Thanks, I fixed it. I'm going to copy my code into the repl.

Graydog6 (2)

Thanks @Coder100! Just make sure to copy the code into your own computer, since it is really slow on repl.