Skip to content

Scene Group Arrays to Type

This will grab each sprite from a group array in AGK Studio and create a new type for each instance.

// Project: Zoikoids
// Created: 19-04-07
 
// show all errors
SetErrorMode(2)
 
// set window properties
SetWindowTitle("Zoikoids")
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(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)
 
#insert "game.scene"
game_setup()
 
img_Ligher = LoadImage( "Ligher.png" )
global player as integer
global playerx as float
global playery as float
 
playerx = GetVirtualWidth() / 2
playery = GetVirtualHeight() - GetImageHeight(img_Ligher) - 64
player = CreateSprite(img_Ligher)
SetSpriteAnimation(player, 32, 32, 4)
SetSpriteScale(player, 2, 2)
playsprite(player)
 
type Zoik
    id as integer
    x as float
    y as float
endtype
global ZoikList as Zoik[]
 
for x = game_Zoikoids.length to 0 step -1
    local z as zoik
    z.id = CreateSprite(GetSpriteImageID(game_Zoikoids[x]))
    SetSpriteScale(z.id, 2, 2)
    z.x = GetSpriteX(game_Zoikoids[x])
    z.y = GetSpriteY(game_Zoikoids[x])
    ZoikList.insert(z)
next
 
for x = game_Zoikoids.length to 0 step -1
    DeleteSprite(game_Zoikoids[x])
next
game_Zoikoids.length = -1
 
 
for x = ZoikList.length to 0 step -1
    SetSpritePosition(Zoiklist[x].id, ZoikList[x].x, ZoikList[x].y)
next
 
 
 
do
 
     
    setspriteposition(player, playerx, playery)
    game_sync()
    Print(ScreenFPS())
    Sync()
loop