Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Map editor snags and snares
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  SS NewsMaker 1.3 Post :: Post Greenland Lvz Editor  View next topic  
Author Message
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Thu Nov 20, 2003 4:02 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sat Nov 22, 2003 10:40 pm    Post subject: JInternalFrames Reply to topic Reply with quote

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 39 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Nov 23, 2003 12:04 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Nov 24, 2003 11:37 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Nov 25, 2003 7:19 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Tue Nov 25, 2003 11:55 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Goldeye
Novice


Gender:Gender:Male
Joined: Dec 15 2003
Posts: 57
Offline

PostPosted: Mon Dec 15, 2003 10:55 pm    Post subject: Reply to topic Reply with quote

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.
Code: Show/Hide

//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
View users profile Send private message Add User to Ignore List Send email
50% Packetloss
Server Help Squatter


Age:39
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Tue Dec 16, 2003 1:50 am    Post subject: Reply to topic Reply with quote

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):

Code: Show/Hide
#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
View users profile Send private message Add User to Ignore List Send email AIM Address
nintendo64
Seasoned Helper


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 104
Location: Dominican Republic
Offline

PostPosted: Thu Dec 18, 2003 10:54 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Goldeye
Novice


Gender:Gender:Male
Joined: Dec 15 2003
Posts: 57
Offline

PostPosted: Mon Dec 22, 2003 2:21 am    Post subject: Reply to topic Reply with quote

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. icon_sad.gif 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
View users profile Send private message Add User to Ignore List Send email
2dragons
Novice


Joined: Feb 17 2004
Posts: 95
Offline

PostPosted: Wed Feb 25, 2004 1:33 am    Post subject: Reply to topic Reply with quote

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 51 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Feb 25, 2004 1:58 am    Post subject: Reply to topic Reply with quote

WARNING: DO NOT WRITE CODE LIKE MGB
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Wed Feb 25, 2004 10:47 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Send email
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Wed Feb 25, 2004 11:25 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
cyph
Guest


Offline

PostPosted: Wed Feb 25, 2004 2:29 pm    Post subject: Reply to topic Reply with quote

ugg, just some minor technicalities lol... icon_smile.gif
Back to top
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Fri Apr 23, 2004 8:28 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sat Apr 24, 2004 2:09 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sat Apr 24, 2004 10:39 am    Post subject: Reply to topic Reply with quote

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 icon_biggrin.gif
_________________
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
View users profile Send private message Add User to Ignore List Visit posters website
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sat Apr 24, 2004 10:47 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sat Apr 24, 2004 1:45 pm    Post subject: Reply to topic Reply with quote

perhaps i can make my situation more clear:

reading the attached map with the following code:

Code: Show/Hide
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 30 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat Apr 24, 2004 3:45 pm    Post subject: Reply to topic Reply with quote

Something is seriously wrong. Tile coords are stored in row order in the lvl file, and the coords go from 0,0 to 1023,1023. Your code for picking out the bit fields is wrong. I wouldn't use the mechanism you are using. You are asking for trouble. Read your map data into an unsigned long...

Code: Show/Hide
unsigned long data;

x = data & 0x03ff;
y = (data >> 12) & 0x03ff;
tile = data >> 24;


No new/delete. No messing with bytes.
Back to top
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sat Apr 24, 2004 4:31 pm    Post subject: Reply to topic Reply with quote

did i mention that this is Java code? it is a java map editor...
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sat Apr 24, 2004 4:36 pm    Post subject: Reply to topic Reply with quote

Well, your byte handling is incorrect, and possibly makes a false assumption, although I don't know java. In C, if you shift a byte, the result is a byte, so...

Code: Show/Hide
BYTE a;
int b;

a = 0xff;
b = a << 8;


b = 0


Doesn't java have an unsigned 32-bit type?
Back to top
View users profile Send private message Add User to Ignore List
Helicon
Server Help Squatter


Joined: Dec 03 2002
Posts: 771
Location: GNU Doldrums
Offline

PostPosted: Sat Apr 24, 2004 4:44 pm    Post subject: Reply to topic Reply with quote

Mr Ekted wrote:
Doesn't java have an unsigned 32-bit type?

no they are all signed except the 16bit char
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun Apr 25, 2004 11:10 am    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Misc User Apps All times are GMT - 5 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 643 page(s) served in previous 5 minutes.

phpBB Created this page in 0.702154 seconds : 52 queries executed (83.6%): GZIP compression disabled