// Project: loadsubimage // Created: 2023-04-16 // code by virtual nomad // show all errors SetErrorMode(2) // set window properties SetWindowSize(800,600, 0 ) SetWindowAllowResize( 1 ) // allow the user to resize the window // set display properties SetVirtualResolution( 800,600) // doesn't have to match the window SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetSyncRate( 60, 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 Texture = LoadImage("Explosion03.png") GLOBAL Frame, Duration#, LastFrame#, Boom as Integer [] Frame = 0 Duration# = 0.05 For x = 0 to 15 Boom.Insert(LoadSubImage(Texture, "img_"+STR(x))) Next x Plane = CreateObjectPlane( 10.0, 10.0 ) SetObjectImage( Plane, Boom[Frame], 0 ) SetObjectTransparency( Plane, 1 ) SetCameraRotation( 1, 0.0, 0.0, 0.0 ) SetCameraPosition( 1, 0.0, 0.0, -15.0 ) Do If LastFrame# + Duration# <= Timer() INC Frame : If Frame > Boom.Length then Frame = 0 SetObjectImage( Plane, Boom[Frame], 0 ) LastFrame# = Timer() EndIf Sync() loop
// Project: create subimage file // Created: 2023-04-16 // by blendman // show all errors SetErrorMode(2) // set window properties SetWindowSize(800,600, 0 ) SetWindowAllowResize( 1 ) // allow the user to resize the window // set display properties SetVirtualResolution( 800,600) // doesn't have to match the window SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetSyncRate( 60, 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 SaveSubImagetext("","",0,0) Function SaveSubImagetext(saveFilename$, imageFilename$, Col, row) If imageFilename$="" imageFilename$ = ChooseRawFile("*.jpg;*.png", 1) EndIf If imageFilename$="" Message("No image selected") Else imageFilename$ = "raw:"+imageFilename$ If col<=0 col = 4 EndIf If row <= 0 row = 4 EndIf nbimg = col * row if GetFileExists(imageFilename$) = 0 message(imageFilename$) end endif LoadImage(1, imageFilename$) If GetImageExists(1) imgw = getImageWidth(1) imgh = getImageHeight(1) w = imgw/Col h = imgh/row a=-1 b=0 For i=0 To nbimg-1 inc a If a> col-1 a=0 inc b EndIf txt$ =txt$ + "img_"+Str(i)+":"+Str(a*w)+":"+Str(b*h)+":"+Str(w)+":"+Str(w)+":" +Chr(13) Next If saveFilename$ = "" ext$ = "." +GetExtensionFile(imageFilename$) saveFilename$ = ReplaceString(imageFilename$, ext$, "",1)+" subimages.txt" EndIf DeleteImage(1) OpenToWrite(1, saveFilename$) WriteLine(1, txt$) CloseFile(1) EndIf EndIf end Endfunction Function GetExtensionFile(file$) count = FindStringCount(file$, "/" ) file$ = GetStringToken(file$, "/", count+1) ext$ = GetStringToken(file$,".",2) EndFunction ext$