Thanks for the feedback. I use the "ThisImg = LoadImage("this.png") along with CreateSprite(ThisImg)" to build the map as it is more efficient. I think the slow down is occurring because from what I was able to dig up. AppGameKit keeps a "List" of loaded sprites and on each passthrough it goes through those list to see if the sprite has to have special properties, adjust positions, animations, etc. which seams to waste processing time.
I built a method that tracks the center of the screen and if the center crosses a certain threshold, all the sprites become unloaded and then gets reloaded based on the position of the crossed threshold. (the map data stays loaded in memory) It seems to work as I was able to load up 100,000 sprites and maintain over 3000 fps.
Unfortunately, I encountered a bug where playing sprites become out of sync causing them to be played at incorrect intervals (so when a cull occurs, if an animation was on frame 3 of 5, it jumps back to 1 and this is very noticeable). For this, I plan to create "Parent" sprites that stay loaded in at all times and playing but not visible and manually set the other sprites with animations with SetSpriteFrame based on the parent its related to.
function Update_World_Culling()
//Get Center of screen
MidScreenX# = GetGridX(GetViewOffsetX() + (Config_ResolutionWidth / 2),Config_GameScale, Config_GridSize)
MidScreenY# = GetGridY(GetViewOffsetY() + (Config_ResolutionHeight / 2),Config_GameScale, Config_GridSize)
//Calculate bounds
MidScreenX# = MidScreenX# / Config_DrawDistance[1]
MidScreenY# = MidScreenY# / Config_DrawDistance[1]
//Set flags if bounds are crossed
If MidScreenX# = round(MidScreenX#) and Config_DrawDistance[2] = 0
Config_DrawDistance[2] = 1
Update_Viewport = 1
endif
If MidScreenX# <> round(MidScreenX#) then Config_DrawDistance[2] = 0
If MidScreenY# = round(MidScreenY#) and Config_DrawDistance[3] = 0
Config_DrawDistance[3] = 1
Update_Viewport = 1
endif
If MidScreenY# <> round(MidScreenY#) then Config_DrawDistance[3] = 0
If Update_Viewport = 1
//Unload current sprites from world
For i = 1 to Map.STile_ID.length
DeleteSprite(Map.STile_ID[i])
next i
Map.STile_ID.length = 0
//Reload sprites to viewport
MinGX = (round(MidScreenX#) * Config_DrawDistance[1]) - Config_DrawDistance[1] //- 40
MinGY = (round(MidScreenY#) * Config_DrawDistance[1]) - Config_DrawDistance[1] //- 40
MaxGX = (round(MidScreenX#) * Config_DrawDistance[1]) + Config_DrawDistance[1] //+ 40
MaxGY = (round(MidScreenY#) * Config_DrawDistance[1]) + Config_DrawDistance[1] //+ 40
for i = 1 to Map.STiles_DATA_INDEX.length
If Map.STiles_DATA_GX[i] >= MinGX AND Map.STiles_DATA_GX[i] <= MaxGX
If Map.STiles_DATA_GY[i] >= MinGY AND Map.STiles_DATA_GY[i] <= MaxGY
Make_Sprite = CreateSprite(Asset.STiles[Map.STiles_DATA_INDEX[i]])
Map.STile_ID.Insert(Make_Sprite)
SetSpriteScale(Map.STile_ID[Map.STile_ID.length], Config_GameScale, Config_GameScale)
SetSpriteDepth(Map.STile_ID[Map.STile_ID.length], Config_TilesetDepth + 1 - Map.STiles_DATA_DEPTH[i])
SetSpritePosition(Map.STile_ID[Map.STile_ID.length], GetPixelGridX(Map.STiles_DATA_GX[i], Config_GameScale, Config_GridSize), GetPixelGridY(Map.STiles_DATA_GY[i], Config_GameScale, Config_GridSize))
EndIf
EndIf
next i
EndIf
endfunction