@Jeku
using an image for large amounts of text could be done similar to my method below that I threw together but for example
a 128* 128 pixel image could store if my math is correct 128^4 * 128^4. the below code will need work if you plan to go down that method
and you could always use the alpha channel for database indexing. (edited its now dumping an example etc correctly with bytes)
// Project: colorDatabase
// Created: 2023-03-21
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "colorDatabase" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type _map
r as integer
g as integer
b as integer
a as integer
endtype
global maps as _map[]
SetRawWritePath(GetReadPath())
dumpText("test1.txt")
img=loadimage("testImage.png") //used to set up an image for sizing memblocks
loadText("test1.txt")
img2=ConvertInfoToPic(img)
ConvertPicToInfo(img2)
spr=CreateSprite(Img2)
SetSpritePosition(spr,0,0)
//i as integer
do
print(maps.length)
Print(Chr(maps[random(1,maps.length)].r))
Print(Chr(maps[random(1,maps.length)].b))
Print(Chr(maps[random(1,maps.length)].g))
Print(Chr(maps[random(1,maps.length)].a))
sync()
loop
function dumpText(filename as string)
file = OpenToWrite(filename):count=0
//WriteLine(file,words)
repeat
WriteByte(file,(random(1,255))) //save characters in byte format
inc count
until count=1024*1024
closefile(file)
endfunction
function loadText(filename as string)
file = OpenToRead(filename)
myMap as _map
line as string
count =1
repeat
myMap.r = (ReadByte(file))
myMap.g = (ReadByte(file))
myMap.b = (readByte(file))
myMap.a = (readByte(file))
maps.insert(myMap)
until fileEof(file)=1
CloseFile(file)
endfunction
function ConvertInfoToPic(img)
imgMemblock = CreateMemblockFromImage(img)
deleteImage(img)
width = GetMemblockInt(imgmemblock,0)
height = GetMemblockInt(imgmemblock,4)
count=0: myMap as _map
if maps.length>0
for x=0 to width-1
for y =0 to height-1
if Count<=maps.length
myMap=maps[count]
offset = (12+((y * width) + x) * 4) - 4
SetMemblockInt(imgmemblock,offset,myMap.r)
SetMemblockInt(imgmemblock,offset+1,myMap.g)
setMemblockInt(imgmemblock,offset+2,myMap.b)
SetMemblockInt(imgmemblock,offset+3,myMap.a)
inc Count
endif
next
next
endif
newimg=CreateImageFromMemblock(imgMemblock)
DeleteMemblock(imgMemblock)
endfunction newImg
function ConvertPicToInfo(img)
imgMemblock = CreateMemblockFromImage(img)
width = GetMemblockInt(imgmemblock,0)
height = GetMemblockInt(imgmemblock,4)
count=0
myMap as _map
for x=0 to width-1
for y=0 to height-1
offset = (12+((y * width) + x) * 4) - 4
myMap.r=GetMemblockInt(imgmemblock,offset)
myMap.g=GetMemblockInt(imgmemblock,offset+1)
myMap.b=GetMemblockInt(imgmemblock,offset+2)
myMap.a=GetMemblockInt(imgmemblock,offset+3)
maps.insert(myMap)
next
next
//deleteImage(img)
DeleteMemblock(imgMemblock)
endfunction //newImg
function makeRandomString(s$ as string,fromAsci as integer, toAsci as integer,n as integer,ammount as integer)
//Creates a random string of asci characters in the range fromAsci toAsci with the ammount of n
r$=s$
if n <= ammount //then exitfunction r$
r$=r$+(chr(random(fromAsci,toAsci)))
r$=makeRandomString(r$,fromAsci,toAsci,n+1,ammount)
endif
endfunction r$
fubarpk
https://fubarpk.itch.io/