How to make a wall-jump and dash in pygame ?

Started by
1 comment, last by Alberth 5 years, 1 month ago

I’ve fully used this tutorial : https://www.youtube.com/watch?v=5q7tmIlXROg&t=124s
So the code is the same as his ( download in description) and I wanted to go further with it and get to map-making with I really like but first of all, I need some more mechanics.
I’ve actually asked Him How to do it and I fully understand that https://imgur.com/a/kw4iAAx
same with dash with would simply be the player moving like twice speed in x direction but I don’t know How to write it down.
1 line of code will really help and I will really appreciate if you get me more depth on Why you did it that way so I don’t have to keep asking questions about it. ?

Advertisement

Time to experiment!

Make a copy of the code so you can go back to the current version. Most programmers use a version control system, but you can also just copy everything to a new directory. I use names likes "project20190719" for such copies (yyyymmdd is useful for sorting), so it is simple to understand when that code existed. Of course something like "project_tutorial_finished" works too, or an extra file with a description. Use whatever is most useful for you to know what a version does. (Before you know it, you'll have 5 to 10 of such copies, and then it's useful to be able to pick the right one directly.)

As for changes, first point is to detect you're jumping at a wall. Modify the code so it prints "wall!" (or beeps or whatever) when you detect it happening. Once you have that, change the print to setting a variable that you detected jumping at a wall. Next, modify movement code such that it moves as you want when the variable is set, and moves normally when it is not. Finally, you have to detect you're no longer jumping at a wall. That detection can be used to turn off the variable.

In other words, just work through the process step by step.

This topic is closed to new replies.

Advertisement