Thanks Guys for the Help.
This is what I want to do for a little game for my grandson.
I've change the text to sprites from a Sprite Sheet with a Data Txt file
Might be usefull for some sort of game template.
And the Random function is really useful.
// Project: RandomLetters
// Created: 2018-06-27
// show all errors
SetErrorMode(2)
global AlphabetID as integer = 1
loadimage(AlphabetID,"alphabet_letters.png")
// set window properties
SetWindowTitle( "RandomLetters" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1280, 720 ) // doesn't have to match the window
SetOrientationAllowed( 0, 0 , 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( 2 ) // since version 2.0.22 we can use nicer default fonts
SetClearColor (255, 200, 100 )
// Setting a grid of locations
global xGrid as integer[8]
xGrid[1]=40
xGrid[2]=190
xGrid[3]=340
xGrid[4]=490
xGrid[5]=640
xGrid[6]=790
xGrid[7]=940
xGrid[8]=1090
global yGrid as integer[4] // sets the y grid values
yGrid[0] = 35
yGrid[1] = 170
yGrid[2] = 300
yGrid[3] = 450
global imgid as integer[26]
// generate the first one
GenerateRandomAlphabet()
do
// Check if space is pressed - if so generate a new set
if GetRawKeyPressed(32) then GenerateRandomAlphabet()
//Print( ScreenFPS() )
Sync()
loop
function GenerateRandomAlphabet()
For i=1 to 26 // one index for each letter of the alphabet
imgid[i]=100+i
// Create the text
if GetSpriteExists(imgid[i]) = 0
//loadimage(imgid[i],mid("abcdefghijklmnopqrstuvwxyz",i,1)+".png")
loadsubimage(imgid[i],AlphabetID,mid("abcdefghijklmnopqrstuvwxyz",i,1)+".png")
//CreateText(i,chr(i+64))
createsprite(imgid[i],imgid[i])
endif
repeat // repeat until we geta unique unsued position
// Get the x and y positions
xpos= xGrid[Random2(1,8)]
ypos= yGrid[Random2(0,3)]
// Check if there is already a latter at that position
until CheckPositionIsUnique(xpos,ypos,i) = 0
//until 1
SetSpritePosition(imgid[i],xpos,ypos)
Next i
endfunction
// This function
function CheckPositionIsUnique(xpos,ypos,i)
for c=1 to i
if GetSpriteX(c+100) = xpos and GetSpriteY(c+100) = ypos then exitfunction 1
next c
endfunction 0