Skip to content

Commit

Permalink
Modified gradient scene prep to add room autosizing, remove hard code…
Browse files Browse the repository at this point in the history
…d tile widths
  • Loading branch information
jwvhewitt committed Sep 27, 2023
1 parent 2b7ef04 commit 41d2303
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
9 changes: 4 additions & 5 deletions game/content/ghplots/ropp_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

VERSION = "v0.957"


class TitleScreenRedraw(object):

TITLE_DEST = pbge.frects.Frect(-325, -175, 650, 100)
Expand Down
27 changes: 17 additions & 10 deletions pbge/randmaps/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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]

8 changes: 4 additions & 4 deletions scenariocreatorsource/cities.ses
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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

Expand Down
24 changes: 24 additions & 0 deletions steambuilder/makedist.sh
Original file line number Diff line number Diff line change
@@ -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



0 comments on commit 41d2303

Please sign in to comment.