Skip to content

Commit

Permalink
Update Track.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetgu authored Jun 19, 2020
1 parent 1623708 commit 47131ba
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions frhd/Track.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# =============================================================
# A python package to generate tracks completely with python.
# Created and maintained by Gabriel Gutierrez.
# Special thanks to Pie42 for helping out with hte code.
# Special thanks to Pie42 for helping out.
#
# The directory structure:
# .
Expand Down Expand Up @@ -45,7 +45,7 @@
# =============================================================

# ============================================================= #
# Track.py
# Track.py
# ============================================================= #

from frhd import Encode as En # Import the encode.py file to encode to base32
Expand All @@ -69,6 +69,7 @@ def __init__(self):
# 3 empty lists, one each for physics, scenery, and powerups.
self.tracklist = [[], [], []]


"""Insert Line"""

def insLine(self, typeofline, *points):
Expand Down Expand Up @@ -101,30 +102,35 @@ def unpack(x, n):
if typeofline == 's':
self.tracklist[1] += [formatted_points]


"""Insert Star"""

def insStar(self, x, y):

self.tracklist[2] += [['T', x, y]]


"""Insert Checkpoint"""

def insCheck(self, x, y):

self.tracklist[2] += [['C', x, y]]


"""Insert Slow-Motion"""

def insSlo(self, x, y):

self.tracklist[2] += [['S', x, y]]


"""Insert Bomb"""

def insBomb(self, x, y):

self.tracklist[2] += [['O', x, y]]


"""Insert Gravity"""

def insGrav(self, x, y, rot):
Expand All @@ -136,6 +142,7 @@ def insGrav(self, x, y, rot):

self.tracklist[2] += [['G', x, y, rot]]


"""Insert Boost"""

def insBoost(self, x, y, rot):
Expand All @@ -144,23 +151,52 @@ def insBoost(self, x, y, rot):

self.tracklist[2] += [['B', x, y, rot]]


"""Insert the default "Start Line"."""

def insStart(self): # Needs no x/y since the line is defined in the code.

insLine(-40, 50, 40, 50, 'p') # Probably bad practice, but whatever.


"""Generate a random track."""

# ============================= DEPRECATED ============================= #
# == Code @ raw.githubusercontent.com/asdase26/FreeGen/master/main.py == #
# ============================= DEPRECATED ============================= #


"""Generate final code"""

def genCode(self):
self.trackdatalist = [[],[],[]] #holds raw data to be joined into frhd text

for pline in self.tracklist[0]: #physics
self.trackdatalist[0] += En.encline(pline)

for sline in self.tracklist[1]: #scenery
self.trackdatalist[1] += En.encline(sline)

for pup in self.tracklist[2]: #powerups
if len(pup) == 3: #if powerup does not have the rotation attribute
self.trackdatalist[2] += En.encpup(pup[1],pup[2],pup[0])
if len(pup) == 4: #if powerup does have rotation attribute
self.trackdatalist[2] += En.encpupr(pup[1],pup[2],pup[3],pup[0])

self.finalData = '' #this will be put into frhd

for typ in self.trackdatalist: #type of object
for indiv in typ: #individual object
self.finalData += indiv[0]
self.finalData += '#'#add object end marker

return self.finalData


# ====================================================================== #
# ============================ END OF CLASS ============================ #
# ====================================================================== #

"""Return the final track code"""

if __name__ == 'main':
my_track = Track()
Expand Down

0 comments on commit 47131ba

Please sign in to comment.