I'm trying to get a little bit better organized in my programming, so I've decided to use multiple python files to organize my game. For some reason, I cannot use functions from another script. My main script in which I run the game is called main.py and the script I'm trying to use functions from is gamemap.py . Here is the code which I use to do this
import pygame,sys,time
import gamemap as g
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((800,600))
#Pictures
enemy = pygame.image.load("enemy_reg.png")
player = pygame.image.load("player_reg.png")
player_shot = pygame.image.load("playershot.png")
enemy_shot = pygame.image.load("shot.png")
g.loadmapstuff()
__init__.py, and put it under a folder with the name of your module. Then, from another file which is located next to that folder, you can import that module usingimportfollowed by the name of the folder.