Convert C into C# (is there a way?)

B

Brian Basquille

Hello all,

Is there any way to convert, what i think is, source code in C into C#?

Can't find any resources online for doing it anyways.. just C# to VB.net and
vice-versa.

The problem with the source code i have is it's quite difficult to
understand as they use some built in functions, such as DotProd and Normal,
which i reckon are in C# but not with the same parameter supplies as below.

For example - for DotProd below, it provides 4 parameters but the DotProd in
C# only allows you to supply a vector.

Little areas like this are catching me out!

Anyone help me convert / make sense of some of the source code below,
especially DotProd and Normal?

Thanks all.

Brian

-------------------------------------------------------------------------------------------------------------

Below is the source code.. it's to perform a collision between two balls of
equal mass.

void collision (void)
{
// ball movement (Yes?)

x1 += xVect1;
y1 += yVect1;

x2 += xVect2;
y2 += yVect2;

// test for collision

if (distance > radius1 + radius2)
{
return;
}

// if we get here, the balls have collided,
// so we do the collision calculations

xVelocity = xVect2 - xVect1;
yVelocity = yVect2 - yVect1;

// Normalize
Normal (x1 - x2, y1 - y2, normal);

approach = DotProd(normal[0], normal[1], xVelocity, yVelocity);

// calculate velocity change

xNewVect = normal[0] * approach;
yNewVect = normal[1] * approach;

// change velocities

xVect1 += xNewVect;
yVect1 += yNewVect;

xVect2 -= xNewVect;
yVect2 -= yNewVect;
}
 
K

KingCrimson

Hey

Perhaps I shouldn't ask this but, why do you want to use C# instead of
C++ ??

I sincerely ask this question because I've been working with c++ and
directX, now I believe the way to go is use C# and DirectX, but it's
almost like a personal decision....... I've used C# and I know it's more
confortable to use, but I'm not sure about forcing people install .NET
framework in order to use my programs........

so the question is why??

KingCrimson
 
B

Brian Basquille

I've been developing a project (Air Hockey game) using the graphic engine in
C# (GDI+) for almost half a year.

It's my first time using the language and i have to give a presentation on
it in just under 2 months.

The game was never really intended to be released for the public, though
some interest on the newsgroup will probably see me release the source code.

The game itself is more of a test for GDI+ as practically every game i've
seen developed with GDI+ has been slow moving (card games, Tetris, space
invaders etc.).

How would it handle a fast-moving puck colliding with a paddle / side of a
table? This is the kind of question i intend to find the answer to.

Hope that answered your question.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top