473,624 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binary "Database" for a game - please help

Hello and thanks in advance to anyone who offers help.

To make this simple, let's say I have a game which has 100 different
monsters. I want a binary data file to hold all of these. It would
have the index number of the mob, name, size, attributes, etc. I can
easily create an editor to edit the records in this file, as soon as
I know how to create this file and be able to find a specific monster
in the file and fill, say, text boxes full of the information
regarding that specific monster.

I hope I am writing this in a way that you can understand fully what I
mean. Let's say I have a data file full of monsters, and the one I
want to know about is in the middle of the file, say record number
33. I want to be able have my program look for the monster named
"Dragon" and then retrieve all information that goes with that
monster.

I was able to do this easily in VB6. I even made an editor that could
go through the different monsters, with their information populating
text boxes as I browsed through them. but for the life of me I
can't figure out how to do this in C#. I know how to read and write
binary files, but that's about it.

So, to my question. How could I do this? I want all records in a
single binary file and the ability to locate specific ones and get
their info.

Thanks in advance. I apologize for the book I wrote. I just wanted
to make sure it was clear what I was looking for.

Daedric
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #1
4 1699
Daedric <ac****@comca st-dot-net.no-spam.invalid> wrote:
Hello and thanks in advance to anyone who offers help.

To make this simple, let's say I have a game which has 100 different
monsters. I want a binary data file to hold all of these. It would
have the index number of the mob, name, size, attributes, etc. I can
easily create an editor to edit the records in this file, as soon as
I know how to create this file and be able to find a specific monster
in the file and fill, say, text boxes full of the information
regarding that specific monster.

I hope I am writing this in a way that you can understand fully what I
mean. Let's say I have a data file full of monsters, and the one I
want to know about is in the middle of the file, say record number
33. I want to be able have my program look for the monster named
"Dragon" and then retrieve all information that goes with that
monster.

I was able to do this easily in VB6. I even made an editor that could
go through the different monsters, with their information populating
text boxes as I browsed through them. but for the life of me I
can't figure out how to do this in C#. I know how to read and write
binary files, but that's about it.


It sounds like you really should be separating the concerns of storage
from editing. You can store the details however you like, so long as
you can load them and save them. Load them into a collection of some
description, and then you can edit them, then save them. Unless you
think the file's going to get *really* big, I wouldn't worry about the
hit of loading the whole thing even if you only want access to one
monster.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
It is even easier in C#. Just create a Hashtable of monster objects and
serialize them to a file.

http://www.geocities.com/jeff_louie/OOP/oop22.htm

private bool Serialize(strin g pathToFile)
{
Stream outStream= null;
// returns false if pathToFile is null
if (!File.Exists(p athToFile)) {return false;}
outStream = File.OpenWrite( pathToFile);
if(outStream == null){return false;}
// Code to write the stream goes here.
try
{
BinaryFormatter formatter = new BinaryFormatter ();
formatter.Seria lize(outStream, serilizationVer sion);
formatter.Seria lize(outStream, monstersHash);
return true;
}
catch (Exception e)
{
System.Console. WriteLine(e);
return false;
}
finally
{
outStream.Close ();
}
}

Regards,
Jeff
So, to my question. How could I do this? I want all records in a single
binary file and the ability to locate specific ones and get their info.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Now, if we're talking about a lot of monsters... maybe you can't hold
all of them in memory at one time.

In that case I think you have two options:
use a database (MySql, for instance, but if you have the money you can
look at SqlServer, or Oracle), or
make your own 'database', as you describe. If you do that, though, I
suggest you look up B-Trees and such things, since, with large set of
records, a linear file such as you describe will result in slow
performance.

HTH,
F.O.R.

Nov 16 '05 #4
Sounds like MS Access be a perfect fit. It not only does a good job of
storing and indexing information, but provides forms to edit the
information. However, if this is some sort of school project and must be
done in C#, then you can still use Access database via ADO.NET and C# as the
front end.

"Daedric" <ac****@comca st-dot-net.no-spam.invalid> wrote in message
news:42******** @127.0.0.1...
Hello and thanks in advance to anyone who offers help.

