From 41d230300f93a14f26a96a20f7f8d97ac1e0ed99 Mon Sep 17 00:00:00 2001 From: jwvhewitt Date: Wed, 27 Sep 2023 10:38:07 +0900 Subject: [PATCH] Modified gradient scene prep to add room autosizing, remove hard coded tile widths --- game/content/ghplots/ropp_main.py | 9 ++++----- history.md | 2 ++ main.py | 1 - pbge/randmaps/prep.py | 27 +++++++++++++++++---------- scenariocreatorsource/cities.ses | 8 ++++---- steambuilder/makedist.sh | 24 ++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 20 deletions(-) create mode 100755 steambuilder/makedist.sh diff --git a/game/content/ghplots/ropp_main.py b/game/content/ghplots/ropp_main.py index dd59c689..d76afc69 100644 --- a/game/content/ghplots/ropp_main.py +++ b/game/content/ghplots/ropp_main.py @@ -1440,14 +1440,13 @@ def build_world(self, nart): exploration_music='Anthem of Rain - Adaptation (Instrumental).ogg', combat_music='HoliznaCC0 - Punk.ogg') # Create a scene generator - myroom = pbge.randmaps.rooms.Room(40, 25) - myroom.area = pygame.Rect(5, 10, 40, 25) + myroom = pbge.randmaps.rooms.Room(40, 25, anchor=pbge.randmaps.anchors.north) myscenegen = pbge.randmaps.PartlyUrbanGenerator( myscene, game.content.gharchitecture.HumanScaleGreenzone( prepare=pbge.randmaps.prep.GradientPrep( - [[ghterrain.GreenZoneGrass, 40], [ghterrain.Sand, 15], - [ghterrain.Water, 5]]), + [[ghterrain.GreenZoneGrass, 0.69], [ghterrain.Sand, 0.94], + [ghterrain.Water, 1.0]]), mutate=pbge.randmaps.mutator.CellMutator(), wall_converter=pbge.randmaps.converter. WallOnlyOnFloorConverter(ghterrain.Bushes, @@ -1464,7 +1463,7 @@ def build_world(self, nart): 10, tags=[pbge.randmaps.IS_CONNECTED_ROOM]), dident="_CITY_13") - myroom.area = pygame.Rect(0, 40, 50, 10) + myscenegen.archi.prepare.band_rooms[1] = myroom the_world['00000012'] = myroom mygate = self.register_element("_MISSION_GATE_13", Exit( diff --git a/history.md b/history.md index b6f28259..65932e9c 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,5 @@ +* Gradient map prep can now place rooms in requested bands + v0.957 September 25, 2023 * Fixed sound fx issues on certain platforms * Game will no longer crash if campaign is ended between completing a mission and leaving mission, which is a situation that never occurs in any of the scenarios but if it ever did happen it would work now diff --git a/main.py b/main.py index f9b2577c..737343ae 100755 --- a/main.py +++ b/main.py @@ -32,7 +32,6 @@ VERSION = "v0.957" - class TitleScreenRedraw(object): TITLE_DEST = pbge.frects.Frect(-325, -175, 650, 100) diff --git a/pbge/randmaps/prep.py b/pbge/randmaps/prep.py index 394820ad..e91f9372 100644 --- a/pbge/randmaps/prep.py +++ b/pbge/randmaps/prep.py @@ -54,10 +54,11 @@ def __call__( self, mapgen ): class GradientPrep( object ): """Make horizontal or vertical bands of terrain with some overlap.""" def __init__( self, bands, overlap=2, vertical=True ): - # Bands is a list of (terrain, width) pairs which describe the bands. + # Bands is a list of (terrain, width as 0.0-1.0 float) pairs which describe the bands. self.bands = bands self.overlap = overlap self.vertical = vertical + self.band_rooms = dict() def adjust_offset(self, offset): if random.randint(1,23) == 5: @@ -69,24 +70,31 @@ def __call__( self, mapgen ): # First, do the basic filling. mapgen.fill( mapgen.gb, mapgen.area, wall=True ) band_start = 0 - for band in self.bands: + if self.vertical: + band_stops = [int(band[1] * mapgen.height) for band in self.bands] + else: + band_stops = [int(band[1] * mapgen.width) for band in self.bands] + print(band_stops) + for n, band in enumerate(self.bands): if self.vertical: - mydest = pygame.Rect(0, band_start, mapgen.width, band[1]) + mydest = pygame.Rect(0, band_start, mapgen.width, band_stops[n] - band_start) else: - mydest = pygame.Rect(band_start, 0, band[1], mapgen.height) + mydest = pygame.Rect(band_start, 0, band_stops[n] - band_start, mapgen.height) if band is self.bands[-1]: # Error check- we want to make sure the map is completely filled! So, if this is the last band, make # sure that it reaches the bottom right corner of the map. mydest.bottomright = (mapgen.width, mapgen.height) mapgen.fill(mapgen.gb, mydest, floor=band[0]) - if self.vertical: - band_start = mydest.bottom - else: - band_start = mydest.right + myroom = self.band_rooms.get(n, None) + if myroom: + myroom.area = mydest + myroom.width = mydest.w + myroom.height = mydest.h + band_start = band_stops[n] # Second, randomize those bands up a bit. - baseline = self.bands[0][1] for b in range(len(self.bands)-1): + baseline = band_stops[b] offset = random.randint(0, self.overlap) - random.randint(0, self.overlap) b0,b1 = self.bands[b], self.bands[b+1] if self.vertical: @@ -107,5 +115,4 @@ def __call__( self, mapgen ): for dx in range(offset+1): mapgen.gb.set_floor(baseline + dx, y, b0[0]) offset = self.adjust_offset(offset) - baseline += b1[1] diff --git a/scenariocreatorsource/cities.ses b/scenariocreatorsource/cities.ses index 48d07600..01af6660 100644 --- a/scenariocreatorsource/cities.ses +++ b/scenariocreatorsource/cities.ses @@ -181,10 +181,10 @@ myscene = gears.GearHeadScene( ) # Create a scene generator -myroom = pbge.randmaps.rooms.Room(40,25) -myroom.area = pygame.Rect(5,10,40,25) +myroom = pbge.randmaps.rooms.Room(40,25,anchor=pbge.randmaps.anchors.north) + myscenegen = pbge.randmaps.PartlyUrbanGenerator( - myscene, game.content.gharchitecture.HumanScaleGreenzone(prepare=pbge.randmaps.prep.GradientPrep([[{city_terrain},40],[{beach_terrain},15],[{water_terrain},5]]), + myscene, game.content.gharchitecture.HumanScaleGreenzone(prepare=pbge.randmaps.prep.GradientPrep([[{city_terrain},0.69],[{beach_terrain},0.94],[{water_terrain},1.0]]), mutate=pbge.randmaps.mutator.CellMutator(), wall_converter=pbge.randmaps.converter.WallOnlyOnFloorConverter(ghterrain.Bushes, {city_terrain})), road_terrain={road_terrain}, @@ -201,7 +201,7 @@ myroom = self.register_element( "_ENTRY_ROOM_{_uid}", pbge.randmaps.rooms.Room(50, 10, tags=[pbge.randmaps.IS_CONNECTED_ROOM]), dident="_CITY_{_uid}" ) -myroom.area = pygame.Rect(0,40,50,10) +myscenegen.archi.prepare.band_rooms[1] = myroom +add_physical ROOM myroom diff --git a/steambuilder/makedist.sh b/steambuilder/makedist.sh new file mode 100755 index 00000000..cea87d10 --- /dev/null +++ b/steambuilder/makedist.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Move and rename everything for a new release. +# Stick all the zip files into dist, then run "makedist {version}" + +rm -rf ghcaramel + +mv ghcaramel_steam.zip ghcaramel-$1-steamos.zip +mv ghclinux.zip ghcaramel-$1-linux.zip +mv ghcmac.zip ghcaramel-$1-macos.zip + +unzip ghcwin.zip +mv exe.win-amd64-3.8 ghcaramel +mv ghcaramel/main.exe ghcaramel/ghcaramel.exe + +zip -r ghcaramel-$1-windows.zip ghcaramel +cd ghcaramel +zip -r ghcaramel-$1-steamwin.zip * +mv ghcaramel-$1-steamwin.zip .. +cd .. +rm ghcwin.zip + + +