You are not logged in.

#1 2008-12-12 23:25:10

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Trying to get better with C++

I recently finished up a class on C++, and I want to get better with it, but now that I have no class to really guide me, I don't know what to do with it.

My math classes aren't complicated enough to warrant building a program, not to mention I'm not taking any math classes until next semester.

I've tried peeking into a few open source projects, but the projects are too big to wrap my head around right now, I can't tell what they're doing, or where to start reading.

To sum up my knowledge of C++, I'm good with the syntax, I'm sketchy with pointers still, and I've only been able to do command line programs.

I feel like I need to write code with a purpose, not write it just to be writing it, so I guess just sitting down building a program that doesn't do anything relatively useful bothers me.

So where do I go from here?  What do I do next to better myself?


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#2 2008-12-13 00:48:03

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Trying to get better with C++

I'm a strong believer that "give me something to program" isn't going to get people places. What do *you* want to do? What do you want your computer to do? I'm sure lots of people here would be happy to point you at things and give you a rough design for an application. Just tell us what YOU want to do. Something you would actually use...

Offline

#3 2008-12-13 01:16:05

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

To be honest, I have no idea what I want my computer to do, I don't really do a lot of busywork with it, I mainly play video games.

The only thing I really use Linux for is coding, I like the setup better (gvim & g++).  I can't stand VS.  But one of my goals is to become a game developer one day, so I guess I want to try and develop games.

The only problem is I lack the knowledge to do this, so that's a lofty goal, since games are pretty complicated things.

So with that, lets say I want to make a simple tetris-like game; would this be a hard project to do?  I'd imagine it would be, considering I have no knowledge of SDL, OpenGL, or even GTK.  I can't even make a simple window.


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#4 2008-12-13 01:25:38

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,485
Website

Re: Trying to get better with C++

If you want to be a games developer, you could start off just getting shapes to move across the screen with whatever input device you want to use.  I think there are some fairly basic OpenGL tutorials around so I would find one of them and just see what you can do.  Once you have a better idea how things work, you might want to write a very basic game to test out your skills.

Offline

#5 2008-12-13 04:05:06

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

I never would have thought putting together a couple of shapes would take up a page's worth of code...

I suppose I'm getting something out of this tutorial: http://www.zeuscmd.com/tutorials/opengl … itives.php

I feel like it's holding my hand though, and I guess it is, but it's a start.


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#6 2008-12-13 05:41:01

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Trying to get better with C++

lordxenu wrote:

The only problem is I lack the knowledge to do this, so that's a lofty goal, since games are pretty complicated things.

It's not so bad. Just take it in small steps. SDL (with SDL_Image and so on as needed) makes it pretty easy to get up and running. If you can make some shapes bounce around the screen, then move on to adding something for the player to control and you've practically got Asteroids. A side-scrolling shooter or a Robotron clone are a couple other pretty easy projects.

Offline

#7 2008-12-13 12:03:43

wuischke
Member
From: Suisse Romande
Registered: 2007-01-06
Posts: 630

Re: Trying to get better with C++

You could try to write your own simple raytracer, too. The good thing about designing raytracer is learning about extensibility; to include for instance shadows, reflections, ... in the code. Plus, it will teach you about geometry, which is very valuable for a game programmer.

Tutorials/further reading:
http://www.devmaster.net/articles/raytr … /part1.php
http://www.codermind.com/articles/Raytr … acing.html
http://www.nirenstein.com/e107/page.php?11

Offline

#8 2008-12-13 12:09:22

xen
Member
Registered: 2008-08-17
Posts: 56

Re: Trying to get better with C++

lordxenu wrote:

To be honest, I have no idea what I want my computer to do, I don't really do a lot of busywork with it, I mainly play video games.

The only thing I really use Linux for is coding, I like the setup better (gvim & g++).  I can't stand VS.  But one of my goals is to become a game developer one day, so I guess I want to try and develop games.

The only problem is I lack the knowledge to do this, so that's a lofty goal, since games are pretty complicated things.

So with that, lets say I want to make a simple tetris-like game; would this be a hard project to do?  I'd imagine it would be, considering I have no knowledge of SDL, OpenGL, or even GTK.  I can't even make a simple window.

