Programming help/tips

For anyone still curious. Try this: https://www.udemy.com/free-learn-c-tutorial-beginners/learn/v4/overview Its a pretty good tutorial with quite high video quality for the time of which it was made.

You can also go on tutorialspoint.com

Well, there’s the manual guide that beginners can use.

Here: https://www.angelcode.com/angelscript/documentation.html

1 Like

Did you just…

REVIVE A DED THRED???

1 Like

That was complete on topic and due to the low volume of posts on this forum I think it is completely fine to post in the correct thread, even if it is old, instead of making a new one.

The manual is only good for beginners to AngelScript. It isn’t a proper tutorial for programming. So everyone who is interested in learning AngelScript needs to first learn a language that has complete programming beginner tutorials and then check out the AngelScript manual to see how similar it is to languages in the C family. The wiki has some programming tutorial links here: How to Help - Thrive (which I have posted already in this thread)

Learn to code websites (the ones I know)

Tutorialspoint

Type: Free

Platform(s): Web

Link: http://www.tutorialspoint.com/

That website has a great library of tutorials from Computer Science to History. Even though there is some tutorials about history, chemistry or physics, most of the tutorials are about computers and programming. Most of programming languages are in the library: C, C++. C#, Python, HTML, CSS, Lua, JavaScript, Brainfuck, etc. The only downside is that the tutorials aren’t interactive enough, thus it might be better to have some programming experience before going into a tutorial or to use the website especially for documentation. In brief, tutorialspoint has many tutorials on most programming languages, but they aren’t so interactive (you can try codes, but you cannot have a lesson after each chapter).

W3Schools

Type: Free

Platform(s): Web

Link: https://www.w3schools.com/

That website is excellent for learning web programming. The library is not very big, but it isn’t so small neither. The library includes: HTML, CSS, Colors, Graphics, JavaScript, JSON, Python, Bootstrap, jQuery, AngularJS, SQL, XML, etc. In addition, the tutorials are very interactive. More precisely, you can try codes and have a test at the end of each lesson. To conclude, that website is web oriented and is great for learning.

SoloLearn

Type: Free

Platform(s): Web, iPhone, Android, Windows Phone and Facebook.

Link: https://www.sololearn.com/

That website is good for learning, because it is very interactive. You have many exercises in each lesson and you can try codes. However, that website has not a huge library. The library includes: C++, C#, Java, Python, Ruby, Swift, HTML, CSS, JavaScript, jQuery, PHP and SQL. In other words, SoloLearn doesn’t have many tutorials, but they are very interactive indeed.

Other learn to code websites (the ones I don’t know)

Codecademy

Type: Freemium

Platform(s): Web

Link: https://www.codecademy.com/

Tutlane

Type: Free

Platform(s): Web

Link: https://www.tutlane.com/

Tutorialsteacher

Type: Free

Platform(s): Web

Link: http://www.tutorialsteacher.com/

YouTube Channels for programming and software

thenewboston (computer & programming): https://www.youtube.com/user/thenewboston

TheHappieCat (computer & programming): https://www.youtube.com/user/TheHappieCat

TJ FREE (Software presentation): https://www.youtube.com/user/tjopen1

If you want to find an alternative software, you can go on this website: https://alternativeto.net/ .

That’s all! If you want to, you can put other sources of informations, so everybody who wants to learn programming, graphics and stuff can go on this thread and choose their own path.

I made the first post of this thread a “wiki” post so anyone who wants to add links there, should be able to now (as long as you have been on the forum for a while to get trust levels).

Also, if some of you (readers who are interested in programming) want to learn programming progressively on tutorialspoint, there is one tutorial called Computer Programming teaching general programming with C, Java and Python as references. When you finish this tutorial, it will suggest you these three languages as starting points (thus, you can then go from C to C++ if you want to contribute to Project Thrive).

Well, if we’re talking about help with code anyway: I have a question. I’m currently working on a small game in Unity (as a school project). I built in a simple pathing system, where the enemies have two points (called “origins”) at either side. Every frame, a RayCast (basically a laser that gives information on whatever it hits.) of 2 units long is cast out of both origin points. The RayCastHits are lSight (what the left feeler “sees”) and rSight (the same but for the left feeler). Then, it checks whether they hit anything, or not, and turns accordingly. The code is (by head currently, I don’t have the code with me right now):

Totally not convoluted code
 if (rSight)
 {
   	if (lSight)
 	{
		if (rSight.collider = lSight)
		{
			dir = leftRightTest();	 //a function I found online that checks whether the object is on the left or right
		}
		else
		{
			dir = 0 ;				//Both see something, but it's something else, so it's safe to move straight ahead
		}
	}
	else 
	{
		dir = -1;					//There is only something on the right, so turn to the left
	}
}
else if (lSight)
{
	dir = 1;						//There is only something to the left, so turn right
}
else
{
	dir = 0; 						//Nothing is seen, so move straight ahead
}
Transform.Rotate(0, 45 * Time.deltaTime * dir); //Turn the proper direction with an RPS of 0,125

