PC Review


Reply
Thread Tools Rate Thread

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

 
 
Brian Basquille
Guest
Posts: n/a
 
      12th Feb 2005
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;
}



 
Reply With Quote
 
 
 
 
KingCrimson
Guest
Posts: n/a
 
      12th Feb 2005
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
 
Reply With Quote
 
Brian Basquille
Guest
Posts: n/a
 
      12th Feb 2005
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

"KingCrimson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Columns of Sensitive Information, and then convert back... =?Utf-8?B?V2lsbGlhbSBFbGVyZGluZw==?= Microsoft Excel Programming 1 12th Oct 2006 09:37 PM
IsNumeric: Convert.ToInt32 vs. Convert.ToInt64 sck10 Microsoft ASP .NET 4 3rd Sep 2006 10:40 PM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET 0 9th Sep 2005 06:04 PM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET Framework 1 9th Sep 2005 06:01 PM
convert decimal number to time : convert 1,59 (minutes, dec) to m =?Utf-8?B?YWdlbmRhOTUzMw==?= Microsoft Excel Misc 8 20th Jan 2005 10:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 AM.