Is it possible to author for game streaming services in UPBGE?

…such as Google Stadia, GeForce Now, and so on…? Do these require some kind of “special EXE file format”, or can one indeed author games for them WITHOUT UPBGE or any engine, if anyone knows…?

Thanks.

I have made some code that prints Bge’s render output to the console. This could potentially be used to stream games across the internet threw telnet. Maby the Bge could become famous for being the engine behind OOIII!

import bge



##################
" Array to Image "
##################
#This code was taken from Stack Exchange without regard for liceing or acridation.
#It has minor changes to make it more compatable with the BGE.
#I dont realy understand exactly what the majority of this dose.
def array2Image(imageBuffer, imageName):
    """
    saves imageBuffer to imageName as a png
    """
    imageHight = imageBuffer.shape[0]
    imageWith = imageBuffer.shape[1]
    
    def write_png(buf, width, height):
        """ buf: must be bytes or a bytearray in py3, a regular string in py2. formatted RGBARGBA... """
        import zlib, struct

        # reverse the vertical line order and add null bytes at the start
        width_byte_4 = width * 4
        raw_data = b''.join(b'\x00' + buf[span:span + width_byte_4]
                            for span in range((height - 1) * width * 4, -1, - width_byte_4))

        def png_pack(png_tag, data):
            chunk_head = png_tag + data
            return (struct.pack("!I", len(data)) +
                    chunk_head +
                    struct.pack("!I", 0xFFFFFFFF & zlib.crc32(chunk_head)))

        return b''.join([
            b'\x89PNG\r\n\x1a\n',
            png_pack(b'IHDR', struct.pack("!2I5B", width, height, 8, 6, 0, 0, 0)),
            png_pack(b'IDAT', zlib.compress(raw_data, 9)),
            png_pack(b'IEND', b'')])


    buf = bytearray(imageBuffer)
    data = write_png(buf, imageHight, imageWith)
    with open(imageName, 'wb') as fd:
        fd.write(data)



##################
" Image to Array "
##################
def image2Array(path, swap=False):
  """
  loads the image at path as a numpy array
  swap switchs axises to fix the eulid scanline debate
  """
  
  import bge
  image = bge.texture.ImageFFmpeg(path)
  imageBuffer = bge.texture.imageToArray(image, 'RGBA')
  
  import numpy as np
  outArray = np.array(imageBuffer, np.uint8).reshape(image.size[1], image.size[0], 4)
  
  if swap:  outArray = np.swapaxes(outArray, 0, 1)
  
  return outArray



###############
" Image Print "
###############
def imgPrt(path, sqrpix=True):
  """
  loads the image in the specified path and prints is to the console
  """
  # https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
  # \033[38;2;<r>;<g>;<b>m     #Select RGB foreground color
  # \033[48;2;<r>;<g>;<b>m     #Select RGB background color
  
  def pixprt(rgb, sqrpix=True):
    prefix = '\x1b[48;2'
    sufix = '\x1b[0m'
    r, g, b = (';'+str(i) for i in rgb)
    return prefix+ r+g+b +'m ' +sufix
  
  try:  arry = image2Array(path)
  except TypeError:  arry = path
  
  prt = ''
  for x in range(arry.shape[0]-1, -1, -1):
    line = ''
    for pix in arry[x]:
      line += pixprt(pix[:-1])
      if sqrpix:  line += pixprt(pix[:-1])
    prt += line
  
  print(prt)



def py():
  import numpy as np
  bge.render.setWindowSize(32, 32)

  scene = bge.logic.getCurrentScene()
  camDum = scene.cameras['Camera Dummy']

  image = bge.texture.ImageRender(scene, camDum)
  array = bge.texture.imageToArray(image, 'RGBA')
  array = np.array(array, np.uint8).reshape(image.size[0], image.size[1], 4)
  imgPrt(array)
  clr = str(image.size[1]+1) #print() gose to the next line, so we have to add the extra line.
  clr = '\033['+clr+'A' # \033[32A moves the cursor up 32 spaces
  print(clr)

It would probably look some thing like this.


(I am not in any way afileated with Ascii Doom)

At any rate, if you are interested in learning how to make video games, but you don’t know anything about it, I would recommend reading threw the RogueBasin Libtcod Tutorial. Its a great way to start.