I'm in my third year of a game programming degree, we have similar interests smile If you like, when I have a little more time (busy end of year rush right now) I can suggest a course of topics that you might like to pursue on the path of game development. In the mean time you should just generally brush up on your C++ skills, make sure you code is neat and readable by others, and take a look at the different styles for labelling variables (e.g. iVarName or varName, or even var_name?) - consistency is important. Also check out the basics of GUI programs, its kinda boring but do all of the 'Hello World' message box tutorials for various bindings such as GTK/Qt to get a better idea of this.

I'm working on a little game engine project in my spare time in support of my dissertation. wink


A wannabe game-developer.
My Blog
My GitHub

Offline

#9 2008-12-13 13:33:35

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

Thanks, that stuff helps a lot. big_smile

And Xen, that'd be cool, I'm pretty much on my own around here, all anyone teaches in SC is business oriented IT stuff, so I really don't know what to look at.


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#10 2008-12-13 22:44:23

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Trying to get better with C++

pauldonnelly wrote:
lordxenu wrote:

The only problem is I lack the knowledge to do this, so that's a lofty goal, since games are pretty complicated things.

It's not so bad. Just take it in small steps. SDL (with SDL_Image and so on as needed) makes it pretty easy to get up and running. If you can make some shapes bounce around the screen, then move on to adding something for the player to control and you've practically got Asteroids. A side-scrolling shooter or a Robotron clone are a couple other pretty easy projects.

Yeah, I was gonna say - start with some 2D games, it's easier. You can get your head around the logic and then "graduate" to 3D stuff later.

Personally, 2D games can be way more fun anyway. Make me a side-scrolling spaceship shooter. Always loved those.

Offline

#11 2008-12-14 01:14:45

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

So I should start with SDL?  I never considered messing with it because it didn't seem like many people used it.

I'll start looking into it though smile


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#12 2008-12-14 01:43:24

nj
Member
Registered: 2007-04-06
Posts: 93

Re: Trying to get better with C++

Good article about making games in general: http://www.gamedev.net/reference/articl … cle892.asp

Good SDL / 2D game tutorials: http://lazyfoo.net/SDL_tutorials/index.php
I would say read lessons 1-8, skim 9-16, read 17. While reading those tutorials, try to make a pong game with what you learn. After that, go for the tetris game.

Offline

#13 2008-12-14 20:27:19

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Trying to get better with C++

lordxenu wrote:

So I should start with SDL?  I never considered messing with it because it didn't seem like many people used it.

It's used all over the place. DOSbox, Cube, Neverball, Frozen Bubble, ZSNES, Xmame, glHack, FCEU, Dxx-Rebirth, Blender, Bzflag, Abuse, and the Linux port of Hexen 2 all use SDL. And that's just stuff I happen to have installed.

Offline

#14 2008-12-14 20:53:35

xen
Member
Registered: 2008-08-17
Posts: 56

Re: Trying to get better with C++

pauldonnelly wrote:
lordxenu wrote:

So I should start with SDL?  I never considered messing with it because it didn't seem like many people used it.

It's used all over the place. DOSbox, Cube, Neverball, Frozen Bubble, ZSNES, Xmame, glHack, FCEU, Dxx-Rebirth, Blender, Bzflag, Abuse, and the Linux port of Hexen 2 all use SDL. And that's just stuff I happen to have installed.

Many cross-platform games use SDL as you mentioned, particularly games that have been ported to new platforms. Many Quake ports, such as ioquake3 use it too.


A wannabe game-developer.
My Blog
My GitHub

Offline

#15 2008-12-15 02:16:42

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

nj wrote:

Good article about making games in general: http://www.gamedev.net/reference/articl … cle892.asp

Good SDL / 2D game tutorials: http://lazyfoo.net/SDL_tutorials/index.php
I would say read lessons 1-8, skim 9-16, read 17. While reading those tutorials, try to make a pong game with what you learn. After that, go for the tetris game.

These tutorials seem to explain a lot, I'll try to chew through them and see what I can do with it.

I never realized SDL hooked into OpenGL, I always thought it was straight 2d software rendering with no flexibility.


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#16 2008-12-15 12:00:38

andr3as
Member
Registered: 2008-10-06
Posts: 53

