Flaming Ghost,
You should place objects' positions for each level within some .dat file(s) or as data within your program. When it is time to go to another level, simply read the information from the file, in a certain sequential order that you have placed the information in, and re-position the objects using the values read.
Down below is a code snippet for you which reads a .dat file and draws boxes on the screen according to the values read. Then, the
repeat until loop continues until the spacekey is pressed, and it then reads the file again, and all over again. Also, below the first code snippet is another code snippet which is .dat file values I made which includes x and y positions.
(Copy and paste this information into a text editor and save it as a .dat file named changelevel.dat. Save both the .dba and .dat files in one folder together.)
The first box's x position being the first line in the file, the second line being it's y position and the next lines for the rest of the boxes. There are two levels of data within the .dat file, which includes twenty lines of values each, giving a total of fourty lines of values. There are two lines of values for each box in each level, and there are ten boxes per level.
The code
set display mode 800,600,32
sync on
sync rate 60
dim positions$(10,2)
REM << open file to read
open to read 1,"changelevel.dat"
level = 1
getcoords_drawboxes(level)
REM ============== main loop ================
repeat
REM << go to next level if spacebar is pressed(if the ball falls in the hole)
if spacekey() = 1
inc level
REM << close and then re-open dat file to reset reading cursor
if level = 3
close file 1
open to read 1,"changelevel.dat"
level = 1
endif
cls
wait 1000
getcoords_drawboxes(level)
endif
sync
until mouseclick() = 2
close file 1
end
REM ============ functions ================
function getcoords_drawboxes(level)
REM << get position integer values from .dat file
for t = 1 to 10
for u = 1 to 2
read string 1,positions$(t,u)
next u
next t
REM << draw boxes to screen at read coordinates
for t = 1 to 10
box val(positions$(t,1)),val(positions$(t,2)),val(positions$(t,1)) + 10,val(positions$(t,2)) + 10
next t
text 0,45,positions$(1,1)
text 0,0,"press spacekey to changelevel(as is the ball falls in the hole)"
text 0,15,"press right mouse button to exit, not F12 or ESCAPE"
text 0,30,"Level " + str$(level)
endfunction
The .dat file values
100
300
100
500
200
200
300
400
400
300
500
100
500
400
600
100
600
500
700
300
100
100
100
200
300
200
300
500
400
100
400
300
500
400
600
200
600
400
700
300

+NanoBrain+