Quote: "I am pretty sure it can't be done with media since that is physical stuff, images, textures ect... but your save game data is just that data, strings and numbers. Character names, locations, stats, items, magic etc so why can't this stuff be stored within the game as a game save then be loaded back when the player wants to play again?"
Technically, all the data (Character names, locations, stats, etc.) is also "physical" stuff. Models, images, and textures are data just like a save file. DBP just knows what to do with an image when loaded. It's got a specific "array" that it stores all the information of the image into internally so that it can be used by other DBP functions.
An image's data structure could be set up such as:
ImageWidth;
ImageHeight;
pixel color(0,0);
pixel color(1,0);
pixel color(2,0);
color pixel(3,0);
etc.
Which would be stored in an array such as imageArray(ImageWidth, ImageHeight)
Sample psuedo code:
read "MyImage.png", ImageWidth
read "MyImage.png", ImageHeight
dim imageArray(ImageWidth, ImageHeight)
for y = 0 to ImageHeight
for x = 0 to ImageWidth
read "MyImage.png", imageArray(x, y)
next x
next y
A model's data structure could be:
VertexCount;
Triangle(1).Point.x#;
Triangle(1).Point.y#;
Triangle(1).Point.z#;
Triangle(1).Normal.x#;
Triangle(1).Normal.y#;
Triangle(1).Normal.z#;
Triangle(1).Point.U;
Triangle(1).Point.V;
Triangle(2).Point.x#;
Triangle(2).Point.y#;
Triangle(2).Point.z#;
Triangle(2).Normal.x#;
Triangle(2).Normal.y#;
Triangle(2).Normal.z#;
Triangle(2).Point.U;
Triangle(2).Point.V;
Triangle(3).Point.x#;
Triangle(3).Point.y#;
Triangle(3).Point.z#;
Triangle(3).Normal.x#;
Triangle(3).Normal.y#;
Triangle(3).Normal.z#;
Triangle(3).Point.U;
Triangle(3).Point.V;
etc.
Which would be stored in an array such as modelArray(VertexCount)
Sample psuedo code:
type vector2Type
x# as float
y# as float
endtype
type vector3Type
x# as float
y# as float
z# as flaot
endtype
type myModelType
pos# as vector3Type
nor# as vector3Type
uv# as vector2Type
read "MyModel.x", vertexCount
dim modelArray(vertexCount) as myModelType
for i = 0 to ImageHeight
read "MyModel.x", modelArray(i).pos.x#
read "MyModel.x", modelArray(i).pos.y#
read "MyModel.x", modelArray(i).pos.z#
read "MyModel.x", modelArray(i).nor.x#
read "MyModel.x", modelArray(i).nor.y#
read "MyModel.x", modelArray(i).nor.z#
read "MyModel.x", modelArray(i).uv.x#
read "MyModel.x", modelArray(i).uv.y#
next i
(This is
not the exact data format for an existing 3d model or image type [does not include image bitdepth, limb names, etc.], but it should get the idea across. Look into memblocks if you are interested in file structure. Although it can seem extremely abstract, it will get you a better idea of how data is stored and then opened into memory for use by your application.)
A save game data structure could be:
PlayerLastX#;
PlayerLastY#;
PlayerLastZ#;
PlayerGold;
PlayerIntelligence;
PlayerStrength;
PlayerLevel;
PlayerExperience;
etc.
Once the program is compiled, you will not be able to apply any internal changes to variables. (I mean, I guess you could with a hex editor or something, but that seems impractical) You will want to do this with an external file loaded. If you don't read/write to an external file, you will be stuck using static variables for everything in the game. You will need to load an external file so that you can fill in all the data for a loaded game with dynamic information.
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.