Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix this DeprecationWarning

DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.

win.blit(playerStand, (x, y))

DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.

win.blit(walkLeft[animCount // 5], (x, y))

like image 644
Blazing_Sun Avatar asked Dec 14 '19 16:12

Blazing_Sun


People also ask

How do I fix DeprecationWarning in Python?

How do I remove deprecation warning in Python? Use warnings. filterwarnings() to ignore deprecation warnings Call warnings. filterwarnings(action, category=DeprecationWarning) with action as "ignore" and category set to DeprecationWarning to ignore any deprecation warnings that may rise.

How do you fix a deprecation warning?

To fix all deprecation warnings, follow the below steps: Replace update() with updateOne() , updateMany() , or replaceOne() Replace remove() with deleteOne() or deleteMany() . Replace count() with countDocuments() , unless you want to count how many documents are in the whole collection (no filter).

What is a DeprecationWarning in Python?

DeprecationWarning. Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by code in __main__ ). SyntaxWarning. Base category for warnings about dubious syntactic features.

What is DeprecationWarning in node?

DeprecationWarning errors are logged by the Node. js runtime when your code (or one of the dependencies in your code) calls a deprecated API. These warnings usually include a DEP deprecation code. They are logged using console. error and end up in your CloudWatch logs.


1 Answers

The warning is related to the coordinate parameter of blit(). Floating point coordinates, would mean that the origin of the Surface is somewhere in between to pixels in the window. That doesn't make much sense. The coordinates are automatically, implicitly truncated and that is indicated by the warning.
Use either int or round to convert the floating point coordinates to integral numbers:

win.blit(playerStand, (round(x), round(y)))
like image 60
Rabbid76 Avatar answered Oct 09 '22 20:10

Rabbid76