Thrive Game Development

Development of the evolution game Thrive.
 
HomeHome  PortalPortal  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  
Welcome new and returning members!
Sign up and introduce yourself. ADMIN knows your ASL.
If you're new, read around a bit before you post: the odds are we've already covered your suggestion.
We are working with a relatively new theme, so visual bugs are being addressed.
ADMIN reminds you that the Devblog is REQUIRED reading.
Currently: The Microbe stage environment is taking shape.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
READ BEFORE POSTING
FAQs Wiki OE CC Thrive
Search
 
 

Display results as :
 
Rechercher Advanced Search
Statistics
We have 864 registered users
The newest registered user is Atrox_Somnium

Our users have posted a total of 22892 messages in 1106 subjects
Who is online?
In total there are 4 users online :: 1 Registered, 0 Hidden and 3 Guests :: 2 Bots

Atrox_Somnium

Most users ever online was 443 on Sun Mar 17, 2013 4:41 pm
Updated Research Web
Wed May 08, 2013 5:20 pm by NickTheNick
Okay guys, here is my first Devblog to fulfill my responsibility as Strategy Team lead.

Finally I have procured some work to show for my efforts in conceptualizing the Strategy Mode. The Research Web is a pivotal component of post-sapience gameplay, as it is what drives your species forwards from the Awakening stage to their final steps into Ascension. Through a graphing program, I have managed …

[ Full reading ]
Comments: 5
Keywords
microbe research Gameplay cell organism space wiki creature prototype tech biomes auto video stage date Thrive tree planet music underwater progress game Devblog concept editor evolution
Latest topics
» Population dynamics
by Seregon Today at 8:19 pm

» Building Microbe Stage
by Seregon Today at 8:19 pm

» Implementing Underwater Civilizations
by Atrox_Somnium Today at 8:15 pm

» im new too!
by NickTheNick Today at 8:12 pm

» Hello everyone :D
by Atrox_Somnium Today at 8:02 pm

» Revamping the Forum
by NickTheNick Today at 8:00 pm

» The new guy number 9999
by Daniferrito Today at 7:50 pm

» Organ Design
by scorpion268 Today at 8:31 am

» Im New and wanting to help
by Mysterious_Calligrapher Today at 8:04 am

» Function Part Discussion
by Daniferrito Yesterday at 11:55 pm

» Revamping the Wiki
by NickTheNick Yesterday at 11:16 pm

» GamerXA - Organism Editor
by Daniferrito Yesterday at 8:23 pm

» Concept Art Thread
by untrustedlife Yesterday at 6:18 pm

» New guy here
by Daniferrito Yesterday at 4:49 pm

» Strategy Mode Discussion
by NickTheNick Yesterday at 10:05 am

» Miscellaneous Bugs And Questions That Don't Deserve Their Own Thread Thread
by WilliamstheJohn Yesterday at 1:32 am

» Another Idea: 'Over tech'
by WilliamstheJohn Yesterday at 1:28 am

» Parallel work on multiple stages
by NickTheNick Mon May 20, 2013 7:37 pm

» Revolutionary Games website's thread
by WilliamstheJohn Mon May 20, 2013 10:48 am

» Hello there!
by Doggit Sun May 19, 2013 2:16 pm

Share | .
 

 On-Forum Tutorial series: Coding

View previous topic View next topic Go down 
Go to page : 1, 2  Next
AuthorMessage
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: On-Forum Tutorial series: Coding   Wed Jul 25, 2012 10:36 pm

An on-forum tutorial series for coding, because I have very little time to dedicate my c++ experience to thrive in a major way (OpenGL implementation, SDL fiddling with, OOP, etc, etc) Therefore, i am hoping that an on-forum tutorial series will spark interest in at least basic programming. For now we'll focus on c++ (it's not so bad once you get into it)

