Hello
It is explained in tutorial no. 6:
in level00.gbas the objects manually. But in a completed game are much more required, and it would be very laborious to call every single object separatly.
Therefore we read out the datas from a predefined file level00.evt. For this we must expand our existing event-type (TEvent).
IX% = 0
ID%[256]
Pos%[256]
X%[256]
Y%[256]
IX is a pointer to the actual listentry, ID is the objectID, Pos is the scrollposition WHEN the object shall appear and X,Y the position WERE the object shall appear.
With
// init events
OPENFILE(1,"./isdo/level00.evt",TRUE)
FOR p=0 TO 254
READUWORD 1,val
Event.Pos[p]=val
NEXT
FOR p=0 TO 254
READUWORD 1,val
Event.ID[p]=val
NEXT
FOR p=0 TO 254
READUWORD 1,val
Event.X[p]=val
NEXT
FOR p=0 TO 254
READUWORD 1,val
Event.Y[p]=val
NEXT
in level00.gbas we load these datas into our eventlist. The request when a object shall appear, we do in the subroutine EventHANDLER in library.gbas.
//=============================================================================
SUB EventHANDLER:
//=============================================================================
LOCAL ix%,typ%
ix=Event.IX
IF ScrollX=Event.Pos[ix]
SELECT Event.ID[ix]
CASE ID_ENEMY1 TO ID_ENEMY2
ObjectADD(Event.ID[ix],Event.X[ix],Event.Y[ix])
ENDSELECT
INC Event.IX,1
ENDIF
ENDSUB // EventHANDLER
First we request the current index in the eventlist, then we check the type and add the corresponding object to the scene. The rest goes as if by magic.
Today or tomorrow i will upload a simple eventeditor
