TinyCircuits Forum

TinyCircuits Products => Thumby => Topic started by: CoolieCoolster on October 31, 2021, 02:10:51 AM

Title: Addition of third-party games to the pre-loaded set?
Post by: CoolieCoolster on October 31, 2021, 02:10:51 AM
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.
Title: Re: Addition of third-party games to the pre-loaded set?
Post by: lennevia on November 01, 2021, 04:14:33 PM
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!

Title: Re: Addition of third-party games to the pre-loaded set?
Post by: CoolieCoolster on November 01, 2021, 08:02:09 PM
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

def dump(obj,f,proto=0):

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

def load(f):
    return loads(s)

def loads(s):
    if "(" in s:
        if "." in qualname:
    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

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

# 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]

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]:
                del highScores[hard_mode][3]

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.