Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / I need to save the players positions..how?

Author
Message
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Aug 2005 12:38
all i want is that everytime you click shift it saves my players positions to a file, like pos.txt or something, and i cant seem to do it, everytime i try it it says "File not open" r "file already open", any help? thanks

Your signature has been erased by a mod because it's larger than 600x120...
Drew Cameron
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: Scotland
Posted: 3rd Aug 2005 13:55 Edited at: 3rd Aug 2005 13:56
Use this code, where 1 is your players object number.

In your loading code:


To save:


To load:


Hope that helps, adjust as needed


Katie Holmes does not endorse D&C or Drew Cameron.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Aug 2005 14:41
heheh, thanks, that works, but its not really what i wanted, i wanted to save the players position, so that i can place coins here and there, without having to write down coords all the time, just click and save, then the next time i load it the coins would all be placed there

Your signature has been erased by a mod because it's larger than 600x120...
Computer Nerd
20
Years of Service
User Offline
Joined: 25th Jan 2005
Location: What do you care?
Posted: 3rd Aug 2005 15:21
I need help with that stuff too apparently.
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 3rd Aug 2005 15:34
Zotoaster,
I think you need a map editor to do that. You can either program one yourself or there are several around which are free.

A map editor will allow you to position objects on a matrix and save the objects position without using the position object objid,x,y,z.

hope this helps.
Jozers
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Aug 2005 15:41
man, theres no point, all i want is:

when you press shift it writes your positions to a file
next time you play you read these positions to each coin

Your signature has been erased by a mod because it's larger than 600x120...
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 3rd Aug 2005 22:04 Edited at: 3rd Aug 2005 22:08
Use this, I'm working on that for my Slayer: Battle Tanks 2 game as well:

All right. That is saying that the "pos.txt" file is the file you want to save to. This is also assuming that the player is object 1. I hope this helps, and I know this works, I'm using it for my game.

If you want to load the file and position the object at the spot he last was at, use this:


There you go, enjoy and change how you like.

--------------------------------------
Vote for Excelsis on the Puzzle Game Compo

__________________________________________
<<<<<Check out my sites>>>>>
www.rhettgames.tk | www.slayerbattletanks.tk
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 3rd Aug 2005 23:13
Look here:

http://forum.thegamecreators.com/?m=forum_view&t=54642&b=10

If you still need help then just ask.

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Aug 2005 15:42
hmm, can i do that in the main loop?

Your signature has been erased by a mod because it's larger than 600x120...
Colonel Cool
19
Years of Service
User Offline
Joined: 3rd Aug 2005
Location: Somewhere
Posted: 4th Aug 2005 21:03
First Post!
I am working on a map editor now anybody want it when it's done?
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 5th Aug 2005 01:47
what does this have to do with my thread? get your own thread..

In other news:

Come on people! Once I've got this bit done my first level in my game will be COMPLETE! HAHA
Please Help! I suck with directory stuff

Your signature has been erased by a mod because it's larger than 600x120...
master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 5th Aug 2005 04:53
I have no idea about the loops with UnderWorld's deal he's got going. If you use mine, you can put this in the loop:


And use this if you want to reload positions:

I know that isn't the same as Underworld's but it works too.


__________________________________________
<<<<<Check out my sites>>>>>
www.rhettgames.tk | www.slayerbattletanks.tk
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th Aug 2005 00:48
yeah, i know that only saves one position, though i worked out how to do it now, i did save array and it worked

Your signature has been erased by a mod because it's larger than 600x120...
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Aug 2005 01:05
Zotoaster

Be careful using Save Array as it can be very finicky when trying to load the data back in! I hope you've been lucky enough so far to not come across the problems yet.

I found it a lot easier to save data out to text files by using Open File to Write and then writing all the data our with Write String. (You can use Str$() to convert numeric values to strings when you write the data).

Loading, you do the reverse using VAL() to turn the strings back into numeric variables.

Using this method, the big advantage is the ability to look at the data file you create using Notepad to look for problems when things don't go to plan.

TDK_Man
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 6th Aug 2005 01:16
hmm, good idea, and yeah i got lucky , from now ill do it your way

Your signature has been erased by a mod because it's larger than 600x120...

Login to post a reply

Server time is: 2025-05-22 13:44:28
Your offset time is: 2025-05-22 13:44:28