I've been working on a game maker for quite some time now and I've been experimenting with ways of creating exe's from the main exe. I had one way but it got screwed...so I am using arrays now. Here's how I would *like* the array part to work...
1. User creates their map bu drag-and-dropping their desired boxes.
2. When the user is happy with their map and feels like testing it, they press the "test" button and their game is opened.
3. If the user wants to just go into their program files and click on their game exe without opening the game maker, they can do so.
Array part
4. An array is created with the x coordinates of every object the user has added to the map, and another array is created with the z coordinates of every object the user has added to the map. The y coordinates dont matter at the moment.
5. Then, a savefile is created, and the arrays are saved to it. Then another save file is created and the user's position and other variables are saved to that one. I cant use the same savefile because arrays need to be saved into .arr and variables need to go into .dat...I think.
6. If the user clicks the exe from their program files, the program checks if the savefiles exist. If they do, it loads them and positions everything accordingly, if not it just loads up the game maker..
The only part of all of that that I cant get working is the array part, the objects keep getting located at 0,0,0.
Heres the saving code with the arrays:
IF MOUSECLICK()=1 AND GAMECREATE=0 AND MOUSEX()>=(OBJECT SCREEN X(9000)-(OBJECT SIZE X(9000)/2)-5) AND MOUSEX()<=OBJECT SCREEN X(9000)+(OBJECT SIZE X(9000)/2)+5 AND MOUSEY() >=(OBJECT SCREEN Y(9000)-(OBJECT SIZE Y(9000)/2))-10 AND MOUSEY()<=(OBJECT SCREEN Y(9000)+(OBJECT SIZE Y(9000)/2))+10
SET DIR "C:\Program Files\Dark Basic Software\Dark Basic Professional"
DELETE OBJECT 1000:DELETE OBJECT 2000:DELETE OBJECT 3000:DELETE OBJECT 9000:DELETE OBJECT 10000
GAMECREATE=1
RAYNUM=1
OPEN TO WRITE 1,"gamesave.dat"
WRITE LONG 1,GAMECREATE
OBJ=OBJ#
WRITE LONG 1,OBJ
USRX=OBJECT POSITION X(7000)
USRY=OBJECT POSITION Y(7000)
USRZ=OBJECT POSITION Z(7000)
```````````````````````````````````````````````````````````````````
FOR i = 2 to OBJ# STEP 1
DIM OBJX(OBJ#)
OBJX(RAYNUM)=OBJECT POSITION X(i)
DIM OBJZ(OBJ#)
OBJZ(RAYNUM)=OBJECT POSITION Z(i)
RAYNUM=RAYNUM+1
NEXT i
SAVE ARRAY "C:\Program Files\Dark Basic Software\Dark Basic Professional\arraysave1.arr",OBJX(0)
SAVE ARRAY "C:\Program Files\Dark Basic Software\Dark Basic Professional\arraysave2.arr",OBJZ(0)
````````````````````````````````````````````````````````````````````
MAKE OBJECT SPHERE 500,30
POSITION OBJECT 500,USRX,USRY,USRZ
DELETE OBJECT 7000
And the loading code with the arrays:
IF FILE EXIST ("gamesave.dat")=1
RAYNUM=1
OPEN TO READ 1,"gamesave.dat"
READ LONG 1,GAMECREATE
READ LONG 1,OBJ
OBJ#=OBJ
`````````````````````````````````````````````````````````````````
LOAD ARRAY "C:\Program Files\Dark Basic Software\Dark Basic Professional\arraysave1.arr",OBJX(0)
LOAD ARRAY "C:\Program Files\Dark Basic Software\Dark Basic Professional\arraysave2.arr",OBJZ(0)
FOR i = 2 TO OBJ# STEP 1
MAKE OBJECT BOX i,30,30,30
POSITION OBJECT i,OBJX(RAYNUM),0,OBJZ(RAYNUM)
RAYNUM=RAYNUM+1
NEXT i
````````````````````````````````````````````````````````````````````
READ LONG 1,USRX
READ LONG 1,USRY
READ LONG 1,USRZ
MAKE OBJECT SPHERE 500,30
POSITION OBJECT 500,USRX,USRY,USRZ
DELETE FILE "gamesave.dat"
POSITION CAMERA OBJECT POSITION X(500),OBJECT POSITION Y(500),OBJECT POSITION Z(500)
POINT CAMERA OBJECT POSITION X(500),OBJECT POSITION Y(500),OBJECT POSITION Z(500)
GAMECREATE=1
ENDIF
The part that isnt working is the sections seperated from the...other sections. The sections with the `` around them.
You can ignore all the other code not in the `` area, it works fine. I just need to know why it isn't finding the values in the arrays and doing...what I tell it to. Sorry if the code is really messy I've been adding/removing lots of things to try and get this to work so thats why its all jumbled up.
Thanks for any help in advance,
RUCCUS.
P.S The loading part is before the do/loop and the saving part is in the do/loop.