SophieWalden / Grand-Expansion

A little simplistic game about resource management
6 stars 2 forks source link

Help needed for Multiple files #8

Closed SophieWalden closed 5 years ago

SophieWalden commented 5 years ago

If anyone would like to help me I can't really figure this out. I have never split files with games using pygame, but have only done it with other projects that don't require pygame. Thus some errors about splitting it up come. If anyone would like to comment I have a few questions.

Any help with these questions is greatly appreciated and I would like to split it into multiple files before I continue.

-8BitToaster

THB0705 commented 5 years ago

Personally I like to split files for two reasons. To put a class in it for an object such as player sprites:

The second reason is to split files if you have different stages to a game (such as in your game):

For this option you could add a flow in three stages:

In your main file (your case game.py) you would check which part is active, (the game, the options, the main menu, etc), whichever part is active on that file you call the three main functions.

About the pygame.draw, make sure you are using the same surface to draw on ofc. Make sure you import pygame in each file. You should only need to initialize pygame once. If you can't get it to work, post the error that's being thrown and send me the draft code file.

SophieWalden commented 5 years ago

Ya, I learned how to split the file in 10 minutes and I'm going to update it now. Didn't see this comment till I uploaded it, but It still worked. You just have to execute the Main file for it to run

-8BitToaster