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
#๐ help with crouching in pygame
25 messages ยท Page 1 of 1 (latest)
@nova bolt
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.
Closes after a period of inactivity, or when you send !close.
!pastebin
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.
next time copy and paste tracebacks and code plz, your problem though is that self.walkCount//3 is working out to be too large
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```
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 1
002 | 0
ok thanks ill give it a go
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
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 //
how come that didnt work for the crouching but did work for the walking?
it works perfect with %1
With %1 you'll always get the same frame
That's because the walking has more frames, so the division result exists in the list
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.