|
I would start by reading up on the various different types.
|
|
|
|
|
|
I'd suggest starting with LZ77: http://en.wikipedia.org/wiki/LZ78[^]
- It is one of the earlier most widespread lossless algo.
- It has been the base for many other algo.
- The compress and decompress code can be done in less than 100 lines of code.
It might take a while, but get a copy of the code and study it until you understand what every single line is doing. Then try to modify it and understand how all the parameters are inter-related.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I have an explosion sprite, with 16 frames.
Everytime the player collides with an asteroid, the gamestate is set to loseScreen, and when the loseScreen is the gamestate, the lose() function is continually called until the gamestate changes.
Inside the lose() function, this code draws the animated spritesheet, which runs through the 16 frame animation. It should always start from frame 0, but it doesn't always. Sometimes it starts at frame 10, and only runs for 6 frames before finishing. That's the issue. The code inside the lose() function to draw the explosion animation is as follows:
expFrameID = 0;
expFrameID += (int)(time * expFPS) % expFrameCount;
Rectangle expRect = new Rectangle(expFrameID * expFrameWidth, 0, 63, 63);
spriteBatch.Draw(explosion, shipLocation, expRect, Color.White, 0f, new Vector2(32, 32), 1.0f, pickupSpriteEffects, 0.1f);
if (expFrameID == 15)
expIsDrawn = true;
The time variable is as follows, it gets the total elapsed game time.
time = (float)gameTime.TotalGameTime.TotalSeconds;
I've tried changing TotalGameTime to ElapsedGameTime, nothing changed.
It's the following line from the lose() function that I believe is the issue, perhaps:
expFrameID += (int)(time * expFPS) % expFrameCount;
It works, and it animates. However it doesn't always start at frame 0. it starts from random frames between 0 and 16, but it still runs correctly at 16 frames per second.
So, how do I get it to always start from frame 0?
Would I solve my issue by making a new time variable that starts a timer from 0 only when the lose() function is called? How do I do that?
|
|
|
|
|
In a C# 2008 application, I need to write code that will generate the following xml. Since
I am new to working with xml, I am wondering if you can tell me and/or
point me to a reference that will show me how to generate the following xml:
<xs:element name="AddDocuments">
<xs:complexType>
<xs:annotation>
<xs:documentation xml:lang="en">
adding Documents
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name ="PckId" type="ept:PackId"/>
<xs:element name ="FDocs" type="ept:FDocs" minOccurs="0" maxOccurs="10"/>
</xs:sequence>
<xs:complexType name="FDocs">
<xs:annotation>
<xs:documentation> Refer to the attributes doc</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="FDocMetadata" type="ept:FDocAttr">
<xs:annotation>
<xs:documentation>
This structure.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="attachmentId" type="ept:AttachmentId"/>
</xs:sequence>
</xs:complexType>
|
|
|
|
|
|
For something that small, I'd use an System.Xml.XmlDocument .
I'd use an System.Xml.XmlWriter for more complex documents.
|
|
|
|
|
In a C# 2010 desktop/console application, I am currently using linq to sql to connect to a sql server 2008 database. So far in this application, I have used straight linq to connect to the database. However now I need to obtain data from various tables so that the data can be setup for a new user to access the data. The database people at my job say it is easier to write the logic using a sql script they can give me.
Thus my question is, can linq to sql use 'stright sql' somehow? Basically can I have linq to sql use a stored procedure? If so, can you tell me and/or point me to a reference that will show me how linq to sql can use a stored procedure?
|
|
|
|
|
Take a look at this tutorial Retrieving Data Using Stored Procedures[^]. It is part 6 of an excellent LinQ to SQL tutorial.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
see below link ..
it will help ful for you
Link 1[^]
|
|
|
|
|
How can we detect from our program that a prerequired
program such as dotNetFrameWork3 or 4 is installed
and also is active now or not? thanks
|
|
|
|
|
The system will do it for you. If the framework is not installed then your program will not even start.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard MacCutchan wrote: your program will not even start.
Technically inaccurate.
It will indeed start and display a message box telling you that the required framework is missing. 
|
|
|
|
|
Shameel wrote: Technically inaccurate. On the contrary, the actual program will not start. The system will receive a request to start it, and the loader will check for prerequisites and abort the loading when it discovers that a required library is not present. The point being that the user code will never get control in order to 'see' this problem.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard MacCutchan wrote: On the contrary, the actual program will not start.
The actual program WILL start and execute a native bootstrap that loads the mscoree.dll (which is Framework version agnostic). It is this dll that actually checks if the supported Runtime is installed and displays a message box if it is not installed.
Richard MacCutchan wrote: the point being that the user code will never get control in order to 'see' this problem.
Agree.
|
|
|
|
|
So the program still never gets started, the only thing that gets any control is the framework that is wrapped round the app. My point was to show that the user code has no way of checking whether a required feature is present or not. Which, after all, is what the questioner is asking about.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
FrameWork was just an example.
|
|
|
|
|
And I gave the answer based on that information. If you wish to discuss some other issue then maybe you could explain further.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
The only way to do it is to write a native code pre-loader which checks the requirements you specify and only starts your porgram if they are met. But you can't do that in C# or any other .NET language as Richard has already said - you would need to use C or C++ most likely.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
As I mentioned before, FrameWork was just an example. In general, how is it possible to check that a dll which is not even famous, is running or not?
|
|
|
|
|
DLLs do not 'run', they are loaded by the system when an application attempts to call a function within the DLL. Alternatively an application can load the DLL and make 'unlinked' calls to functions using the LoadLibrary() [^] and associated functions. This is true in native applications but I'm not sure that it is particularly straightforward in .NET based applications.
Perhaps a clearer explanation of what you are trying to achieve would help.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
You are right, assume that a program wants to check out a printer driver is loaded or not?
|
|
|
|
|
|
Well, as Paul explains, you can enumerate all sorts of information in C++, which probably means you need to learn about P/Invoke[^]. However, you still have not explained what you are trying to achieve.
One of these days I'm going to think of a really clever signature.
|
|
|
|