|
Hi,
I was wrong by talking about short sorry.
by 1 0 0 0 I was meaning 01 00 00 00 = 8 bits = 1 byte.
The values are stored as set of 2 bits (values are between 0 - 3), but the sets are inverted in the file.
The values meaning are the following:
00 : nothing
01 : wall
10 : ladder
11 : tree
So, for example, when in the file there is the byte value:
0x68 : 01 10 10 00
the real values should be interpreted as:
0x29 : 00 10 10 01
1 byte means 4 cells of the array.
The series of 2 bits are inverted.
See what I mean?
So, the compressed array's size is (MapWidth/2)x(MapHeight/2).
for example if you have a tiny 4x8 map like this: (t1)
1 1 1 1 1 1 1 1
1 0 2 2 0 0 0 1
1 0 2 2 0 0 0 1
1 1 1 1 1 1 1 1
In the collision map coded like this in memory: (t2)
01 01 01 01 01 01 01 01
01 00 10 10 00 00 00 01
01 00 10 10 00 00 00 01
01 01 01 01 01 01 01 01
and in the file it is like this: (t3)
01 01 01 01 01 01 01 01
10 10 00 01 01 00 00 00
10 10 00 01 01 00 00 00
01 01 01 01 01 01 01 01
in hexa as bytes it looks like this:
0x55 0x55
0xa1 0x40
0xa1 0x40
0x55 0x55
the size of the compressed array is 2x4 like I wrote above (MapWidth/2)x(MapHeight/2)
In the unsigned char* it is coded like this (in the file)
0x55 0x55 0xa1 0x40 0xa1 0x40 0x55 0x55
so, in our example, GetAt(compressedArray, 3, 1) should returns 2 (0x10 - column 3, line 1 from t2)
while it is read from the compressedArray...
I hope it is clearer with a concrete example.
I'm sure there is a way to decode it on the fly without storing the decompressed array.
Thanks for the help
Best regards.
Fred.
There is no spoon.
-- modified at 12:20 Saturday 25th March, 2006
|
|
|
|
|
Just a tweak to the function should get it to work.
You can just do GetAt(compressedArray, x + y * MapWidth) to get the cell you are interested in.
<br />
unsigned char GetAt(unsigned char *compressedArray, int i)<br />
{<br />
int nArrayPos = i / 4;<br />
int nBytePos = (i % 4) * 2;<br />
return (compressedArray[nArrayPos] >> nBytePos) & 0x03;<br />
}<br />
Don't get what you mean by decode on the fly, isn't this decoding on the fly?
|
|
|
|
|
it always return 1
There is no spoon.
|
|
|
|
|
ok got it!!!
It works!!!
many thanks
Fred.
There is no spoon.
|
|
|
|
|
Hello hfry,
Do you remember me and my problem about bits?
You gave me the function that reads the values and it works perfectly. Now, I need the reciproque function: I need to write values...
I remind you the function for reading the data you kindly gave me:
int GetCollisionValue(unsigned char* collisionsMap, int x, int y, int nWidth)
{
int i=x+y*nWidth;
int nArrayPos = i / 4;
int nBytePos = (i % 4) * 2;
int value=(collisionsMap[nArrayPos] >> nBytePos) & 0x03;
return value;
}
Now, I need the "SetAt" function...
void SetAt(unsigned char* collisionsMap, int x, int y, int nWidth, int nValue);
Can you help me again please???
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
how to code for finding some related info based on keywords like "id", "name" etc
|
|
|
|
|
what's your question exactly ?
i doubt anybody can understand you.
please also indicate which data types you're handling...
sincerely,
|
|
|
|
|
lets say i have a program, its a reservation system. i have a db connected to it, and when click a button "Find", it will find related info based on keywords provided like "ReserveNo", "Name", etc.
im not very good at telling wat i want, cause im very new with this... sry
|
|
|
|
|
well, what you want seems to be some SQL queries...
|
|
|
|
|
I would like to distribute a font file with my app. The font I have is a little too large for my liking, 3.6mb. Using winrar I am able to compress it down to 1.2mb which is a little more realistic.
Obviously There is a chance that winrar will not be installed on the target machine so I need some sort of runtime decrompression algorithm. The idea is, I compress the file and add it to the resources/installer then simply deflate it onto the target machine.
I know of zlib, but I have never used it. Could anybody recomend a good algorithm, with not much overhead, will not increae the exe size too much, and fairly easy to implement? This is not an MFC project
|
|
|
|
|
|
This for the links, I will into them
|
|
|
|
|
|
I am using Visual c++ 6.0.
Where can I found a class that make DateTimePicker Flat like i found for ComboBox
Urgent
I learn my self
|
|
|
|
|
No Body can reply me at this forum !
|
|
|
|
|
Hi,
I've an application which creates HTML files. For that i'm using some database operations, which includes classes such as, CDatabase and CRecordSet etc.
I'm getting an exception as "invalid cursor" since m_strCursor is getting set to some file name e.g. "test.html", which the application is creating. I'm not able to trace out, how the variable is getting set. Similarly, m_strFilter, m_strSort, m_strUpdateSQL, m_strRequeryFilter, m_strRequerySort are getting set to the same file name.
Thanks,
Kranti
|
|
|
|
|
|
|
Cool, that is what I was looking for. Thanks.
Now one more thing - is there any preprocessor variable that indicates what compiler is compiling the code? I want to write this macro seperately once for VC8 and once for VC6/VC7 so that the code can still be compiled with the older compiler, just in case someone wants to use the older compilers.
thanks!
|
|
|
|
|
|
Guys,
* How to find my system get connected to LAN alone
not internet.
* IsNetworkAlive() API results in compilation error. AS
It requires Sensapi.h and its not found in my sysem.
where could I get this file?.
You only have to do a very few things right in your life so long as you don't do too many things wrong.
Vivek.S
|
|
|
|
|
vivek.s.vivek wrote: It requires Sensapi.h and its not found in my sysem. where could I get this file?.
Download latest PSDK from MSDN site or seach cds comes with MSDN subscriptions.
|
|
|
|
|
Try using this.
DWORD flags;
BOOL chk=InternetGetConnectedState(&flags, NULL);
if(chk)
AfxMessageBox("Connected");
else
AfxMessageBox("Not Connected");
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Ganesh_T wrote: BOOL chk=InternetGetConnectedState(&flags, NULL);
This function doesnot gurrantee internet state
|
|
|
|
|
Greetings,
I'm new to VC++ and the MFC (been programming text based games in C for 10 years) and I've decided to give VC++ a shot. I have worked with some DirectX 8 and 9 over the last few months (modifying what someone else wrote and using MSDN to understand it all). Anyways, what I'm trying to do is create an application that will do a couple things:
1.) Copy the pixel/bitmap information of the center of the screen (let's say 50x50 pixels)
2.) Draw a black box in the center of the screen (multiple of the above [1.5-4x])
3.) Scale the stored pixel/bitmap information to match the size of the box.
4.) Draw the new bitmap in the box.
Also, I'm wondering if it is possible to make this an overlay to some fullscreen application (for example a 3D game). The purpose of this application is to offer a "zoom" function in Blizzard's World of Warcraft MMORPG game. I have managed to hook DirectX and then modifying the Field of View (which works wonderfully), but I have come across a problem. Due to the nature of my code (hooking Dx9), the game thinks I'm using some type of cheat. Blizzard froze my account and after explaining what I was doing (and sending them my code), they unbanned me and told me I'd have to come up with a different method that did not involve attaching to WoW's process. The person I spoke with said that my little project was such a good idea that he'd pass it on to the dev-team. This is all fine and good, but I am now very curious as to how I can go about this independently of the game. Besides, I'm sure the dev-team won't have this feature in the game for quite some time (if they even consider it needed).
I figure the best approach would be using GDI/GDI+ for this, unless it is possible to do in DirectX or OpenGL without hooking WoW's process. I just have no idea where to start looking for information. Most of my searching has turned up articles on the inefficiency of GetPixel() and how using other GDI functions is much more efficient. Or I come across some pre-built application with no source code to learn from . On another note, I'm wondering if my overlay will "flicker" due to the fact the game is rendering constantly (90-100 frames per second) and my application will just render as fast as it can loop (without hording the CPU). I know that some applications can place overlays on games without a problem (such as xFire) and I wonder how.
Any ideas, snippets, or places of intrest to look?
Thanx so much,
Rapture2k4
|
|
|
|