Lesson1:
C++ is a computer language which simplifies hardcore programming (01110100 01001000 01001001 01010011) In order to use c++, you must either use a compiler, or some kind of command line type of interface (what is there when you don't have an operating system) I, for the sake of your mental health, recommend using a compiler. Several compilers I know of, which are used often, are - Microsoft Visual Studio (express version is free), Code Blocks (totally free), and MinGW (minimalist GNU for windows) Once you have downloaded your preferred compiler, please read it's documentation and make sure you try to recognize anything that may set it apart. For this series, I will be using Visual Studio. The first thing you want to do is set up a new project, and if you're using VS, select Win32 console application, name your project, and press ok.

Now for actual coding, in your shiny new project, you will start by first setting up a main function. It should look like:

Code:
 int main()
{
   return 0;
}



This function(yes, basically what the name states, a function) acts like a starting point, it defines the entry point for the application. It is invaluable in coding and should always be in every program you compile. The int you see means integer, or whole number. It is the type of the function, other function types include float (decimal number), char (a character, like a letter) and void(no return) we will go in more detail with void and stuff at a later date. The return you see is what tells the function to go back wherever it came from(another function, a variable, or in this case nothing) the number is what it takes back with it. As for the { }, they represent start and finish of the function. So think of boundaries.

Now that we learned about that, let's make your computer do something magical and wonderful, we're going to make it say Hello tongue. First, we must add something to our program so that we can make use of this black magic. This something is, <iostream>(again, we'll discuss this in detail at a later date) to make use of <iostream> we will have to include it by putting #include <iostream> into our code. Another thing we'll need is using namespace std;(for right now this is just magical) Note: #include goes above all, and then using namespace std; comes next, always. so now we have:

Code:
#include <iostream>

using namespace std;
int main()
{
   cout << "hello";
   return 0;
}


Now that we have, TEH POWUH, we will say hello. To do this, type cout << "Hello"; in your function. As you can probably imagine, anything typed between in the " " part will come up on your screen, ANYTHING, it's TEH POWUH! Also, cout means ComputerOutput. So now:

Code:
#include <iostream>

using namespace std;
int main()
{
   cout << "hello";
   return 0;
}


now if you run this program (in VS, it's the green arrow next to the word "Debug"). Absolutely nothing happens Crying or Very sad. Well this is because your computer did this program really fast and closed right up pretty much as soon as it opened. To stop this, we have to make the computer unable to finish unless you type something. To make use of this fun fun, we use cout's evil twin brother, cin(ComputerInput). So back to the code, in order to make the computer wait for you and use cin, we will put cin.get(); right above return. cin.get(). will proceed no matter what you press. so here's our code now:

Code:
#include <iostream>

using namespace std;
int main()
{
   cout << "hello";
   cin.get();
   return 0;
}


And woopty Belgiuming doo, your computer says hello until you press something on your keyboard Very Happy. One final thing, if you are using VS, you must also have #include "stdafx.h" in your code. Next lesson we'll learn about more, so stay tuned for more mind boggling ,amazing, spectacular, awesomeness. Only on, the Thrive forums! please post all questions below. If you read none of this, stare at the pickle of shame, STARE AT IT. You lazy Belgium waffle.


Back to top Go down
View user profile
Brennus
Newcomer


Posts: 70
Reputation: 0
Join date: 2012-07-04
Age: 16
Location: Canada

PostSubject: Re: On-Forum Tutorial series: Coding   Wed Jul 25, 2012 11:25 pm

This is really useful, thanks for posting. Please do more.
Back to top Go down
View user profile
The Uteen
Sandbox Team Lead


Posts: 1490
Reputation: 68
Join date: 2010-07-06
Age: 16
Location: England, Virgo Supercluster

PostSubject: Re: On-Forum Tutorial series: Coding   Thu Jul 26, 2012 11:27 am

Interesting. Thanks. Smile
Back to top Go down
View user profile
~sciocont
Overall Team Lead


Posts: 3179
Reputation: 99
Join date: 2010-07-06

PostSubject: Re: On-Forum Tutorial series: Coding   Thu Jul 26, 2012 2:56 pm

I may make a an attempt at this soon.

_________________
Remember our goals: simplicity, science, and playability. Keep them in mind always.
[OE]|[FAQ]|[Wiki]|[My Blog]
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Fri Jul 27, 2012 3:58 pm

Lesson 2:
Now that you know about the int main() function, it is time to go over other functions(a set of statements), variables, and statements(instructions).

In C++ there are over 140 predefined functions already available for use. However, in the development of Thrive, it would be likely that you would often times have to make your own functions. To make a function, you must first make a prototype for that function at the top of your source code under the #include stuff, and above your int main() function. A prototype outlines what type the function will be, the name, and the argument(info in parentheses which can be used) of the function. It looks like the following:

Code:
void GiveMeMySandwich(void);


The first word you see (void, a data type) is the function type, the second word(s) is the name(no spaces allowed), and in the parentheses is the argument. Data types(like void) define what kind of function a function is,and what it returns, or what value is possessed in a variable or argument. here are the major types:

void - Valueless(nothing). with this as your function type, your function returns nothing to the function that called(used) it, therefore the return(); statement(a line in code in a function) is not used.
int - an integer, or whole number, as a function type an integer is returned. there are sub-types for int, but we won't discuss them right now
bool - a Boolean, basically true or false. As a function type, true or false is returned.
float - a decimal number, you can return decimals.
double - what are often called "real numbers", double allows for a decimal or whole number to be used. As a function type a decimal or a whole number can be returned is returned.
char - a character (letters and stuff) as a function type, a character is returned.


So now that we know all that, let's make ourselves a function, first, make sure you're typing outside of(more specifically below) the int main() function. Next put the function type you put in the prototype(in our case, void.) The name(i put GiveMeMySandwich) and an argument( two empty parentheses because our argument is void). After that, put an opening bracket ( { ) and on the next line a closing bracket ( } ) so now our code looks like:

Code:
#include <iostream>

using namespace std;
void GiveMeMySandwich(void);

int main()
{
    cout << "hello. ";
    cin.get();
    return 0;
}

void GiveMeMySandwich()
{
}


As of right now, our function does nothing. In order to make our function do stuff, we must fill it with statements(instructions), and then have our main function call(use) it. A statement you already know is cout <<, so let's use that:

Code:
void GetMeMySandwich()
{
  cout << "You now have a sandwich.";
}

NOTE: you must use ; at the end of every statement to signal to the computer you are done with that instruction.

Now to tell main to use the GetMeMySandwich function. To do this, you type the function name, and give it an argument(if it can use arguments, our function doesn't) and type it out as a statement in main. So let's see our code now:

Code:
#include <iostream>

using namespace std;
void GetMeMySandwich(void);
int main()
{
    cout << "hello. "
    GetMeMySandwich();
    cin.get()
    return 0;
}

void GetMeMySandwich()
{
    cout << "You now have a sandwich.";
}


Alright, looking good so far. In case you're wondering cout << endl; is how you make the next statement come up on the next line(it's like telling your computer to press enter.) Now for my last part of today's lesson, variables. A variable is a letter, or word which holds certain information depending on it's Data type (i covered that earlier). you construct a variable with, a data type, the name, an = operator, and a value relevant to the data type. So a variable would look like:

Code:
int number = 3;


NOTE:you can always just make a variable(no = 3 or whatever), and assign it something whenever you want in the shown way.
variables can be used pretty much like a specialized container. For example, if you have a container for trading cards, you cant stick baseballs in that container, just trading cards. to define what kind of container you're using, you use the previously mentioned data types. In our above case we said we wanted to store integers, so integers(whole numbers) like 3 are all that can be stored in our variable. To give you a sense of one of the ways we can use variables, lets make our program have main give GiveMeMySandwich a number and display it. first, we must change the prototype and actual function to accompany integers. so now our prototype is:

Code:
void  GiveMeMySandwich(int);


as you may tell, we will be using arguments to carry out this process. Now remember that statement in main where we called our custom function? well, now we must give it a value in its argument part. So let's put something like 7 in there:

Code:
int main()
{
   cout << "hello.";
   GiveMeMySandwich(7);
   cin.get();
   return 0;
}


Since that's all done, we're going start making our actual function now. Go to your custom function, and in the argument make your variable by putting something like int number in the following way:

Code:
void GetMeMySandwich(int number)


now to display our number by adding another cout statement:

Code:
void GetMeMySandwich(int number)
{
cout << "You now have a sandwich";
cout <<"here is a number for no reason" << number;
}


Our final source code:

Code:
#include <iostream>

using namespace std;

void GetMeMySandwich(int);
int main()
{
    cout << "hello. ";
    GetMeMySandwich(7);
    cin.get();
    return 0;
}

void GetMeMySandwich(int number)
{
    cout << "You now have a sandwich";
    cout << endl;
    cout << "Here is a number for no reason: " << number;
}


And WooHoo! your own function and variable. Stick around for the next lesson, because i'll be talking about something every video-game uses/needs, OOP(not POOP).

Too long? Didn't read? PICKLE OF SHAME!:


Last edited by jaws2blood on Wed Aug 15, 2012 1:34 pm; edited 1 time in total
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Sat Jul 28, 2012 9:56 pm

Attention, lesson 3 might be a little delayed due to a busy schedule.
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Mon Jul 30, 2012 5:28 pm

Lesson 3:
Today we're going to learn about OOP(Object Oriented Programming). OOP is vital for video games, why? Because, it organizes all those different components in your video game in a nice, clean way. OOP does this through the use of classes(a collection of variables and things), and then objects(uses a class to define it's properties.) Here's an example of a class:

Code:
class gun
{
}; 


The class has nothing in it right now, but what you see is the basic structure of a class. As you may notice, the structure of it is really simple. we type the keyword class(to tell the computer we want to make a class) and then the name of the class, followed by brackets( { } ) to put our stuff in, then a semi-colon to say, we are finished making a class. Quite often(all the time), you're supposed to put your classes into a relevant header file. A header file ( .h ) is not to be confused with a source file ( .cpp, has functions in it ). I will go into further detail with header files some other day. So with our class we can outline the properties of different objects we create in the world, for example, with the gun class i would identify RateOfFire, Damage, and Range(real games have way more than just that):

Code:
class gun
{
      int RoF;
      int Dam;
      int Range;
};


Another thing that goes into classes is the methods(functions done by an object belonging to the class). So for gun, we would have things like void shoot() or something. Thing about methods is you don't code these special functions in the class, rather you code them outside of the class. Next thing to know is you can make stuff in your class public and private. Public and private will be covered next lesson so disregard it for now. As for giving the variables we made values, we can allow objects to do that through methods and functions. We do this by first making a method in our class to set a certain variable's value, then a method to get the value. So you end up with something like this:

Code:
class gun
{
private:
   int RoF;
   int Dam;
   int Range;
public:
   void SetRoF(int rof);
   int GetRoF();
   
   void SetDam(int dam);
   int GetDam();
   
   void SetRange(int range);
   int GetRange();
};


Next, we're going to make special functions that will allow us to use the methods. We do this with the Scope Resolution Operator( :: ). When you use :: , you give the function a type, then you put the name of the class you wish to mess with, :: , and then the method. Like any other function, it must also have the brackets ( { } ). next, we will make statements that allow us to do what we want the method to do. so for setting say, RoF, we may try something like this:

Code:
void gun::SetRof(int rof)
{
      RoF=rof;
}


and for GetRoF, this:

Code:
int gun::GetRoF()
{
    return RoF;
}


We are making the get function have int as it's value because, we will be returning the value of RoF(an integer) to the function that wants to know it. Now let's do the things shown above with all the other methods.

Code:
void gun::SetRoF(int rof)
{
   RoF=rof;
}

int gun::GetRoF()
{
   return RoF;
}

void gun::SetDam(int dam)
{
   Dam=dam;
}

int gun::GetDam()
{
   return Dam;
}

void gun::SetRange(int range)
{
   Range=range;
}

int gun::GetRange()
{
   return Range;
}


in order to make use of the "set" functions i made here as soon as i make an object, we'll use a constructor(method that runs when you create an object) to tell objects to use certain methods as soon as the object is made. We'll do this through arguments so what we will do is make variables that our code can mess with. So, for RoF, i could do rof, for Dam, i could do dam, and for Range, i could do range. So in our constructor's (which is made by simply typing the name of the class, and parentheses for the arguments btw) arguments we would type int rof, int dam, int range. Then we will identify what the method does with a :: function. for the statements, we copy all the statements from the sources we need( SetRoF, SetDam, and SetRange) and jam them into our constructor's statements. So our constructor function looks like:

Code:
gun::gun(int rof, int dam, int range)
{
   RoF=rof;
   Dam=dam;
   Range=range;
}


Now for the other thing you do besides make classes in OOP, make objects. Making objects is simple enough, you simply state the class, then state the name of the object, and then any arguments. So let's say i want to make an ak47 in my game. What i would do is somewhere along the lines I would type:

Code:
gun ak47(600, 33, 300);


Through that statement I would create an object that is named ak47, which is a member of the gun class. The numbers in the arguments for ak47 are RoF(600) Dam(33) and Range(300). Now i know you're probably wanting something you can do with this, well, let's make program. We could make a program that tells people information about the ak47. To do this, we will need cout <<. Here's where i want to explain something, notice how the whole lesson i didn't mention #include <iostream> or using namespace std like in previous lessons? Well, that's because I don't need them unless I want something to do with input or output(the io in iostream) And i can make the inclusion of things from namespace std as painless to the program as possible by specifying what I want, where I want it. How? simple, we take what we want from the std namespace using :: . Instead of the class being on the left, and some method on the right, we'll have the namespace (std) we want to use on the left, and on the right we'll have what we want( like cout ). we can then put our std::cout or whatever in the function where we want to use it in as a statement. After we have put std::cout in the function, we then do this to output certain characteristics of the ak47 object:

Code:
std::cout <<" The ak47's rate of fire is: "<< ak47.GetRoF() << endl <<" with an effective range of: " << ak47.GetRange() << "meters";


And huzzah! We're done. You can obviously screw around with this stuff and make say, a class for certain animal parts, then objects belonging to that class of animal parts. or something else Thrive related. Stick around, and you'll learn more and more, and the possibilities will never stop expanding!

If you broke my heart and didn't read this, pickle. OF SHAME!


Last edited by jaws2blood on Tue Jul 31, 2012 4:53 pm; edited 1 time in total
Back to top Go down
View user profile
Brennus
Newcomer


Posts: 70
Reputation: 0
Join date: 2012-07-04
Age: 16
Location: Canada

PostSubject: Re: On-Forum Tutorial series: Coding   Tue Jul 31, 2012 12:37 pm

Once again, this has been useful, thanks!
Back to top Go down
View user profile
nziswat
Newcomer


Posts: 39
Reputation: 0
Join date: 2012-06-28

PostSubject: Re: On-Forum Tutorial series: Coding   Tue Jul 31, 2012 8:58 pm

This is kinda relevant but are you planning on becoming a coder for this game?
Back to top Go down
View user profile
Brennus
Newcomer


Posts: 70
Reputation: 0
Join date: 2012-07-04
Age: 16
Location: Canada

PostSubject: Re: On-Forum Tutorial series: Coding   Wed Aug 01, 2012 11:44 am

Me? I'll be learning C++ for a while, and I'll contribute some code here and there when I can. I may be able to contribute a lot, I may not be able to contribute much at all (such is life), but I will be contributing code.
Back to top Go down
View user profile
nziswat
Newcomer


Posts: 39
Reputation: 0
Join date: 2012-06-28

PostSubject: Re: On-Forum Tutorial series: Coding   Wed Aug 01, 2012 9:01 pm

Brennus wrote:
Me? I'll be learning C++ for a while, and I'll contribute some code here and there when I can. I may be able to contribute a lot, I may not be able to contribute much at all (such is life), but I will be contributing code.
well both of you guys really.
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Sat Aug 04, 2012 7:43 pm

I'll help a little bit here and there but, I can't code the whole game, or allot. I don't really know if thrive is ready for code yet tbh, there's still basic code stuff to think about and design. As for people who want to learn, lesson 4 is coming soon, so stay strong.
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Sat Aug 04, 2012 7:48 pm

Brennus wrote:
Me? I'll be learning C++ for a while, and I'll contribute some code here and there when I can. I may be able to contribute a lot, I may not be able to contribute much at all (such is life), but I will be contributing code.


How much you contribute will come down to how much time you have, and whether you're a math guy or not.
Back to top Go down
View user profile
The Uteen
Sandbox Team Lead


Posts: 1490
Reputation: 68
Join date: 2010-07-06
Age: 16
Location: England, Virgo Supercluster

PostSubject: Re: On-Forum Tutorial series: Coding   Sun Aug 05, 2012 5:16 am

Good job, two more already. Seems to make sense, although I'm a bit confused on why double is a boolean.
Back to top Go down
View user profile
jaws2blood
Newcomer


Posts: 62
Reputation: 3
Join date: 2011-12-18
Location: USA

PostSubject: Re: On-Forum Tutorial series: Coding   Wed Aug 15, 2012 1:31 pm

The Uteen wrote:
Good job, two more already. Seems to make sense, although I'm a bit confused on why double is a boolean.

Oh my, sorry about that, typo, double can return decimals or whole numbers.
Back to top Go down
View user profile
 

On-Forum Tutorial series: Coding

View previous topic View next topic Back to top 
Page 1 of 2Go to page : 1, 2  Next

 Similar topics

-
» Brief Tutorial On Coding Your Own Route?
» LUA coding
» Ridgerealms coding- Structure Simulator
» Steel Series Giveaway
» POSKY 737 Series AC - FSX and FS9 - Freeware

Permissions in this forum:You cannot reply to topics in this forum
Thrive Game Development :: Technical/Conceptual work :: Programming :: Programming Language-