Skip to content

Commit

Permalink
Merge pull request #15 from gaudiatech/more-bundles-aug
Browse files Browse the repository at this point in the history
Ensure 4 game are OP (bundle format)
  • Loading branch information
wkta authored Aug 28, 2023
2 parents 8238842 + 70964bf commit 8f87490
Show file tree
Hide file tree
Showing 62 changed files with 2,865 additions and 766 deletions.
4 changes: 2 additions & 2 deletions examples/blokumanBundle/cartridge/metadat.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"vmlib_ver": "23_8a2",
"vmlib_ver": "23_8a5",
"dependencies": {
"pyved_engine": "23.4a4"
},
Expand All @@ -14,6 +14,6 @@
"coinlow.wav"
],
"game_name": "blokuman",
"cartridge": "blokuman",
"cartridge": "blokumanBundle",
"build_date": "Tue Aug 22 20:46:22 2023"
}
16 changes: 5 additions & 11 deletions examples/breakoutBundle/cartridge/metadat.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"vmlib_ver":"23_8a1",
"vmlib_ver": "23_8a5",
"dependencies":{
"pyved_engine": "23.4a4"
},
Expand All @@ -10,14 +10,8 @@
"(astero)rock.png"
],
"sounds": [
"FIRE.WAV",
"EXPLODE1.WAV",
"EXPLODE2.WAV",
"EXPLODE3.WAV",
"LSAUCER.WAV",
"SSAUCER.WAV",
"THRUST.WAV",
"SFIRE.WAV",
"LIFE.WAV"
]
],
"game_name": "Breakout classic",
"cartridge": "breakoutBundle",
"build_date": "???"
}
45 changes: 38 additions & 7 deletions examples/breakoutBundle/vm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import importlib.util
from pprint import pprint
import os


class _PyModulePromise:
verbose = 1
Expand Down Expand Up @@ -63,12 +65,41 @@ def upward_link(link_to_pimodules):
globals()['pimodules'] = link_to_pimodules


def find_spc_folder(givenfolder, start_path):
for root, dirs, files in os.walk(start_path):
if givenfolder in dirs:
return True
return False


def game_execution(metadata, game_definition_module):
print(f'~~Vm Pyv~~ LAUNCHING {metadata["game_name"]}...')
print('-'*8 + 'metadata' + '-'*8)
pprint(metadata)
# TODO handle special case
# --- detect a special case here: if @pyv.declare_begin
# and similar tags havent been used manually,
# I shall detect the proper game object and link stuff here,
# before calling run_game...

globals()['pimodules']['pyved_engine'].run_game()
print()

pyv = globals()['pimodules']['pyved_engine']
# <> Here we have to handle a special case
# ->to detect: if @pyv.declare_begin etc were not set.
# If so, and if gamedef has an object named "game" therefore we link all by ourselves
if pyv.vars.beginfunc_ref is None:
if hasattr(game_definition_module, 'game'):
game = getattr(game_definition_module, 'game')
# this manually connects existing codebase with the pyved 23.8a1+ philosophy (tags)
pyv.vars.beginfunc_ref, \
pyv.vars.updatefunc_ref, \
pyv.vars.endfunc_ref = game.enter, game.update, game.exit

# Strat= we preload all assets ->best solution considering the wanted code portability
# ... And no need to filter out the metadata here, pyv can handle the whole thing
current_folder = os.getcwd()
if find_spc_folder(metadata['cartridge'], current_folder):
adhoc_folder = os.path.join('.', metadata['cartridge'], 'cartridge')
elif find_spc_folder('cartridge', current_folder):
adhoc_folder = os.path.join('.', 'cartridge')
else:
raise FileNotFoundError("ERR: Asset dir for pre-loading assets cannot be found!")
pyv.preload_assets(metadata, prefix_asset_folder=adhoc_folder+os.sep)

# lets rock!
pyv.run_game()
Loading

0 comments on commit 8f87490

Please sign in to comment.