Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Beginning C++ programming  (Read 1833 times)

sinoth

  • Bay Watcher
    • View Profile
    • http://sinoth.net
Re: Beginning C++ programming
« Reply #15 on: March 17, 2008, 06:12:00 pm »

quote:
Originally posted by The-Moon:
<STRONG>The best IDE you can use is www.Codeblocks.org.

If you want to do graphics the i suggest you use sdl, and if 3d graphics, then openGL.</STRONG>


I'm gonna agree 100% here.  I used CodeBlocks, SDL, and openGL to make the 3Dwarf visualizer and it was a lot of fun.  CodeBlocks is more lightweight than Visual Studio, and has code completion and a drop-down box with all the functions in a file.  This is really all I wanted in an IDE.

Also, making cross-platform code is extremely easy with CodeBlocks+MingW.  With very minimal tweaking you can have a program running on Windows and Linux, using the exact same CB project for both.

Logged
[i do not regret]

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Beginning C++ programming
« Reply #16 on: March 17, 2008, 08:23:00 pm »

In truth, dev-c++ uses mingw which is gcc/g++ with windows files added.
Dev-c++ is only an IDE for it(I think).
Logged
Eh?
Eh!

Gibbles

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #17 on: May 19, 2008, 10:44:00 am »

How do you go about making a quiz game?

I have an most of the game done, but what I'm stuck on is how to group 5 questions in a loop before asking the player if he/she wants to continue.

How do you do that?

Logged
 break cheetah groins on a daily basis.

Sindai

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #18 on: May 19, 2008, 11:18:00 am »

On the subject of language: unless your game is very performance-intensive (either video-wise like 3D games or CPU-wise like DF) there's not much reason to use C++. C#, Java, Python, or others are all quite a bit easier to develop with for a number of reasons, and for the most part their only real disadvantage is a small performance penalty.

 

quote:
Originally posted by Gibbles:
<STRONG>How do you go about making a quiz game?

I have an most of the game done, but what I'm stuck on is how to group 5 questions in a loop before asking the player if he/she wants to continue.

How do you do that?</STRONG>



Create a loop that asks 5 questions, and afterwards ask the player if they want to continue.

It's difficult to be more specific unless you post your code. It sounds like a question of pretty basic syntax.

[ May 19, 2008: Message edited by: Sindai ]

Logged

Surma

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #19 on: May 19, 2008, 01:47:00 pm »

Wow thread necromancy, at least it was only a couple of months old.  :p

Anyway, Gibbles, what language are you programming in? And yes, a snippet of code would help. But you could probably just use a For() loop. Or even a Do-While loop.

Logged

Gantolandon

  • Bay Watcher
  • He has a fertile imagination.
    • View Profile
Re: Beginning C++ programming
« Reply #20 on: May 19, 2008, 05:29:00 pm »

quote:
I have an most of the game done, but what I'm stuck on is how to group 5 questions in a loop before asking the player if he/she wants to continue.

code:

string answer;
while ("Y"==answer)
{
 answer="";
 for (int i=0; i<5; i++)
 {
 //questions
 }
 while (answer != "Y" && answer != "N")
 {
 cout << "Continue? (Y/N)\n";
 cin >> answer;
 }
}

Logged

Ostsol

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #21 on: May 19, 2008, 06:05:00 pm »

I recommend Python.  While it's not fast, it's an easy language to learn and forces you to learn good indentation style.  While the latter may not be particularily important to you, it sure helps if you ever want someone else to try and read your code.

On a related note:

Python also compiles down to a byte code.  The difference between this and Java is that when you actually run the code Java will compile again to whatever native code the platform uses.  This is known as a "just-in-time" (JIT) compiler.  The result is that Java should theoretically run just as fast as any natively compiled programming lanugage, like C/C++.  Any difference in speed is due to the efficiency of the compiler and the libraries.

Python, on the other hand, does not utilize any JIT compiler in the basic distribution.  Its byte code is interpretted by software, though there are instances where code can be as fast as natively compiled code.  This is most often with libaries written in C.

C# and other .NET langauges are similar to Java.  They compile to a platform-independant byte code (Common Intermediate Language [CIL]) and a JIT compiler is utilized during runtime.

There are distributions of Python that do take advantage of the JIT compilers in .NET and Java: IronPython and Jython, respectively.  For the basic distribution there's also a library called Psyco, which procides JIT compilation (though only on x86 platforms).

Logged
Ostsol

caeono

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #22 on: May 19, 2008, 10:54:00 pm »

quote:
Originally posted by Katawa:
<STRONG>I agree with Heph, especially on the front of C#. If you plan on just developing for Windows it's probably the easiest thing to start with. Especially if you grab a copy of Microsoft's XNA.</STRONG>

I gotta step in for this one. If you're starting out, XNA's libraries can be really alluring. A problem that you'll run into, though, is that most people won't have the requirements to play the games you make. This means you can't get feedback for your projects, you get discouraged, etc. I'd make sure that whatever platform you choose is as widely accessible as possible.

Logged

Empty

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #23 on: May 20, 2008, 12:15:00 am »

