#๐Ÿ”’ help with crouching in pygame

25 messages ยท Page 1 of 1 (latest)

nova bolt
#

Im creating a street fighter style game and im trying to make my character crouch but its not working :
When I press the down arrow it comes up with this

kindred hingeBOT
#

@nova bolt

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

slender leaf
#

!pastebin

kindred hingeBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

undone comet
#

next time copy and paste tracebacks and code plz, your problem though is that self.walkCount//3 is working out to be too large

nova bolt
#

How can I fix this?

#

Div it by a higher number?

warped patio
#

You can use the modulo operator

#

It gives you the division remainder

#

But in this case you'll still have an extra number, so you might want to modulo by 2

#

!e

print(7%2) #remainder 1
print(8%2) #remainder 0```
kindred hingeBOT
nova bolt
#

do you think you could explain how this works cause the tutorial guy didnt really explain it

#

like why was i DIVing in the first place

warped patio
#

Because they wanted to repeat the images for a couple frames

#

So dividing w floor division will keep the number the same for a couple iterations

#

Which might be what you want now that I think about it

#

Or some combination of modulo and //

nova bolt
#

how come that didnt work for the crouching but did work for the walking?

#

it works perfect with %1

warped patio
#

With %1 you'll always get the same frame

warped patio
kindred hingeBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.