- Home /
Is it possible to create an entire game using javascript?
Hey, I've been programming for a while mainly in Java but my question is, would it be possible to create a game entirely using JavaScript or would maybe C# be used for maybe things like MySQL databases or something to store player data maybe?
If you are familiar with Java then you should find the transition to c# the easiest. I would only recommend UnityScript to people most familiar with ActionScript 3.
Answer by Statement · Dec 23, 2013 at 02:27 PM
Yes, it's possible to create an entire game in JavaScript (UnityScript)
There are some differences between the languages but to my best knowledge you can still use all the API's regardless of language choice. There may be rare moments where doing something in UnityScript may be harder than C# but I wouldn't let that deter you if you feel that UnityScript is a better choice for you overall than C#. If you prefer UnityScript and if you feel the syntax is familiar for you, go for it.
However, with my limited experience in Java (not JavaScript), I think that you may find transition to C# pretty easy since the languages are pretty similar in structure and syntax.
You may find this page helpful too:
In the end, common libraries are the same and the language choice is mostly a matter of preference. You can't do some things with UnityScript that you can with C#, such as using extension methods. On the other hand UnityScript excels over C# when it comes to terse coroutine syntax. This is just mentioning two differences, and there are of course several. None of these will stop you from writing any code and you should be able to achieve the same goal with either languages.
If at all uncertain, give each a try. Try making a simple component in UnityScript and in C#, and see which one follows a syntax convention that you prefer the most.
Recommended topics:
If you were to ask me for advice and let me be subjective on the topic, I'd say you'd be better off in the long run learning C#. In the short run it may stagger you as several of the examples in Unitys docs are in UnityScript only, but if you know program$$anonymous$$g you shouldn't have that much of a hard time figuring it out. The question is only how long it will take you and how soon you need to be productive. Also I think you'll see a lot more widespread C# usage if you were to work at a company using Unity. Learning C# also gives you a "carry with you" skill that you can apply elsewhere, where UnityScript is specific to Unity only. New programmers can benefit from learning UnityScript if they find it easier to learn, at least the get the "carry with you" skill of learning a program$$anonymous$$g language, and so if they transition to another language, they can still apply a lot of their knowledge to ease the transition.
Thank you for the advice! I know in Java when you create objects you can implement them and extend them, is this possible in C# and UnityScript? and also is it possible for example to create an object lets say a magic spell, is it possible to get the attacker of the spell and check if the spell hit's another player using these objects, for example:
if(spell.hit(player)){
spell.getAttacker().giveExp(5.57);
}
which language would you recommend me to create objects which I can check things like this? UnityScript or C#?
Thanks again!
Yes, you can extend and implement classes, abstract classes and interfaces. However, once you get started with Unity you may find yourself doing less of that than you think you need to due to the component design of the engine. There are still places to do that but in many cases it's not necessary. It may take a slight mental shift to get used to this way of thinking but it is really nice to work with once you got the hang of it.
Both languages should be equally good at doing what you just described.
Note that extends and implements are used in UnityScript where : is used in C#. The syntax is a little different, but it achieves the same thing, just with fewer letters which can improve or reduce your readability, depending on what flavour you prefer.
// C#
public class Foo : Bar
{
}
// JS
public class Foo extends Bar
{
}
// C#
public class Foo : IBar
{
}
// JS
public class Foo implements IBar
{
}
I invite you to read the links I sent you as they should help you get a broader picture. Also you'll find a lot of discussions if you put just a little effort searching here. I am not telling you to RTF$$anonymous$$ so please don't take this as a diss or that I am too important to care, but there is a wealth of nice questions and answers readily available (for example I just looked up extends and implements myself to answer your question by searching for unity javascript interface in google). A general tip when it comes to Unity specific questions is to use google and prefix your question with unity or site:unity3d.com
You are welcome!
While I don't want to milk you for $$anonymous$$arma points, we who answer questions would prefer if you also took the time to upvote the answer if you found it helpful and accept the answer if you deem the answer to also be the most correct answer presented to you. There is also a short tutorial video on how to best use Unity Answers.
By giving good contributors $$anonymous$$arma, those users are granted access to moderate the site for the better of the community. In my case, I desire all the points I can get to shamelessly try and catch up with @Eric5h5 ;) (Even though I know that is never going to happen). It also makes me feel like I've achieved something.
Answer by Kieron_Wiltshire · Dec 23, 2013 at 08:22 PM
I don't have the option to 'covert to answer' or whatever on your answer? only on mine?
Your answer
Follow this Question
Related Questions
how to make out like little notes? 2 Answers
paid request 1 Answer
I'm completely lost with android 2 Answers
How do you create hotkeys in your game. 1 Answer
I need help with a companion!!! 2 Answers