Hello everyone! I've just found an example of a very basic side-scroller that just has 2 sets of platforms and a little square that jumps around. Now that I konw how, I can expand on this and make my level bigger. Before I do this though, there is an issue that needs addressing. When my little box sprite is on a platform, his movement is very jerky, and I don't really know how to fix it. I thought that perhaps I've typed something wrong but I've checked and double checked it with the example and I can't find anything wrong with it. I figured that as this was on a tutorial website (www.programarcadegames.com) that it would be all good, but it's horrible! Here is the code I have:

Try it out, it's horrible isn't it? Does anyone know how to make my little sprite move smoothly when he's on the platforms? I can't make a game with my hero jerking around on every platform he's on, it would be terrible. Any advice would be much appreciated.Thanks!

Tired of this guy's "examples". I recommend you don't use that site. Especially as this exact question was just asked recently. There are two ways to do this. If only ever colliding with rectangular objects you can, on collision, set the player's rect to the wall that he collides with.

i.e. if the player was falling and hit a platform below him, you would:

Wow, I didn't realise that his examples were that bad lol. When I first found the website, I clicked on the link that leads to 'aout the author' and saw that he was a professor so figured it would be quite good. This isn't the only 'example' that I've had trouble with neither. There was another one which just showed how to make a wall that a sprite cannot pass through, but when you move the sprite towards the wall, because it's moving 3 pixels at a time, there is a visible gap when the sprite colides with the wall. Not very good at all lol. I will copy your example and have a mess around with that, see if I can understand it. Thanks Mek!

Dan

ps: do you know of any better tutorials? And also, do you know of any tutorials that cover the use of tiles? I'd quite like to try to make a map with tiles. Thanks again!

Honestly there are tons of people out there "writing tutorials" that are just awful. I can't think of any at the moment that are actually decent. The problem is that the way to get the most visibility is to promise the world. Because of this you don't often see Pygame tutorials aimed at people that already know python. They are all written for (and far to often by) people that have just started to learn to program. In my opinion this is the wrong approach. Effective game programming--be it with Pygame or anything else--requires an Object Oriented approach. Pretending anything otherwise is not helpful to anyone.

There are certain cardinal sins that you can look out for though when trying to pick a good tutorial.

If the author does any of the following, just walk away:

Uses star imports of any kind.

Uses global variables of any kind (global CONSTANTS are fine).

Codes there main game loop in the global namespace.

Doesn't separate the event loop into its own function

Has multiple game loops or multiple event loops.

Uses the global keyword (there are cases where this is acceptable but most people who do it, do it for the wrong reason).

Shows basic errors like using repeated ifs in a block where elifs are indicated.

If you download and go through all the examples in my example repo in detail you should get a fairly good idea of the basics of Pygame. And will be better suited to ask questions when you do encounter things you don't understand.

The approximate order of difficulty is:

color_change.py

drag_text.py

eight_dir_move.py

punch_a_hole

resizable

tank_turret

four_direction_movement

topdown_scrolling

platforming

For working with tiles you basically have two options. Write your own; or use someone else's tile loading library. I always write my own though (which I highly recommend as an exercise) so I can't really comment on tile loaders.

Cool cheers Mek. Do you know that every single tutorial I've looked at includes at least one of the cardinal sins? Lol, you'd think that somebody would have made a decent tutorial. Oh well, Ive got your examples so I can play around with them and see what's going on. As for writing my own tile loader, I'd like to be able to do that, but I really don't thin I could. I looked at Richard Jones TMX loader (it's Python 2.7 so it's no good to me anyway) and honestly, I think that it's way beyond me. But, who knows, maybe with some reading I'll be able to.Thanks MekDan