A Slice of Pygame
Learning python is fun so far but like i said yesterday diving head first into something is how i normally learn about that something i might know the basics going in but that is pretty much all i know the first thing that got me stuck was indentation level's you can read about it here : https://www.python.org/dev/peps/pep-0008/#introduction coming from C# i just wrote my code however i wanted with little to no regard about how it looked to other people that was what comments are for right? well python cares and has a specific way that it has to be written to execute code correctly like this:
def hello():
# their has to be two spaces after a function!
print("hello world")
hello()
That's a basic hello world program pretty simple when you write a function in python you declare it with the def keyword and then you name your function at the end you add a semicolon all code added below the function must be lined up with the semicolon but you don't have to line it up to call it! also don't forget to add 2 blank lines below the function.
Now on to pygame after i got python setup i installed pygame with pip as per instructions found on pygame's website i then went looking around a bit on YouTube eventually i found a tutorial by The Terrible Programmer on making a rogue like in python using pygame and libtcod i have been following along for the past week and now have a basic game.
The only other problems i have encountered so far is i installed python version 3 and the tutorial uses python version 2 so i changed some code to work with python 3 also i decided hey it would be even easier to read my code if it was split up into more modules instead of one big file so i did that....i then spent several hours figuring out what went wrong.
Turns out you can't draw something to a surface you don't have access to who knew right? the solution make another surface for the map but don't update it that's what i did anyway will it cause issues in the future probably but im sure i can come up with a solution to that to.
upvoted and followed you if you like salaheldeen0 please upvoted and follow me lets help each other :)