Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 16, 2016 1:39:53 GMT
If anyone here is willing to teach a some people how to do things. I want to program c++(that is the language right?) for thrive a bit since I mostly have free time and check the forums a lot. I know just a bit of programming and only a bit. I suggest thrive to have a question thread of some sort because I am not sure where to put this. I have eclipse(only for the debug option really). I have the compier and also notepad++. Hopefully someone would be able to read this.
If it is ok with the teacher can people from this thread look at it to follow some of the tutorials. I think I would benefit from here than a video because it would be easier to find the right section of tutorial and ask the parts I won't understand. I also think that I won't be just copying stuff from videos and I would actually do work if I ask here. thank you (^-^)
Example of confusion:
main(){
return(1)< I don't know what is the function of return. I know it is something to activate the function that's all. }
If you read through this thx.
|
|
|
Post by evolution4weαk on Jan 16, 2016 2:13:23 GMT
I Thought Thrive was Written In Lua also "return" Returns a value
The return statement terminates the execution of a function and returns control to the calling function. Execution resumes in the calling function at the point immediately following the call. A return statement can also return a value to the calling function.-Wikipedia
|
|
|
Post by TheCreator on Jan 16, 2016 6:48:32 GMT
Hey, Unkown! Of course, we'd love to help you out! Computer science is one of the best fields out there, and it is never too late/early to get started. Thrive is written in c++, yes, and we use lua as a scripting language.
I would like to start by saying two things: 1) Please don't use Eclipse. People only use it when they have no other choice. With c++ I recommend downloading Visual Studio 2015 Community Edition. It will make your life so much easier. 2) I usually recommend this book (http://ptgmedia.pearsoncmg.com/images/9780672333316/samplepages/0672333317.pdf) to people who want to start with c++. I basically learned all of my programming skills from this one book (and looking stuff up on stack overflow, which is your friend).
To answer your question, return does not activate the function, in fact, it does quite the opposite—it ends the function. In c++ every function outputs a value when you call it, which is usually the first keyword of a function declaration. For example, int foo(); will return an integer value, while bool bar(); returns a boolean (true or false). Once the program reaches the return statement, it goes back to the function that called it (or exits the program if it is main as in your case) and is "replaced" by that value. So in the below example, myVar is 5.
int foo(int input) { return (input + 3); }
int main() { int myVar = 0; myVar = foo(2); return myVar; }
Hope this all made sense!
|
|
|
Post by Narotiza on Jan 16, 2016 9:15:41 GMT
I was also thinking about learning some C++ so I could help with the development of Thrive a little or something.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 18, 2016 2:07:48 GMT
TheCreator This maybe a bit too advance for me but how does graphic programming work. Isn't it library for your game? You guys use ogre3D, but I think ill start slow and use sdfl or something else. Thx for answering my return question, but I am a bit confused for "foo". I heard it is to hold four variables in it or something. Return changes a certain variable or so to what the function wanted to change it and ends it? Like changing the code on a website and when it hits return it reloads the pages changing the content on the website?
|
|
|
Post by TheCreator on Jan 21, 2016 4:12:35 GMT
You should definitely learn to program before you move on to graphics. We use ogre as a graphics engine, but I personally prefer directX (which is a lot more low level). If you want, java makes graphical programming much easier than c++, and the syntax is very similar, so it shouldn't be too hard to switch.
foo/bar is just the name of any generic function, so I could have replaced that part with
int MyFunction(int input) { return (input + 3); }
and it would do the exact same thing.
In C++, a function works as a black box. You give it some inputs (the "int input" thing in my example above) and it "returns" a value. So basically, the function is replaced by the return value. So
(4 + MyFunction(3))/2 is the exact same thing as (4 + 6)/2 in the eyes of the computer.
Does this make sense?
|
|
|
Post by evolution4weαk on Jan 21, 2016 4:15:52 GMT
www.codecademy.com/ Try This Site, it called Codeacademy Other Site To Try 1.(Not Really For Teaching You, But More About Problem Solving) CodinGame Coding Game- CodinGame is an online gaming platform that provides solo and multiplayer games for programmers and also hosts monthly international online coding contests.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Jan 21, 2016 5:02:07 GMT
TheCreator That helps so much thank you. It helped a lot when you said the function gets replaced by the "return". Also i perfer c++ because I heard it is faster
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 6, 2016 22:30:13 GMT
Well so far I actually got around to do things my weekend. This only multiplies 2 numbers so far... I just want to know if it works on other computers. I am pretty sure it doesn't Download it if you want, Windows(idk 64x or 32x) only though :( New.exe (108 KB) Virus scan it if you want. idk
|
|
|
Post by TheCreator on Feb 6, 2016 22:49:34 GMT
Well so far I actually got around to do things my weekend. This only multiplies 2 numbers so far... I just want to know if it works on other computers. I am pretty sure it doesn't Download it if you want, Windows(idk 64x or 32x) only though Virus scan it if you want. idk It works on my computer, but I'd like to point out one thing. When you get the user input, you don't check what you got, so if I enter 'a' for my first number and 29 for my second number, it tries to multiply the two together. It is a good coding practice to check for all end cases, meaning you should see if the value you got is a double, and if it isn't, you should tell the user to enter another number. Same for the "Do you want to quit?" statement. If I enter 'n', the program exits, when it should tell me that 'n' is not a valid input. This might seem like something trivial, but it is actually very important and what tells a good coder from a bad one. Other than that, everything looks fine to me (though it is hard to say without seeing the actual code), keep trying!
|
|
|
Post by evolution4weαk on Feb 7, 2016 3:04:23 GMT
wish i could see it, Chrome Say It A Virus...
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 7, 2016 5:03:19 GMT
wish i could see it, Chrome Say It A Virus... I knew that it would do that for other computers
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 12, 2016 0:25:29 GMT
TheCreator So I couldn't find the answer. How do I add a char or string between two variables with cin Example: cin >> n1 >> "x" >> n2; I want to automatically add in an x as he types a number and I don't know how to do that. I saw insert function, but I came to ask you to make sure.
|
|
|
Post by TheCreator on Feb 12, 2016 17:23:20 GMT
TheCreator So I couldn't find the answer. How do I add a char or string between two variables with cin Example: cin >> n1 >> "x" >> n2; I want to automatically add in an x as he types a number and I don't know how to do that. I saw insert function, but I came to ask you to make sure. I'm not sure your code works, does it? The best way is to try and see where it errors. But why can't you just do it like this? // Get the two values. std::cin >> n1; std::cin >> n2; // Mix them together into one string. String n = n1 + "x" + n2; // Output for the user. std::cout << n << std::endl; Unless of course, you meant to output the "x" while the user is typing into the console because in that case you can't.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 12, 2016 18:41:59 GMT
Ok thx I might use your Idea bit then
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 13, 2016 1:15:19 GMT
TheCreator Hey this code does not work for some reason. There isn't a script error, but does not work like I intended to. If I type in 2 numbers it will say, "Sorry I do not understand please try again. Make sure it is like '64x20'. I will now restart the question" #include <iostream> #include <string> #include <Windows.h> #include <ctype.h>
using namespace std;
void main(){ unsigned int countdown = 4; unsigned int n1; unsigned int n2; string quit; cout << "Hi there! This is a program to multiply numbers :) To multiply please give two numbers and press enter when you finish a number\nOutput: 64x20\nIf you would like to quit please wait at the end of the equation or close your \nwindow.\nNumbers:\n"; Loop: cin >> n1; cin >> n2; cout << n1 << "x" << n2 << endl; if(isdigit(n1) && isdigit(n2)){ cout << n1 << "multiplied by" << n2 << "equals" << n1*n2 << ".\nWould you like to quit?\n" << endl; cin >> quit; QuitLoop: if(quit == "yes"){ while(countdown >= 1){ cout << --countdown; Sleep(1000); cout << " ,"; } }else if(quit == "no"){ cout << "\nNumbers:"; goto Loop; }else{ cout << "Sorry I do not understand please try again."; goto QuitLoop; } }else{ cout << "Sorry I do not understand please try again. Make sure it is like '64x20'. I will now restart the question\nNumbers:"; goto Loop; } }
|
|
|
Post by TheCreator on Feb 13, 2016 6:17:09 GMT
Try using a debugger to step through it and see what each of the variables is equal to and why you are not entering the if statement. Also, NEVER use goto statements. They will just mess up your code, and I don't think there is ever a use for them. Everything can be accomplished using normal loops without goto statements.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 23, 2016 3:56:20 GMT
So I just wanted to know what libraries were and so I tinkered around and worked with dynamic linking and static linking(I think that's what it's called). I am not sure if this works on other computers. I may have done it wrong so I'll just give a link if anyone want to tell me if it does. If your on chrome then it might not download. I am gonna cross my fingers and hope I did something right. x| (might as well cross my eyes too) Windows: SFMLTest.zip (334.34 KB) The code is not mine. This is purely just testing if I accomplished libraries.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 23, 2016 3:59:24 GMT
Forgot to say the download link is the static linking(which was the hardest for me).
|
|
|
Post by TheCreator on Feb 23, 2016 17:22:14 GMT
It's a green circle that becomes an oval if I resize the screen So if that's what you were aiming for, you did it!
|
|