Converting Pseudocode into C#
Hello, so I'm recently trying to learn how Pseudocode works, and I want to it to work in unity3d. However, Unity only work with C# and Javascript, so the only way to do that is try to make a script that converts Pseudocode to either C# or Js. So far I've writen down a simple script based on an example I've found on converting Pseudocode to C#.
using UnityEngine;
using System.Collections;
public class PseudocodeConverter : MonoBehaviour {
class Program
{
static void Main()
{
// Get the value for N
Console.Write("Please enter a positive integer: ");
int N;
int.TryParse(Console.ReadLine(), out N);
if (N <= 0)
{
Console.WriteLine("{0} isn't a perfect number", N);
return;
}
// Initialize sum of the divisors & divison
int SumOfDivisors = 1;
int Candidate = 2;
// Consider all possible divisors
while(Candidate <= N/2)
{
int R = N - (N/Candidate) * Candidate;
if (R == 0) SumOfDivisors += Candidate;
Candidate++;
}
// Check the results
if (SumOfDivisors == N)
{
Console.WriteLine("{0} is a perfect number", N);
}
else
{
Console.WriteLine("{0} isn't a perfect number", N);
}
Console.ReadKey();
}
}
Of course as you can see, there are a lot of errors that need to be dealt with, and I'm still relatively new to coding. In any case though, can anyone point out what need to be corrected here? I would really appreciate it.
You do know Pseudocode isn't an actual language, and is really just short hand gibberish, right...? I even checked the Wiki to make sure some new language wasn't just invented. Creating your own coding language isn't an ideal thing here. You want to write files for your game in 'pseudocode', and then have a c# file read them and run your game from them. Sure it is possible, but just because you can doesn't mean it's at all a good idea. It'll be inefficient, take a lot more time to develop, and you'll still have to learn c# anyways to be able to code it. Just, learn and go with c#, and you'll save yourself the struggle
I suppose your right about that, It's just I'm having a hard time trying to figure out what kind of C# script I should make for the Game I'm trying to make. You see I want to create a game that mimics the Pseudo 3D Raster effects that where used often in early games, specifically arcade racing titles from the 80's and 90's. Do you know what I mean?
You will have to write the same script in C# that you would have done in PseudoCode.