Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi init bug #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/Ironseed-py.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions global_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"""
import pygame, os


# Simple objects is declared and initialized here,
# class object types is declared here and initialized in the init method.

size = width, height = 640, 480 # screen dimensions
# Planet texture constants.
planetHeight = 240 # 120
planetWidth = 480 # 240
# It's certainly not a lively python...
version = "IronPython 0.02 - Frigid Snake Alpha"

# Initialise music system and pygame
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.init()

# Colours
WHITE = (255, 255, 255)
GREY = (127, 127, 127)
Expand All @@ -36,9 +36,7 @@
TECH4 = (200, 200, 0)
TECH5 = (250, 250, 0)

# Note: Font should resize according to resolution, but logic needed.
# Fonts: this is a temporary google font, get it from them.
font = pygame.font.Font(os.path.join('Fonts', 'Inconsolata-ExtraBold.ttf'), 14)
font: object
offset = 15 # for this font.

# Totals for items
Expand All @@ -60,5 +58,20 @@

systemsVisited = []

starDate = [2, 3, 3784, 8, 75] #M,D,Y,H,M, Default entry here is for new game.
gameDate = "Placeholder" # The game time needs to be accessible everywhere.
starDate = [2, 3, 3784, 8, 75] # M,D,Y,H,M, Default entry here is for new game.
gameDate: object # The game time needs to be accessible everywhere.


# Class objects need a separate init function
def init(init_game_date):
# Initialise music system and pygame
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.init()
global font
# Note: Font should resize according to resolution, but logic needed.
# Fonts: this is a temporary google font, get it from them.
font = pygame.font.Font(os.path.join('Fonts', 'Inconsolata-ExtraBold.ttf'), 14)

# Initialise game objects
global gameDate
gameDate = init_game_date
7 changes: 5 additions & 2 deletions helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ def colourLine(length, colour):
# Rounded indicates if the end of the bar needs to be drawn as
# half a hemesphere with Height diameter.
# Returns a pygame surface with the required elements added.
def createBar(tupleList=[], length=0, height=int((g.height/320)*2), rounded=False):

def createBar(tupleList=None, length=0, height=None, rounded=False):
if height is None:
height = int((g.height / 320) * 2)
if tupleList is None:
tupleList = []
bar = pygame.Surface((length, height))
bar.set_colorkey(g.BLACK)
barArray = pygame.PixelArray(bar)
Expand Down
54 changes: 29 additions & 25 deletions ironSeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@
import helper_functions as h

class IronSeed(object):

def __init__(self):
self.state = 3 # Initilise with intro set, normally 3.

self.state = 3 # Initialise with intro set, normally 3.

self.creditText = ["1994 Channel 7, Destiny: Virtual",
"Released Under GPL V3.0 in 2013 by Jeremy D Stanton of IronSeed.net",
"2013 y-salnikov - Converted IronSeed to FreePascal and GNU/Linux",
"2016 Nuke Bloodaxe - Pascal Code Tidying/Prep",
"2020 Nuke Bloodaxe - Complete Python Refactor/Rewrite",
"All rights reserved."]
"Released Under GPL V3.0 in 2013 by Jeremy D Stanton of IronSeed.net",
"2013 y-salnikov - Converted IronSeed to FreePascal and GNU/Linux",
"2016 Nuke Bloodaxe - Pascal Code Tidying/Prep",
"2020 Nuke Bloodaxe - Complete Python Refactor/Rewrite",
"All rights reserved."]
self.versionText = ["Ironseed", g.version]

# Set Window version and Display surface
print("Initialise Screen.")
self.displaySurface = pygame.display.set_mode(g.size)
pygame.display.set_caption(self.versionText[0]+' '+self.versionText[1])

# Initialise game objects
print("Initilising IronSeed Game Time")
g.starDate = [2, 3, 3784, 8, 75] # M,D,Y,H,M.
g.gameDate = h.IronSeedTime()


# init globals
g.init(h.IronSeedTime())

# Populate Item dictionaries
print("Loading Items: ", end='')
items.loadItemData()
Expand Down Expand Up @@ -73,7 +71,7 @@ def __init__(self):
print("Game Generator Objects: ", end='')
self.generator = gen.Generator(self.ship, self.crew) # Settings at new-game state.
print("complete.")
print("Commnications System Objects: ", end='')
print("Communications System Objects: ", end='')
self.crewCom = crewC.crewComm(self.crew) # Needs to have crew data set.
print("complete.")
print("Planet Scanner Objects: ", end='')
Expand All @@ -97,9 +95,9 @@ def __init__(self):
print("Creating Main Menu: ", end='')
self.mainMenu = mainMenu.MainMenu()
print("complete.")

# Note: While in Alpha, the below state list is not exhaustive.

self.states = {1:self.generator.update, # The crew + ship selection system.
2:self.mainMenu.update, # Main menu.
3:self.intro.update, # Game Intro - quite useful for testing.
Expand All @@ -118,7 +116,7 @@ def __init__(self):
16: "Creation", # really item assembly/disassembly.
17: "Sector Map" # Inter-Sector travel.
}

self.interactive = {1:self.generator.interact,
2:self.mainMenu.interact,
3:self.intro.interact,
Expand Down Expand Up @@ -152,20 +150,26 @@ def main_loop(self):

# enter main state and logic loop.
while 1:

for evt in pygame.event.get():

if evt.type == pygame.QUIT:

pygame.quit()
sys.exit()

# Handle mouse input.
elif evt.type == pygame.MOUSEBUTTONDOWN:

self.state = self.interactive[self.state](evt.button)

g.gameDate.update() # Update game time in "realtime"
self.state = self.states[self.state](self.displaySurface)
# self.state(self.displaySurface)
pygame.display.update()


if __name__ == "__main__":
game = IronSeed()
game.main_loop()

12 changes: 4 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#
####### requirements.txt #######
#

###### Requirements without Version Specifiers ######
pygame
#io
Expand All @@ -10,23 +9,20 @@ pygame
#sys
#time
numpy
#

###### Requirements with Version Specifiers ######
# See https://www.python.org/dev/peps/pep-0440/#version-specifiers
#docopt == 0.6.1 # Version Matching. Must be version 0.6.1
#keyring >= 4.1.1 # Minimum version 4.1.1
#coverage != 3.5 # Version Exclusion. Anything except version 3.5
#Mopidy-Dirble ~= 1.1 # Compatible release. Same as >= 1.1, == 1.*
#
python >= 3.0

###### Refer to other requirements files ######
#-r other-requirements.txt
#
#
###### A particular file ######
#./downloads/numpy-1.9.2-cp34-none-win32.whl
#http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl
#

###### Additional Requirements without Version Specifiers ######
# Same as 1st section, just here to show that you can put things in any order.
#rejected
Expand Down