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.

Newcomers DBPro Corner / saving objects on a grid to a file - How is this done?

Author
Message
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 30th Nov 2003 04:39
I am at a road block with this one, I can't seem to figure out how this would be done.

Basically I have an 8x11 grid. Each grid block can contain 5 different blocks. These blocks are used for a break-out style game. I have successfully made a nice editor! =D It is cool looking and easy to use. but the darndest thing is I can't figure out how to save GridX x GridY's information.

Lets Say location 4x7 contains a red block, how do you save to a file stating that 4 over and 7 down has a red block on this grid which is 24 pixels down and 64 pixels wide (per grid)
hmmmmmm... I'm trying to figure this out, its a toughy.

anyone know a good way to do this?

repeat arkBASICPro = LearnStatus() :until DarkBASICPro = FullyUnderStood
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 30th Nov 2003 05:01
I figure that whatever block that Grid(x,y) is holding can be assigned an integer.

The problem is, how do I make it know which part of the grid it is remembering. would I need to make an array? but what would the array contain?

like..

DIM Columns(8)
DIM Rows(11)

but how would you know how to combine them?

repeat : DarkBASICPro = LearnStatus() : until DarkBASICPro = FullyUnderStood
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 30th Nov 2003 05:25
I successfully created a string by this line

saveblock$=STR$(GridX)+" "+STR$(GridY)+" "+STR$(selection2)

This will create a string showing How many over, and How many Down and what the selection is.

I'm on to something, but I have to figure out how to save it to a file, and then read it and be able to place it where it needs to go.

repeat : DarkBASICPro = LearnStatus() : until DarkBASICPro = FullyUnderStood
Don Malone
21
Years of Service
User Offline
Joined: 27th Apr 2003
Location: Birmingham, Alabama
Posted: 30th Nov 2003 05:50 Edited at: 30th Nov 2003 05:51
Alot will depend on how your grid will be setup.

1) will it always start at the top left corner? (most likely not)
2) will your bricks all be the same size or will they vary?


I think that saving as an array will be the way to go. In DarkBasic (classic version is what I have) there is a command to save an array and load an array.

Command format is
Save Array <Filename>, <Array Name>(Index Numbers)
and
Load Array <Filename>, <Array Name>(Index Numbers)

Just dimension your array to hold you brick information and that could also include the actual coordinates for each brick on the screen as well as color for each block and any extra info you need.

You can put as much or as little info as you need to place your blocks.

I will apologize because I am making assumptions on how your editor is setup to work and am just assuming the simpliest way.

but those commands will be what you need if you are working from arrays (the best way in my opinion but it is worth what you are paying for it.)

Good luck.

And No I am no expert but am learing like yourself.

Wasting CPU Cycles since the 286 was a hot machine.
Matt McFarland
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location: Cincinnati, OH. USA
Posted: 30th Nov 2003 06:23
wow save array is awesome.

I have posted another topic regarding save array.

thank you for your help!

repeat : DarkBASICPro = LearnStatus() : until DarkBASICPro = FullyUnderStood

Login to post a reply

Server time is: 2024-09-21 11:55:44
Your offset time is: 2024-09-21 11:55:44