Author |
Message |
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Thu Nov 20, 2003 4:02 pm Post subject: |
|
|
|
|
i considered that approach, i can't remember now why i split it. I think it had something to do with feeding to the Bitmap class(not mine, given by a friend) a File object. _________________ Signatures just seem so quaint.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Sat Nov 22, 2003 10:40 pm Post subject: JInternalFrames |
|
|
|
|
in the following zip, run the test class.
Nothing appears if i use an instance of MapDocument - which extends JInternalFrame.
Except nothing appears in the desktop pane.
Now change the MapDocument to JInternalFrame in the initialisaion and declaration in Test. Everything will work like a charm....
please see the addDocument(Document) method in class Main to see what the problem is.. i think the problem may be there. either that or i have set something amok with the desktop pane.
Map.zip - 28.07 KB
File downloaded or viewed 43 time(s)
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Sun Nov 23, 2003 12:04 am Post subject: |
|
|
|
|
I will take a look at it tomorow when I get home. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me
|
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Mon Nov 24, 2003 11:37 pm Post subject: |
|
|
|
|
Don't know. I don't have the time at the moment to give it a full debug, but there are plenty of decent tutorials on doing what you want.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Tue Nov 25, 2003 7:19 pm Post subject: |
|
|
|
|
no tutorials... i got it to run. something to do with the order of calls to show it. maybe its my runtimes. in any case, it now ~works~.
Thanks anyway
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Tue Nov 25, 2003 11:55 pm Post subject: |
|
|
|
|
about imageio, i did some tests. it hits jpeg, png, gif well, but i havent had success loading and g.drawImage() with bitmaps... i don't suppose you'd all mind moving to png though would you?
oh and a minor correction.. i did some more tests with graphics painting (benchmark-ish) and it turns out my test implementations from before hand were nothing like the actual situation will call for (assuming i'm not wrong again). Hope returns... java performance, talley-ho!!!
|
|
Back to top |
|
|
Goldeye Novice
Gender: Joined: Dec 15 2003 Posts: 57 Offline
|
Posted: Mon Dec 15, 2003 10:55 pm Post subject: |
|
|
|
|
I'm working on a C# map editor. Goals are to include the basic lvl stuff, and a nice little environment for lvz. Maybe even throw a set editor on top for fun.
I'm using DirectDraw for it, makes sense to anyway since its what Cont uses..
So far my problems have been in things about forms.. Anyone know how I would make a fixed tool window that stays on top when you are in the main window, but doesn't take focus from the main window (tileset) I have to close the tileset or the close button is faded out on the main window. I tried having it as an MDI child, and was having some problems, will try it again though.
Heres what I did to check if first two bytes are BM.
//Check if there is a tileset.
byte[] header= new byte[6];
//Open the
System.IO.FileStream lvl = System.IO.File.Open(tileSetPath,FileMode.Open,FileAccess.ReadWrite);
lvl.Read(header,0,6);
//If first two bytes of header != "BM", assume theres no tileset.
if(header[0] != 0x42 || header[1] != 0x4D)
return;
//Reset the FileStream so you can...
lvl.Flush();
//Load the tileset to a bitmap.
tileSetBMP = new Bitmap(lvl);
lvl.Close();
|
Theres a function to change a byte array to a dword(uint32) System.BitConverter.ToUInt32(byte[] value, int startindex), which I'll be using to get the length. But how can you sightread the length off of the 4 bytes after BM?
|
|
Back to top |
|
|
50% Packetloss Server Help Squatter
Age:39 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Tue Dec 16, 2003 1:50 am Post subject: |
|
|
|
|
Hopefully this helps? Its C++ and all Mine GO BOOM's code
Mine GO BOOM wrote: |
Then every 4bytes (or int) you read in, just type it to a struct tilerecord. Example (quick hack, didn't debug/compile):
#pragma pack(1)
struct tilerecord
{
unsigned int x : 12;
unsigned int y : 12;
unsigned int tile : 8;
};
struct lvlheader
{
unsigned short type; /* should be 19778, aka 'B' followed by 'M' */
unsigned int lengh;
};
#pragma pack()
char buff[6];
struct tilerecord *tile = (struct tilerecord*)buff;
struct lvlheader *header = (struct lvlheader*)buff;
/* could use a union, but this is good enough */
FILE *f;
f = fopen(LVLFILENAME, "rb");
if (!f) return 0; /* couldn't open file */
if (fread(buff, 6, 1, f)) /* check to see if has bmp data up front */
{
if (header->type == 19778) /* yep, has the string "BM" up front */
fseek(f, header->length, SEEK_SET); /* skip forward to end of BMP data */
else /* didn't have header up front, means should be tile info */
fseek(f, 0, SEEK_SET); /* rewind to front again */
}
else /* couldn't read 6 bytes, which COULD mean a lvl with only 1 tile, or an empty file */
fseek(f, 0, SEEK_SET);
/* We should now be where the tile info is at */
while (fread(buff, 4, 1, f))
{
/* keep reading until we cannot read 4 bytes anymore */
if (tile->tile == 220) /* check to see if wormhole */
{
/* Do your "found a wormhole" stuff here.
* Remember, it only tells the upper-left corner of a wormhole,
* so the actual area includes the 4x4 box (i think) to the right/down
* of this position.
*/
}
}
fclose(f); |
|
|
|
Back to top |
|
|
nintendo64 Seasoned Helper
Age:38 Gender: Joined: Dec 01 2002 Posts: 104 Location: Dominican Republic Offline
|
Posted: Thu Dec 18, 2003 10:54 am Post subject: |
|
|
|
|
What directx headers are you using?, CTM uses 2 and if you're going to use DirectDraw use DX2 or DX3 ones. I recommend using GDI for the map editor.
-nintendo64
|
|
Back to top |
|
|
Goldeye Novice
Gender: Joined: Dec 15 2003 Posts: 57 Offline
|
Posted: Mon Dec 22, 2003 2:21 am Post subject: |
|
|
|
|
Heh, I was using DX9.. its the only one that microsoft encapsulated into .NET :/ There is no way I'll manage to do the same with any earlier DX using Managed C++ <shudder>. C# is fun because it lets you do everything you want without guessing how many ____'s you need.
As for GDI, I really have no clue how to use it. Then again, I don't have much clue of anything here. What would be the most practical way to load enough tiles at once to do whats needed. After all, I don't wanna deal with 1000000 bitmap objects.. Last time I tried that I ended the process when it was only using 200,000KB of ram.
|
|
Back to top |
|
|
2dragons Novice
Joined: Feb 17 2004 Posts: 95 Offline
|
Posted: Wed Feb 25, 2004 1:33 am Post subject: |
|
|
|
|
I'm actuallly working on a full lvl/lvz editor in java. I've had pretty good success, fairly smooth scrolling considering it is java. I'll include a wrapped jar to exe file if you want a very basic preview.
I'll also include a couple classes I used to read in the map.
* please note it is mostly a quick hack but hopefully the code can help you along your way.
I'm sure you can probably rip the jar out of the exe. But I'll probably give anyone the source once I get it more complete.
Editor.exe
LevelFile.java
ByteArray.java
Editor.zip - 39.45 KB
File downloaded or viewed 52 time(s)
|
|
Back to top |
|
|
Mr Ekted Movie Geek
Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Wed Feb 25, 2004 1:58 am Post subject: |
|
|
|
|
WARNING: DO NOT WRITE CODE LIKE MGB _________________ 4,691 irradiated haggis!
|
|
Back to top |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Wed Feb 25, 2004 10:47 am Post subject: |
|
|
|
|
Mr Ekted wrote: | WARNING: DO NOT WRITE CODE LIKE MGB |
You forgot to bold that, fixed it for you.
Not all my code is bad. And that example above was done by pure memory alone (excluding the structs).
|
|
Back to top |
|
|
Mr Ekted Movie Geek
Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Wed Feb 25, 2004 11:25 am Post subject: |
|
|
|
|
LOL
I'm talking about the layout of the code. It is unreadable. Even if you live with it like that for yourself, take a minute and make it nice before posting.
|
|
Back to top |
|
|
cyph Guest
Offline
|
Posted: Wed Feb 25, 2004 2:29 pm Post subject: |
|
|
|
|
ugg, just some minor technicalities lol...
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Fri Apr 23, 2004 8:28 pm Post subject: |
|
|
|
|
next question, still in the map format:
how would one (in java code) convert from an int containing bits for a signed integer into an int representing the same value but in two's compliment and signed???
|
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat Apr 24, 2004 2:09 am Post subject: |
|
|
|
|
You'll be able to find the length of the BMP portion of the .lvl, by what Dr Brain suggested, checking the BMP format. So the BMP will be substr(0, length determined by reading into the BMP struct-1?) _________________ Performance is often the art of cheating carefully. - James Gosling
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Apr 24, 2004 10:39 am Post subject: |
|
|
|
|
So wait, right now you have a bunch of ints containing either 1 or 0? I have no clue how you got there, but if it is, just left shift each int to the place you want it to go in the final number and add it to a signed sum integer. If it is the bits, then you won't have to worry about 'converting' to two's complement, since it will already be in it. (If the number exceeds 127, it will be negative.)
Nice to see some progress _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Sat Apr 24, 2004 10:47 am Post subject: |
|
|
|
|
the bits are read raw from a file generated by c or c++ code.
unsigend ints are not available in java (all ints and bytes are signed). In addition, casting in java maintains numerical value across types, not bits (two's compliment). hence there is a change in encoding between types. A non-cast mathematical conversion is required. I've nearly got it right, though suggestions are still welcome.
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Sat Apr 24, 2004 1:45 pm Post subject: |
|
|
|
|
perhaps i can make my situation more clear:
reading the attached map with the following code:
byte[] rawInput = new byte[4];
while (fs.read(rawInput) != -1) {
int row = rawInput[0] << 4 + rawInput[1] >> 4;
int col = ((rawInput[1]) << 8) + ((rawInput[2]) & (0xFFF));
System.out.println("Read tile: (" + row + "," + col + ") value: " + rawInput[3]);
}
|
yields
Quote: | Read tile: (0,0) value: 1
Read tile: (65536,4096) value: 1
Read tile: (2,8192) value: 1
Read tile: (196608,12288) value: 1
|
in actuality, the tiles are at
(1,1) (2,2) (3,3) (4,4)
and are all value 1 (0???) - they will need to be converted as well as larger numbers are made negative
i assume that the upperleftmost tile is stored as (1,1) and not (0,0)??
perhaps this makes the need more clear: i need to convert the values of row and col to their signed equivalents, and then back for writing
default.lvl - 0.02 KB
LVL Preview: Full Size - Half Size
File downloaded or viewed 32 time(s)
|
|
Back to top |
|
|
Mr Ekted Movie Geek
Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
Posted: Sat Apr 24, 2004 4:31 pm Post subject: |
|
|
|
|
did i mention that this is Java code? it is a java map editor...
|
|
Back to top |
|
|
Mr Ekted Movie Geek
Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
|
Back to top |
|
|
Helicon Server Help Squatter
Joined: Dec 03 2002 Posts: 771 Location: GNU Doldrums Offline
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sun Apr 25, 2004 11:10 am Post subject: |
|
|
|
|
Does it really matter? Even if the data ends up 'negative' the bits are still what they should be. Therefore, doing bitwise operators on it should have the same result even if it was unsigned. (Using Ekted's method, at least; I don't really understand yours.)
|
|
Back to top |
|
|
|