Re: Trying to get better with C++

If you want to learn OpenGL I would recommend [link]http://nehe.gamedev.net/[/link].
In university I'm learning the basics of OpenGL in a lecture atm, but to me this page is really useful if I want to know how to do something without having to search the slides.
(I thought this was *the* OpenGL tutorial, I wonder why nobody has brought it up until now?)

Offline

#17 2008-12-15 12:35:58

dav7
Member
From: Australia
Registered: 2008-02-08
Posts: 674

Re: Trying to get better with C++

lordxenu wrote:

I recently finished up a class on C++, and I want to get better with it, but now that I have no class to really guide me, I don't know what to do with it.

My math classes aren't complicated enough to warrant building a program, not to mention I'm not taking any math classes until next semester.

I've tried peeking into a few open source projects, but the projects are too big to wrap my head around right now, I can't tell what they're doing, or where to start reading.

You can't run before you walk, or walk before you crawl. It isn't normal - nobody can do it. tongue

lordxenu wrote:

To sum up my knowledge of C++, I'm good with the syntax, I'm sketchy with pointers still, and I've only been able to do command line programs.

Pointers are interesting, especially to users who have started out with higher level languages. I find this way of explaining it easy to grasp after I finally went "oohhhh..." with them: your brain currently directly references "variable" with "data". Move these into two separate (but contextually/conditionally linked to each other, C/C++ being out of the context) mental structures and you'll be halfway there. Then, understand that "variable" can also mean "reference"; pointers are just names describing where data is in memory (referencing it), not representing it in a controlled, managed manner. That's why they're said to point to it.

lordxenu wrote:

I feel like I need to write code with a purpose, not write it just to be writing it, so I guess just sitting down building a program that doesn't do anything relatively useful bothers me.

