Addition of third-party games to the pre-loaded set?

CoolieCoolster

  • Full Member
  • ***
    • Posts: 30
    • View Profile
As there's still at least two weeks until any production begins, and I would imagine still some time after that until devices are assembled and flashed with firmware, perhaps the addition of completed third-party Thumby games to the default set of five could be something to consider as a means of giving the device additional functionality out of the box? While users can always add and remove games based on their preferences, I thought that perhaps the inclusion of third-party games completed prior to whenever firmware flashing will begin could serve as both a means of encouraging additional third-party development and adding to the first impressions that the user would have in regards to the capabilities of the Thumby.

In regards to my own projects, if NanoMem's implemented button-select sound effects work on actual hardware, and if I can figure out how to use the functions transposed from "Pickle" to save the "hard mode unlock" and six high score values to a text file, I would be glad to contribute it, should the creator of TinyMem not have any objections.


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 437
    • View Profile
We definitely see this as an option and would love to include more games as they are available and we ship units out. We likely need some game submission infrastructure put in place to make sure those creating games are okay with the idea. Hopefully, we will get something together this week!

My personal worry as I lurk through the forum is that many are still in the process of improving games, so I hesitate to add games not 'finished' to the author's preference. A guideline of submitting a game to be added to Thumby with the author's approval eases my mind.

We can test out hardware functionality here up to the author's preference as a part of this process. Thank you for your input!

Best,
RĂ©na


CoolieCoolster

  • Full Member
  • ***
    • Posts: 30
    • View Profile
Thanks for the reply! The unfortunate thing is that not many people seem to be developing games yet, despite the fact that it seems that many of us working on MicroPython projects are learning while doing, so hopefully others in the community can find inspiration to make programs of their own. As I'm keen to finish up NanoMem and figure out the mystery that will be combining animation and velocity in my second project (I expect SaurRun has some functions that might be helpful to learn from in that regard), I'll see if I can finish my function rewrites and implementation of save data saving/loading in the next few days.

If anyone working on their own Thumby projects might be able to help discern how to use the following functions from pickle to serialize and deserialize variables and lists to a defined txt file, I'll post what I've gathered so far on the subject:

The following is the pickle function, edited to allow for its use without a seperate pickle module:
Code: [Select]
# Save data serialization
HIGHEST_PROTOCOL=0

def dump(obj,f,proto=0):
    f.write(repr(obj))

def dumps(obj,proto=0):
    return repr(obj).encode()

def load(f):
    s=f.read()
    return loads(s)

def loads(s):
    d={}
    s=s.decode()
    if "(" in s:
        qualname=s.split("(",1)[0]
        if "." in qualname:
            pkg=qualname.rsplit(".",1)[0]
            mod=__import__(pkg)
            d[pkg]=mod
    return eval(s,d)

If it helps, the following description was also listed in the documentation describing the function, though it wasn't too helpful for me:
Code: [Select]
import pickle
data = {'1':b'test\nmore', '2':1.414, '3': [11, 12, 13]}
s = pickle.dumps(data)
print('Human readable data:', s)
v = pickle.loads(s)
print('Decoded data (partial):', v['1'])

Human readable data: {"2": 1.414, "3": [11, 12, 13], "1": "test\nmore"}
Decoded data (partial): test
more

s = ujson.dumps(data)
# pickle produces a bytes object whereas ujson produces a string
u.write(s.encode())
# Pickle:
# u.write(s)
u.write(b'\n')

# receiver
s = u.readline()
v = ujson.loads(s)  # ujson can cope with bytes object
# ujson and pickle can cope with trailing newline.

The following was my initial attempt at adding theoretical variable saving functionality to NanoMem, and while it includes what I think is the intended method of opening, reading, and writing to files, I have yet to figure out how to combine it with the pickle functionality to save and load the variable that determines whether or not the user has unlocked hard mode and the index of six high score values that are currently saved if the current score following a "desync" is greater than one of the three saved high scores for the current gamemode:

Code: [Select]
thumby.files.openFile(/Games/NanoMem/data.txt)
    thumby.files.readFile(1)
    if(thumby.files.readFile()=='h'):
        h=1
        thumby.files.closeFile()
        bl(s1e2,33,29,6,7)
    elif(thumby.files.readFile()=='r'):
        thumby.files.closeFile()
    else:
        thumby.files.openFile(/Games/NanoMem/data.txt,w)
        thumby.files.writeFile(r000000000000000000000000)
        thumby.files.closeFile()

Should it be of any use, the following is the aforementioned function that saves high scores in NanoMem, with an i value of range three for the three high score values saved, which itself is defined by the hard_mode variable that places it in the corresponding sub-index of the highScores index:

Code: [Select]
for i in range(3):
            if s>highScores[hard_mode][i]:
                highScores[hard_mode].insert(i,s)
                del highScores[hard_mode][3]
                break

Assuming an efficient function for saving and loading variable data is standardized, perhaps it will prove helpful to future users in saving time in developing their own games.


 

SMF spam blocked by CleanTalk