This works, but the issue is that, well, it’s ridiculously ugly. So, does anyone know if there is a way to make it less ugly? I’ve though about a for-loop, but I don’t think you can make one with multiple (boolean) variables.

(I was originally planning on posting this on “Dev Team Requirements”, since it’s kinda on-topic, but then I realized this thread exists. I could’ve also posted it on “bad code examples”, but that is a bit to off-topic)

I would put that into a new function and split the logic into parts with early returns.
Something like this:

if(!rSight && !lSight)
    return 0;
if(rSight && lSight){
    if(rSight == lSight)
         return 0;
    return leftRightTest();
} else if(rSight)
    return 1;
else if(lSight)
    return -1;

Something like that. I can’t think of a better way to reduce complex if-else nesting. (I didn’t make sure that that code is actually right, and I didn’t add comments which is very critical here to explain to future readers what the logic is about)

Thanks, now that I think about it using a function does make it a lot “cleaner” or so to say. I’ll try this out next time I’m working on it.

UPDATE!!!

You remember W3Schools? Years earlier, it was only about Web programming, but now they’ve started C++, Python, C#, and other tutorials as well.

*double necropost

So I’m trying to figure out how metatables work in Lua, and what I can’t figure out despite all the reading is how the metamethods work. For instance, what are __index, __newindex and __call doing?
I’ve tried using them, yet I still don’t how they work. Is Lua running on black magic?

I’m not really experienced with Lua myself, but I looked at the documentation: Programming in Lua : 13
Basically metatables is the way OOP works in Lua, so if you have two tables that you are treating as class instances, you can do stuff like a + b which results in the metatables being looked up, and I think if they contain an item with the name __add then that function is called.
So basically instead of objects (which are tables in Lua) having a class defining what they do, they have a single metatable on them, which stores the methods the class would have in a different language.
I think I said this before, but this is the same kind of approach to objects as the old JavaScript object prototype system (that was before JavaScript got proper class support).
What I’m trying to say is that Lua has quite a manual approach to OOP, so it might actually be much more difficult to try to use that if you aren’t familiar with OOP than using a language that has classes directly to help with this kind of thing.

Yes. Python also does this kind of thing, you can override what happens when you do a.b if you add a specifically named method to a. The same way in Lua you need to configure how your “objects” work using metatables.

Too bad Garry’s Mod doesn’t have anything else than Lua. I created a class for a stamina system and it seemed to work if called directly. The only problem is that I was trying to use it in both the player classes files and my HUD program. That’s why it doesn’t work, but I feel that if I don’t do it this way, I’ll never be able to implement a perk system for stamina upgrades.

I’m thinking of learning C# to maybe join the dev team (will need time and time from now until it happens) (and also to do better programming finally). But i’ve seen much much things in the internets talking about C# having a lower performance and be used for small programs, with C++ being used for bigger projects and having higher-performance. Such a dilemma of which one to choose, each one says different opinions and things; as I want to considerate both Thrive if possible and other personal/non-thrive programmings.

Although I can start using other language, but as i said, i want to consider invest experience in thrive potential, too.

Of course they are forgetting something, as thrive’s main language is C#, and it has a reason for it, but could someone clarify it to me?

And I’ve seen much discussion in the internet about which one is easier, and much people here saying that C# is easier to learn. I also know C# has bigger libraries than C++.

There are two languages you can use with Godot (without compiling native modules, which would mean that we’d lose mac builds and windows builds would be more hassle for me): GDScript and C#.
GDScript uses the same syntax as Python, which I don’t like. Also it’s Godot exclusive, so there aren’t a bunch of general libraries that can be used.

So I went ahead with the switch to Godot, because it was possible to write in C# while getting the benefits of easy to make builds and easy setup.

The reasoning why C# is so popular in game development (mainly due to the Unity engine being popular where C# is like the only choice for making games), is that it is fast enough. Often times games don’t need to run a bunch of custom logic each frame. So the games get by by relying on the game engine doing the heavy lifting, which is written in C++.

I agree, C# is easier to start with as you can’t make huge memory related issues that are hard to track down. Though, modern C++ is also pretty good, but there is the chance that you make a mistake and your program blows up without a clear error message.

But if you learn C++ then you’ll actually learn how computer memory works and that really clears up some reference shenanigans you can get hit by in python and C# (in C++ you always know if something is a value type or a pointer / reference to some other place).

1 Like

Found a C++ tutorial for beginners. Surely I’ll be taking a look at it soon.

Hope its a good introduction for C++ :smiley:

edit: God… he starts from windows installing then goes to variables, some other commands, pointers, objects…
seems legit

And the king returns…

Those seem pretty decent. Though they seem to only cover the basics very quickly, which is understandable as you just can’t cover everything in four hours.
Personally I don’t like video tutorials, but if you like video tutorials those seem at least decent.

My personal programming learning technique is: watch video lessons about this language, start doing your own things, and, when you are enough saturated with it, go back and see the next level of programming in that language.
That’s how I learned to make some programs in HTML and (javascript?) effectively.