quote:
Originally posted by Gantolandon:
<STRONG>
code:

string answer;
while ("Y"==answer)
{
 answer="";
 for (int i=0; i<5; i++)
 {
 //questions
 }
 while (answer != "Y" && answer != "N")
 {
 cout << "Continue? (Y/N)\n";
 cin >> answer;
 }
}

</STRONG>

First you'll need an array to hold the questions and the answers. A string array would do nicely for both.
Then you'll need a loop (for/while) that runs as much times as you have questions. (You could use your question arrays length)

Then in the loop use the int you assigned to keep track of the rotation (i in your for loop) to show the current question (question where i will point to the question of the round.)

And you'll also need to compare the user input with the current round answer. (same as the question answer to get a referance to it)

Oh and you seem to be missing a means to keep track of how many questions an user has answered correctly.

If you don't know of any of the above terms try googling for "c++ term" and usually you'll get some info on what it is and what it does.

If you really can't figure things out ask again and I'll post some example code.

Logged

Sindai

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #24 on: May 20, 2008, 07:35:00 am »

quote:
Originally posted by Ostsol:The result is that Java should theoretically run just as fast as any natively compiled programming lanugage, like C/C++.  Any difference in speed is due to the efficiency of the compiler and the libraries.[/QB]

Well, there are a handful of other factors. One which actually helps JIT Java run faster and several which make it slower than C or C++ compiled directly to machine code.

The factor which actually helps JIT is that a particularly clever JIT compiler can make CPU-specific optimizations to the code that you can't make when you're compiling code in advance to run on a variety of machines.

The things that slow it down are language features whose implementations incur some performance penalty. In most popular languages that aren't C++ this means stuff like garbage collection and runtime type safety, which help you avoid errors or make it easier to debug when errors happen.

I might be forgetting something else, but I think this is mostly correct.

Logged

Gantolandon

  • Bay Watcher
  • He has a fertile imagination.
    • View Profile
Re: Beginning C++ programming
« Reply #25 on: May 20, 2008, 08:54:00 am »

quote:
If you really can't figure things out ask again and I'll post some example code.

Thanks, but this code was meant to be an answer, not a question  ;).
Logged

Keiseth

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #26 on: May 20, 2008, 05:10:00 pm »

I'm not sure if my reply as actually useful to the topic anymore, but I felt I should post it anyway... hmm. =) The ramblings of a beginning C++ programmer follow; I apologize in advance if anything is odd/just plain wrong.

I started out with C++ for the first time a couple months ago, starting with Code::Blocks and moving to DevCPP. The one thing that bugged me is not knowing how the IDE made everything work, although it (usually) did. So I started using a command line, and then a batch file, using Notepad++ for some highlighting and to ease eye-strain.

A fancy IDE is fantastic for a full project, but I think for the first several, smaller ones, working with the bare essentials seems to teach you a lot more. DevCPP was linking libraries for me, compiling all my source code, but I never knew what made it tick. I wouldn't have known all of Gcc's arguments with it. =)

Though I admit I learn things in a backwards way, so maybe my advice is totally counter-productive and I'd appreciate any input or suggestions, myself!

Also, if it's of any use to anyone else here, I learned a ton about C++ and SDL (a beautiful, handy library) with lazyfoo's tutorial: here. I think it expects you to know a bit about C++ already, but its still a good read.

Logged

Nesoo

  • Bay Watcher
    • View Profile
Re: Beginning C++ programming
« Reply #27 on: May 20, 2008, 07:17:00 pm »

quote:
Originally posted by Keiseth:
<STRONG>I started out with C++ for the first time a couple months ago, starting with Code::Blocks and moving to DevCPP. The one thing that bugged me is not knowing how the IDE made everything work, although it (usually) did. So I started using a command line, and then a batch file, using Notepad++ for some highlighting and to ease eye-strain.

A fancy IDE is fantastic for a full project, but I think for the first several, smaller ones, working with the bare essentials seems to teach you a lot more. DevCPP was linking libraries for me, compiling all my source code, but I never knew what made it tick. I wouldn't have known all of Gcc's arguments with it. =)</STRONG>


Oh, I agree completely. I will openly admit that I have no clue what goes on "behind the scenes", and sometimes that bugs me. On the other hand, I do it as a hobby and don't have much time for it, so all I care is that I hit compile and it works  :)

Logged
000508 □ [dwarf mode][flows] flooding over a full pond will kill the fish inside

Mel_Vixen

  • Bay Watcher
  • Hobby: accidently thread derailment
    • View Profile
Re: Beginning C++ programming
« Reply #28 on: May 20, 2008, 09:28:00 pm »

quote:

I will openly admit that I have no clue what goes on "behind the scenes", and sometimes that bugs me


Be happy you dont know it. I have done programming assembler for microcontroller and PCs so lets say its very painful (but quite satisfying). The code is most times the "Horror" and for my 21 Years on Earth my badest dreams were written in assembler.

Logged
[sarcasm] You know what? I love grammar Nazis! They give me that warm and fuzzy feeling. I am so ashamed of my bad english and that my first language is German. [/sarcasm]

Proud to be a Furry.
Pages: 1 [2]