To make this simple, let's say I have a game which has 100 different
monsters. I want a binary data file to hold all of these. It would
have the index number of the mob, name, size, attributes, etc. I can
easily create an editor to edit the records in this file, as soon as
I know how to create this file and be able to find a specific monster
in the file and fill, say, text boxes full of the information
regarding that specific monster.

I hope I am writing this in a way that you can understand fully what I
mean. Let's say I have a data file full of monsters, and the one I
want to know about is in the middle of the file, say record number
33. I want to be able have my program look for the monster named
"Dragon" and then retrieve all information that goes with that
monster.

I was able to do this easily in VB6. I even made an editor that could
go through the different monsters, with their information populating
text boxes as I browsed through them. but for the life of me I
can't figure out how to do this in C#. I know how to read and write
binary files, but that's about it.

So, to my question. How could I do this? I want all records in a
single binary file and the ability to locate specific ones and get
their info.

Thanks in advance. I apologize for the book I wrote. I just wanted
to make sure it was clear what I was looking for.

Daedric
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2186
by: Yasso Picasso | last post by:
Greetings, I have to admit that I'm still a beginner in the database field, but I'm actively studying, and this is why I will be utterly grateful for the proper, accurate, and wise guidance to the right direction or specific paths of database studies. I simply want to make my first major database project a "personal knowledge database" or a "personal encyclopedia", so to speak. By this I mean that I want to gather diverse,...
1
8068
by: Kenjis Kaan | last post by:
I had to run DB2 on Win2k. After installation it puts a directory under c:\DB2 and c:\DB2Log and C:\Program Files\SQLLIB Now am all confused which is instance home, db2 home etc. I had to configure tivoli inventory and its all *@#$ up because of this confusion. Can someone please clarify which is which? TIA c:\DB2>wgetrim invdh_1 RIM Host: user88 RDBMS User: user881 RDBMS Vendor: DB2
0
1399
by: David P. Donahue | last post by:
I'm using C# to create an ASP .NET website backed by a MySQL database. One of the things I do often on the site is populate a DataList by binding it to a DataSet pulled from the database. However, I'm running into a bit of a problem with a specific field type in the database. It seems that fields of type TEXT (a kind of binary way of storing large amounts of text) generate the error "Unknown Target Conversion Type" when I try to bind...
8
1834
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
1
2906
by: Pedro Leite | last post by:
hello. got stalled at at point that i can no longer get my thoughts together. the point, is in classic asp, stream an excel file from a firebird database. temporarly save it if necessary stream it to the browser delete the temp file on googling, i found some examples but all assuming that the file is locally
0
4393
by: serge | last post by:
I have 2 SQL Enterprise Editions running SP2 and same collation. When i try to start database mirroring I get the following error message: "The remote copy of database "ABC" has not been rolled forward to a point in time that is emcompassed in the local copy of the database log. (Microsoft SQL Server, Error: 1412)" Both SQL Server services are running under account
2
2699
by: alberto | last post by:
I am Very new to .net but have experience with C++ and other languages. Can somebody point me to a "hello world" database program? Create one table (managed to do that with an .mdf database file and designed a simple table) and fill it up through a datagrid from scratch. I do not want to download the northwind database and the dvds program is not much help. thanks Alberto
0
4246
by: vaibhavsumant | last post by:
<project name="DBCreate" default="usage" basedir="."> <property name="user" value="db2admin"/> <property name="passwd" value="db2admin"/> <property name="dbprefix" value=""/> <property name="driver" value="COM.ibm.db2.jdbc.app.DB2Driver"/> <property name="starturl" value="jdbc:db2:temp"/> <property name="db2dir" location="${basedir}/../../../../.." /> <target name="CreateTestData" > <echo message="in mydbs db2dir = ${db2dir}" />
2
2362
by: elgin | last post by:
I have a split Access 2003 database. I have signed the database with a Code Signing Certificate from Small Business Server. This works fine and users can have Access macro security on high or medium and do not get prompted at startup. The problem comes because there are two of us modifying the code. Whenever either one of us changes the code, one of us must resign both the front and back end of the database. If we forget to sign both, we...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.