I understand what you mean: I, for the most part, am very much the same - I disliked writing code for the purpose of writing it (if I learned something from it, that wasn't much of a consolation) until recently, when I realized that C and C++, and programming in general, are mostly commodity items nowadays, with no color, enjoyment factor or character visible anywhere. But it's there - you just have to find it. Also, remember that until one gets past all these seemingly pointless hurdles, the fun stuff is beyond one's skill level and grasp.

lordxenu wrote:

So where do I go from here?  What do I do next to better myself?

<...>

phrakture wrote:

What do *you* want to do?

<...>

lordxenu wrote:

To be honest, I have no idea what I want my computer to do, I don't really do a lot of busywork with it, I mainly play video games.

The only thing I really use Linux for is coding, I like the setup better (gvim & g++).  I can't stand VS.  But one of my goals is to become a game developer one day, so I guess I want to try and develop games.

Is that because that's the only thing you know a computer can do well? Being open minded - and removing or compartmentalizing the whole "but is there a point" thing as much as you can can help here.

lordxenu wrote:

The only problem is I lack the knowledge to do this, so that's a lofty goal, since games are pretty complicated things.

Some of them are, sure. But simple games are simple, as teh lolcat fanz might say. tongue lol

And like I said before, you can't run before you walk or crawl.

lordxenu wrote:

So with that, lets say I want to make a simple tetris-like game; would this be a hard project to do?  I'd imagine it would be, considering I have no knowledge of SDL, OpenGL, or even GTK.  I can't even make a simple window.

Making simple windows is one thing, drawing is another. Since you're a math student, you'll be able to do a lot of fun graphics things here that I wouldn't be able to (I go all "..." and so on I try to learn anything more complex than than basic division and so on tongue) so you only need to wait and do lots of learning in the mean time (at your own pace, of course, rushing yourself is always a bad, bad idea) before you can do some really fun stuff.

SDL is the Simple Directmedia Layer, and as its name hints is pretty simple, so is likely a good introduction (I don't have a graphically capable PC, so I'm mostly guessing here) but may wind up needing some feature or capability that SDL doesn't have one day, in which you may want to consider OpenGL, and if you do you'll almost certainly want the OpenGL Red Book - an older version is available for free online, but the newest revision is only available in book form. I've heard that it's the de-facto OpenGL programming book.

To wrap up, C/C++ are good for small, fast programs, and especially graphics, but on the side you might want to explore other languages as well - for example, if I remember correctly then Fortran is the best mathematical language out there (I might have it mixed up though). Ruby also looks pretty good too, and you can't go wrong with bash scripting too.

-dav7

Last edited by dav7 (2008-12-15 12:38:18)


Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.

Offline

#18 2008-12-16 05:09:29

namegame
Member
Registered: 2008-07-29
Posts: 31

Re: Trying to get better with C++

lordxenu wrote:

all anyone teaches in SC is business oriented IT stuff, so I really don't know what to look at.

Not true at all...

I am a Computer Science major at Clemson University. We focus on Computer Science, especially in the area of graphics. Not one thing about business is mentioned. We focus on efficient algorithm design, software design, operating design, etc.

I live in Clemson by the way, and I've lived here for 19 years tongue

Offline

#19 2008-12-16 05:15:41

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

namegame wrote:
lordxenu wrote:

all anyone teaches in SC is business oriented IT stuff, so I really don't know what to look at.

Not true at all...

I am a Computer Science major at Clemson University. We focus on Computer Science, especially in the area of graphics. Not one thing about business is mentioned. We focus on efficient algorithm design, software design, operating design, etc.

I live in Clemson by the way, and I've lived here for 19 years tongue

Heh, I go to Tri-County; maybe that's why I have a limited scope of things... I heard that you guys had a masters program with animation and game design?


Surprised to see a fellow South Carolinian on a linux forum tongue

I'm actually looking into transferring to a 4 year after this summer, maybe I should look into Clemson after all.

Last edited by lordxenu (2008-12-16 05:16:24)


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#20 2008-12-16 05:41:14

namegame
Member
Registered: 2008-07-29
Posts: 31

Re: Trying to get better with C++

lordxenu wrote:

I heard that you guys had a masters program with animation and game design?

Yep, it's called Digital Production Arts.

Here is a link.

http://www.fx.clemson.edu/

Graphics programming really isn't my cup of tea so I really haven't look into much. However, I work with one of the DPA students and he seems to enjoy it.

Offline

#21 2008-12-17 00:44:26

lordxenu
Member
From: Easley, SC
Registered: 2008-11-24
Posts: 12

Re: Trying to get better with C++

I've got a few questions about some other stuff within C++ (and C) pertaining to pointers; I'm not making a new thread since it still pertains to C++.

Just so I get it straight: (correct me if I'm wrong, I want to see if I understand this)

* is a dereference, as it points to the data within the address.
& is a reference, as it passes the address of the data

I'm still not sure what '->' does exactly, and I think I have * and & backwards.

I've been floundering my way around these things for a while now.


Desktop Specs:  Vista Ultimate 64-bit & Arch 64
     --CPU: Core 2 Duo E8400 @ 4.0ghz  --RAM: 4GB G.Skill DDR2-800  --GPU: ATi Radeon HD 4870
     --HDD: 2 250GB Seagate Barracudas in RAID 0, 500GB eSATA external  --Sound: Razer Barracuda AC-1
Laptop Specs:  Dell Vostro 1500 with Arch 64, Core 2 Duo T5470, 2GB of ram, 160GB HDD, 8600m GT 256MB

Offline

#22 2008-12-17 02:01:30

nj
Member
Registered: 2007-04-06
Posts: 93

Re: Trying to get better with C++

lordxenu wrote:

* is a dereference, as it points to the data within the address.
& is a reference, as it passes the address of the data

That is right.

lordxenu wrote:

I'm still not sure what '->' does exactly

Imagine you have a class or struct

struct Point { int x; int y };

To access the members x and y, you would use the period operator.

Point p;
p.x = 5;

When you instead have a pointer to a class or struct, you would expect to do this:

Point *p2 = &p;
*p2.x = 3;  // nope

The reason you cannot do this is that the period operator has higher precedence than the dereference, so the compiler effectively sees

*(p2.x) = 3;

which is not correct. Instead, you must explicitely group the operators:

(*p2).x = 3;

Because this is annoying to type all the time, the arrow operator was invented.

p2->x == (*p2).x;

Of course, the arrow operator is also a bit of a pain to type, so I map ;z to -> in my editor. smile

Offline

Board footer

Powered by FluxBB