• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:05
CEST 00:05
KST 07:05
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 1 - Final Week6[ASL19] Finals Recap: Standing Tall12HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0
Community News
Esports World Cup 2025 - Brackets Revealed10Weekly Cups (July 7-13): Classic continues to roll4Team TLMC #5 - Submission extension3Firefly given lifetime ban by ESIC following match-fixing investigation17$25,000 Streamerzone StarCraft Pro Series announced7
StarCraft 2
General
The GOAT ranking of GOAT rankings RSL Revival patreon money discussion thread Who will win EWC 2025? Weekly Cups (July 7-13): Classic continues to roll Esports World Cup 2025 - Brackets Revealed
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series $5,100+ SEL Season 2 Championship (SC: Evo) WardiTV Mondays Sparkling Tuna Cup - Weekly Open Tournament
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
External Content
Mutation # 482 Wheel of Misfortune Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Flash Announces (and Retracts) Hiatus From ASL BW General Discussion Starcraft in widescreen A cwal.gg Extension - Easily keep track of anyone
Tourneys
[Megathread] Daily Proleagues Cosmonarchy Pro Showmatches CSL Xiamen International Invitational [BSL20] Non-Korean Championship 4x BSL + 4x China
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread CCLP - Command & Conquer League Project The PlayStation 5
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2025! Things Aren’t Peaceful in Palestine
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 2024 - 2025 Football Thread NBA General Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Men Take Risks, Women Win Ga…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 656 users

Game Programming: Part Two

Blogs > CecilSunkure
Post a Reply
1 2 3 4 Next All
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-02-28 16:52:29
February 22 2012 21:54 GMT
#1
If you haven't yet seen my first game programming post, go check it out! Here's the second one.

I've been as busy as ever learning all I can while attending my CS degree, and I'd love to share what I learn for free with people that want to better themselves. Don't know programming much, but interested? Anyone can learn, it's not some difficult or far away unacheivable goal that only genius can reach (see below section for absolute beginners). I know of three different ways to program video games for new developers that I can recommend*: C, Flash, and Python.

*Can't recommend anything I haven't tried! There are definitely other options out there, these are just what I have personal experience in.

Python
Lets face it, Python has some very clean syntax. It also has some extremely newcomer friendly features such as dynamic typecasting -this means all variables are typeless to the programmer. You can assign a string to a variable, then an integer without compiler errors. There are wonderful resources like PyGame for developing games within Python. All around programming with Python is always extremely fun for me, and so I recommend it to new programmers looking to try out different things.

Flash
Flash doesn't have as awesome of a syntax as Python, in my opinion, but it's also very easy to use and learn to develop with. ActionScript is the name of the language used to develop Flash applications. ActionScript 3 is what is currently released to develop in.

There are immense amounts of documentation out there for anyone to get going on developing games in Flash, and due to the easy access of such resources and easy-going nature to get projects up pretty quick I highly recommend flash to anyone wanting to learn to program video games as a hobby.

There are even awesome places like Kongregate, or the iPhone app store that allows Flash games to have immense potential in generating revenue!

C
Now for C. Why C? Why not Java, or C++? Well I recommend C for those who have a desire to eventually work in a professional setting for game development in C++. Grounding yourself in C first gets you accustomed to working in a language that gives you complete access to everything you want. Langauges like Python hide a lot of low-level interaction from the developer to make things easier or more time-efficient. However, in real-time applications that are demanding on hardware require a much more fine-tuned and optimized structure to function well. C++ lets professionals do this, and it is the industry standard. However, I'm a strong proponent of learning C before C++. Learning C first lets you understand the limitations of C on an intimate level, and by learning of these limitations you learn to make highly effective use of the features presented in C++.

I'm currently at that stage of transitioning from C to C++, and so I'll be writing about this subject next. There will be a detailed post about object orientation within C, with regards to inheritance and especially to polymorphism, although I've written a short version here.

+ Show Spoiler [Class-like Objects in C] +
In C you can make use of structs and function pointers in order to emulate the class system within C++. If you've read my state manager post and understand the benefits it provides, then you can easily incorporate class-like objects in your C code. Each object is simply a structure. Each object holds the following function pointers:

  • Construct - Allocation and loading of any required space or data to attach onto the object via pointers. This would include AI data, animation sequence, etc.
  • Initialize - Initialize allocated space from the Construct function, and initialize all data to prepare for use.
  • Update - Uses delta time to update all of the object's data and perform all behavior logic.
  • Draw - Render object and other effects from object to screen.
  • Destruct - Deallocate all space allocated involving the object.

The object struct also has a tag inside of it (just an integer will work, preferably an enum value) to determine what type of object your struct is. Then when the object is allocated through your memory management system, you initialize these function pointers to point to a set of functions corresponding to the type of object you are creating. For example I could have a file called Bat.c to create a bat object. Inside of Bat.c I have functions BatInit, BatDraw, BatUpdate, etc. When I allocate my object structure and want to create a new bat object, I initialize the function pointers within this structure to the ones in Bat.c. This then allows you to easily loop through a list of all live objects during your update/draw states, and make appropriate function calls to all your different types of objects!

The way this works is by making use of the void pointer. By using a void pointer as your function arguments within your objects, you can create classes, and even emulate inheritance with those classes. If all you do when you inherit from one class to another is extend the structure, then you can make use of simple inheritance. For example say you have a Structure.c file with the corresponding Structure functions to Construc, Destruct, Init, etc. Then, you copy/paste the Structure struct definition into a new header file called GoblinStructure. You then add in same data members to the struct. You can still pass your GoblinStructure to the Structure functions and all will be well. This is because the same data members will be accessed at the same points in memory with the Structure functions no matter if a GoblinStructure is passed or a Structure is passed. If this is confusing, wait for the better-documented post!


I've been keeping a personal blog chronicling the steps taken to become a professional game programmer, as well as attempting to provide a free resource for anyone wanting to learn to program games.

As such, I'd love to share some excerpts from my recent posts with you all! Lets start with a continuation from where my last TL post left off. The last post was about the painter's algorithm, though the more recent ones were more generalized to apply to any coding project.

Excerpt: Variable Sized Struct:
In the previous post I had talked a little bit about image ordering, and image transparency. The way the image data was held in memory was very quirky! We had to create an entire header file for each image, and each image had to be an entirely different structure definition due to arrays of data being different from image to image.

[image loading]


I'd like to show you a method that makes use of some clever macros in order to achieve an interesting variable-sized image structure! The idea was actually brought to me by a friend of mine named Malcolm Smith. Here's the structure design for an object to be dynamically sized during run-time, in our case for images:

typedef struct _Image
{
int width;
int height;
unsigned char *chars;
unsigned char *colors;
} Image_;


In the above structure we have two pointers, one to chars and one to colors. These pointers will point to arrays of unsigned characters, which is the datatype that represents both colors and characters for the Window's console. In order to access these arrays, you should recall that the name of an array can be treated the same as a pointer to the first element in the array. So after we allocate space for our arrays we'll need to initialize chars and colors properly by setting them to point to the first element in our arrays.


In order to go about allocating our space properly we need to allocate the space of the Image_ structure, space for the width * the size of our character array * height, and finally space for our color array * width * height. Here's a call to malloc to this in one single swoop:

Image_ *image = (Image_ *)malloc( sizeof( Image_ ) +
sizeof( width * height * sizeof( unsigned char ) +
sizeof( width * height * sizeof( unsigned char ) );


The nice thing about this sort of allocation is that it isn't broken up into separate allocation calls, which speeds up the process since allocation is slow. This also keeps all the parts of memory in the same location in memory all adjacent to one another, as opposed to who knows where in memory when malloc is called multiple times, thus lessening memory fragmentation.

...

I plan to continue on my series of creating Windows console game to the point where someone can pick up programming without any experience, and finish a fine product in C from scratch! I can remember back in highschool when I first decided I wanted to program for a living and had no idea where to start. Especially for game programming. Back then I wished I could stumble onto someone's blog and find good, concise explanations and answers, as I had nobody I could directly talk to about the subject. Hopefully I can help to solve that predicament for anyone here interesting in learning to program!



Recently I've had the chance to apply some of the concepts I've written about, such as Vector Physics and Program Structure/Design, in a game of Asteroids! Check out a video I made showing some ridiculous particles flying all over.

http://www.youtube.com/watch?v=zDdKNJnv_VQ


If you're the straightforward type, you can take a look at the pseudo code involved in the physics of the video above. It's actually extremely simple, and anyone with an understanding of basic algebra can achieve some very cool physics effects from very simple code:
// Find current direction vector
dirVect.x = cos( radianOrientation );
dirVect.y = sin( radianOrientation );

// Apply forward acceleration
if(keypress( UP ))
vel.x += ACCELERATION_FORWARD * dirVect.x * dt;
vel.y += ACCELERATION_FORWARD * dirVect.y * dt;
// Simulate friction
vel.x *= .99
vel.y *= .99


// Apply backward acceleration (negative forward)
if(keypress( DOWN ))
vel.x += ACCELERATION_BACKWARD * dirVect.x * dt;
vel.y += ACCELERATION_BACKWARD * dirVect.y * dt;
// Simulate friction
vel.x *= .99
vel.y *= .99


// Add a value scaled by dt to rotate orientation
if(keypress( LEFT ))
radianOrientation += ROTATION_SPEED * dt;
// Bound checking for pi and -pi
if radianOrientation > PI
radianOrientation = -PI
else if radianOrientation < -PI
radianOrientation = PI


// Subtract a value scaled by dt to rotate orientation
if(keypress( RIGHT ))
radianOrientation -= ROTATION_SPEED * dt;
// Bound checking for pi and -pi
if radianOrientation > PI
radianOrientation = -PI
else if radianOrientation < -PI
radianOrientation = PI


// Update position with our new calculated values
pos.x += vel.x * dt
pos.y += vel.y * dt



However, what if you're completely new to programming and know really just about nothing? Well, I've written a nice post about getting started with the C language, and I don't assume you know anything! In about an hour you can be well on your way to writing programs that deal with simple mathematical statements, and even print output of those statements onto the screen! Here's an excerpt from the blog post I wrote called I Want to Learn Programming, but I Know Nothing!:

+ Show Spoiler [Blog Excerpt] +
CecilSunkure wrote on his Blog:
So you want to learn to program. Great! So you're reading this article, and here you'll learn to start with C on a Windows Operating System. Starting with C is an excellent place to start, as it grounds you with a very solid base of understanding for programming in general, that of which I feel is easily transferable to other languages! I even feel that once you learn the basics of C and transfer to another language (I recommend Python!) you'll be better off in the long run than if you started with another language and then moved to C (perhaps start with Java and move to C). I won't get into deep details about this point as that's out of the scope of this article, but you should definitely take my word on the matter!

...

You can write your C code in any text editor you like. You can just simply use notepad (to open hit windows key+r and type notepad, then hit enter), though I recommend using the IDE apart of Visual Studio. Once you write some C code, save your file as a .c file and then use a compiler to turn it into a .exe file.

Now what about this compiler business. You might have already googled for a C compiler by now and noticed that there is a multitude of compilers out there. Luckily I have one to recommend to you! Download and install Visual Studio 2010 Express.

When installing you'll be ask if you have a CD. Just say no and download the installation from online. Once you see this screen (mine is reinstalling however):

[image loading]


Be prepared to restart your computer in the middle of the installation. For some reason this installation took a long time, so be patient! After you restart, at the end of the installation it says: requires a key. Go ahead and hit the button to acquire one; you'll need a microsoft address from something like live.com. Once you fill out this lame questionnaire with fake answers copy/paste your key into the box and continue! You're now ready to code your C programs, and compile them! ...


There's also a sneak peak preview of a game I'm constructing with a team of 3 other members for our second semester project... Prepare to be in awe of our awesome pixel art madness! The idea of the game is you play as a Forest fighting against a faction of Grumpy Monsters who are corrupting the land. Game concept was inspired by this unfinished Flash game I found one day: link. The cool thing about the project is that it applies most of all the topics I've been writing about lately, especially the soon-to-come topic of Object Oriented C. How else would you make an RTS without object orientation?

[image loading]
Sneak peak screenshot of semester project!


I know you'll all feel at home playing an RTS game, which is what the above screenshot will be. I'll likely make a blog post about it when the time comes and hopefully have all you RTS pros playtest the game ^^

Future topics to write about and share with TL:
  • Binary collision maps
  • File in/out
  • Object oriented C
  • Simple 2D static collision
  • Image z ordering via linked list
  • Basic Tile-Based Pathfinding
  • And more! Taking suggestions



+ Show Spoiler [Interesting Blog Responses] +

On February 28 2012 15:14 Rayeth wrote:
I think you have some good idea here, but I want to put forward that the C++ vs C argument changes when you don't want to work in a games setting. For example, I work in embedded systems and use C almost exclusively for various reasons (very low level access to things like timers, registers, or other hardware; need to save cycles due to low power processors; and the compilers aren't standard and therefore limit our language choice). So the choice you make on what language to use is really dependent on what situation you're in. Gaming on a modern PC is one thing, but there are TONS of systems out there that don't have gigabytes (or even megabytes) of memory for you to use, and in these cases C (or sometimes even assembly) are pretty much all you've got.

This changes the game completely, of course. Everything becomes about how to optimize memory usage and how to do more with less. Making things work in confining situation is an altogether different type of skill from the creative impulse (IMO) needed to develop games. There is often time very little visual feedback when things are broken, which makes for fun times figuring out bugs. I like to think it makes me very good at spotting and fixing memory leaks, but I can't say that for certain


Anyhow, that isn't to say C++ or things like Python, etc don't have their places in embedded designs too. There are LOTS of different systems out there. Most can be done in many languages and are relatively fast and easy to use. For anyone interested in doing (or even trying out) embedded stuff, I find the MSP430 from Texas Instruments a great starter. Plus at only $4.30 its pretty damn cheap and has a wide array of hardware for you to mess around with. Plus there is a great community that uses that processor family if you need basic help.

Anyhow. Good blog! And remember there are lots of things to do with programming besides gaming. Computers really are EVERYWHERE these days.





Interesting links to get started:
http://pygame.org/ - The PyGame engine! Free engine that's very easy to develope games very quickly with! Extremely fun.
Invent your own games with Python - Very cool book on making simple games with Python!
http://kongregate.com/labs/ - Wonderful website for Flash game development.
http://forums.tigsource.com/index.php?topic=14588.0 - Awesome thread on ascii art, with tools to create
http://labs.bp.io/2011/ascii-paint-bpio-fork.zip - My favorite tool to create ascii art
http://www2.warwick.ac.uk/fac/sci/moac/students/peter_cock/cygwin/part1/ - How to install Cygwin to use the GCC compiler
http://www.crimsoneditor.com/ - Favorite text editor for writing code
http://cecilsunkure.blogspot.com/ - My personal resource to start programming, especially games

***
nath
Profile Blog Joined May 2010
United States1788 Posts
Last Edited: 2012-02-22 22:35:01
February 22 2012 22:29 GMT
#2
as someone who's been programming most of his life, and is very in-tune with the industry (game industry, enterprise software, and startups) I have to disagree with using Flash.

My anger at you recommending flash was cooled off by your description of C, though. But i think you exaggerate how much more helpful it is to start with C just so you understand the benefits and additions of C++ better; its not a huge deal; to me C and C++ are very very very similar and there is no disadvantage of simply learning C++ first, as the usefulness and proper applications of the additional functions of c++ over c can be intuitively learned rather than directly learned by having used pure c.

I would agree with you on learning pure c if you are going to use objective-c for iphone/ios development and don't already know c++. even so in that case, provided its not your first programming language, just learning objective-c and working out proper usage of the features through usage and intelligence/knowledge that grows while you learn, is probably the more efficient route. I firmly believe in separating the learning of concepts and languages, rather than thinking purely in terms of using a specific language to learn a specific set of programming concepts and then moving on to other languages..
Founder of Flow Enterprises, LLC http://flow-enterprises.com/
ClysmiC
Profile Blog Joined December 2010
United States2192 Posts
Last Edited: 2012-02-22 22:55:08
February 22 2012 22:54 GMT
#3
It also has some extremely newcomer friendly features such as dynamic typecasting -this means all variables are typeless to the programmer. You can assign a string to a variable, then an integer without compiler errors.

Holy crap I never knew that. That's just like Game Maker. It's an awesome feature ^^

I think I'm pretty similar to you, as I also want to be a game programmer and I am currently in high school. I'm learning Java in my AP CS class (Java is the only language they teach), and I'm pretty good at it as I already knew some basic stuff going into that class from messing around with Game Maker and the BW map editor (triggers require some programming-like logic).

Next year I'm doing an independent study in CS, in which I plan to go even further in Java, whilst learning C. I know that Java and C have a lot of similarities, so it shouldn't be too messy of a transition.

I enjoy reading your posts, even though I don't understand some of them due to not knowing C's syntax. But I wish you the best of luck as you continue to program your games!

...And also that is some sexy pixel art. I'll play any game with good 2d pixel art, even if it's a shit game. I just love pixel art (even though I suck at it).
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
February 22 2012 23:15 GMT
#4
Please don't recommend Dev-C++. It's out of date and buggy as hell. The express versions of Visual Studio are a much more solid choice.

Something like the Unity game engine would also be a great thing to point out to beginners. It uses C# and / or a variant of Javascript, both of which are probably much easier to learn than either C or C++. There's also no faffing around with setting up an environment or compiler (which I think for me was one of the most problematic and time-consuming things about learning to program).

I think Unity gives a nice top-down view of what actually goes into making a game (art-assets, scripts, textures, shaders and such), and how it fits together, as opposed to starting right at the nitty details in C. I suppose it depends somewhat on the end goal - learning to program, or making games.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 22 2012 23:19 GMT
#5
On February 23 2012 08:15 netherh wrote:
Please don't recommend Dev-C++. It's out of date and buggy as hell. The express versions of Visual Studio are a much more solid choice.

I completely forgot there is the express version. I'll download and try that out, then re-write the post. I wanted to write it about Visual Studio but didn't want to recommend something that wasn't free. Thanks!
Bigpet
Profile Joined July 2010
Germany533 Posts
Last Edited: 2012-02-23 01:53:53
February 23 2012 00:53 GMT
#6
I'm a strong proponent of learning C before C++


This is bad advice imho. There are good and bad reasons for learning C. Learning C to write C-code is fine but learning C to write C++ is just not very smart. Great C programmers make bad C++ programmers and vice-versa.

C++ especially now with C++11 being finalized is becoming a whole different beast than C. I can clearly see the appeal of C. It doesn't have as many complex elements and corner cases but C++ for while now has been a lot more than "C with classes". Mixing modern C++ with "malloc", "memcpy", "free" and the like is just asking for trouble, Many people (including Bjarne Stroustrup the original developer of C++) even discourage using "new" and "delete" in modern C++.

For some examples of modern C++ look at these talks from the "Going Native 2012" conference

Day 1 Keynote - Bjarne Stroustrup: C++11 Style (slides)

Day 2 Keynote - Herb Sutter: C++11, VC++11 and Beyond (slides)

Regarding your little C class-like structs. They are more inefficient than C++ classes. Essentially they are the C++ equivalent of virtual functions and those are discouraged in performance-critical parts of the code. They use more memory per object and prevent optimizations like in-lining.
I'm NOT the caster with a similar nick
KeksX
Profile Blog Joined November 2010
Germany3634 Posts
Last Edited: 2012-02-23 01:51:24
February 23 2012 01:48 GMT
#7
A very useful advice that netherh kinda mentioned is to learn C#. With XNA, you'll be able to program games in no time. For someone that "only wants to program games" this is the best advice one can give imho

I also don't really agree on C being more professional, there really is no significant difference in that regard. If anything, C libs/content is getting outnumbered by newer C++ stuff.

Other than that, nice blog. I always enjoy your blogs.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2012-02-23 02:54:42
February 23 2012 02:52 GMT
#8
On February 23 2012 10:48 KeksX wrote:
A very useful advice that netherh kinda mentioned is to learn C#. With XNA, you'll be able to program games in no time. For someone that "only wants to program games" this is the best advice one can give imho

I also don't really agree on C being more professional, there really is no significant difference in that regard. If anything, C libs/content is getting outnumbered by newer C++ stuff.

Other than that, nice blog. I always enjoy your blogs.

I'd recommend C#, but I haven't used it, so I cannot. I also don't think "C is more professional" than C++. I just really liked learning it and its limitations before moving on to C++. I'm also told by a lot of respectable professors here that it's a very good approach in learning.

On February 23 2012 07:29 nath wrote:
as someone who's been programming most of his life, and is very in-tune with the industry (game industry, enterprise software, and startups) I have to disagree with using Flash.

Haha don't forget I said as a hobby. You know, for fun. A side project.

On February 23 2012 09:53 Bigpet wrote:
Show nested quote +
I'm a strong proponent of learning C before C++


This is bad advice imho. There are good and bad reasons for learning C. Learning C to write C-code is fine but learning C to write C++ is just not very smart. Great C programmers make bad C++ programmers and vice-versa.

I didn't really intend to say you should learn C to write C++. I just meant I think it's proper to learn C and it's limitations before learning C++. Note that I implied you still have to learn C++ after you learn C, as in I implicitly acknowledged that they are different, or as you stated different beasts.

On February 23 2012 09:53 Bigpet wrote:
Regarding your little C class-like structs. They are more inefficient than C++ classes. Essentially they are the C++ equivalent of virtual functions and those are discouraged in performance-critical parts of the code. They use more memory per object and prevent optimizations like in-lining.

Me and my little C class-like structs aren't claiming to be efficient or all-powerful. The point in me using and writing about them, is in their organizational advantages. I'm just a Freshman student writing about my learning experiences hoping to share them with others.
memcpy
Profile Blog Joined April 2010
United States459 Posts
February 23 2012 06:22 GMT
#9
On February 23 2012 09:53 Bigpet wrote:
Show nested quote +
I'm a strong proponent of learning C before C++


This is bad advice imho. There are good and bad reasons for learning C. Learning C to write C-code is fine but learning C to write C++ is just not very smart. Great C programmers make bad C++ programmers and vice-versa.

C++ especially now with C++11 being finalized is becoming a whole different beast than C. I can clearly see the appeal of C. It doesn't have as many complex elements and corner cases but C++ for while now has been a lot more than "C with classes". Mixing modern C++ with "malloc", "memcpy", "free" and the like is just asking for trouble, Many people (including Bjarne Stroustrup the original developer of C++) even discourage using "new" and "delete" in modern C++.

For some examples of modern C++ look at these talks from the "Going Native 2012" conference

Day 1 Keynote - Bjarne Stroustrup: C++11 Style (slides)

Day 2 Keynote - Herb Sutter: C++11, VC++11 and Beyond (slides)

Regarding your little C class-like structs. They are more inefficient than C++ classes. Essentially they are the C++ equivalent of virtual functions and those are discouraged in performance-critical parts of the code. They use more memory per object and prevent optimizations like in-lining.


You're making the assumption that he plans on using C style and functions in future C++ programs. It's nice to learn C first because you can learn the syntax and basic usage without jumping straight into the added complexity of objects, references, virtual functions, etc.

It's also good to know the subtle differences between C and C++ in case you ever find yourself needing to write a C program.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 24 2012 04:04 GMT
#10
On February 23 2012 08:19 CecilSunkure wrote:
Show nested quote +
On February 23 2012 08:15 netherh wrote:
Please don't recommend Dev-C++. It's out of date and buggy as hell. The express versions of Visual Studio are a much more solid choice.

I completely forgot there is the express version. I'll download and try that out, then re-write the post. I wanted to write it about Visual Studio but didn't want to recommend something that wasn't free. Thanks!

Updated the post for a much better IDE/compiler!
blade55555
Profile Blog Joined March 2009
United States17423 Posts
Last Edited: 2012-02-24 08:07:37
February 24 2012 08:06 GMT
#11
Hm I remember when I was learning programming everybody recommended me to go straight to C++ because if I learned C then C++ I would get bad habbits from C. I remember asking it on a popular programming forum that I can't remember for the life of me lol. So I disagree with you on learning C first.
When I think of something else, something will go here
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 24 2012 19:30 GMT
#12
On February 24 2012 17:06 blade55555 wrote:
Hm I remember when I was learning programming everybody recommended me to go straight to C++ because if I learned C then C++ I would get bad habbits from C. I remember asking it on a popular programming forum that I can't remember for the life of me lol. So I disagree with you on learning C first.

You definitely learn habits from C that don't apply to C++, and vice versa. I think that's pretty minor compared to the advantages though. But I can totally understand, you stand by what people told you and so do I.
delHospital
Profile Blog Joined December 2010
Poland261 Posts
February 24 2012 20:38 GMT
#13
On February 25 2012 04:30 CecilSunkure wrote:
Show nested quote +
On February 24 2012 17:06 blade55555 wrote:
Hm I remember when I was learning programming everybody recommended me to go straight to C++ because if I learned C then C++ I would get bad habbits from C. I remember asking it on a popular programming forum that I can't remember for the life of me lol. So I disagree with you on learning C first.

You definitely learn habits from C that don't apply to C++, and vice versa. I think that's pretty minor compared to the advantages though. But I can totally understand, you stand by what people told you and so do I.

Learning C before C++ is good advice. C is a nice little language. Once you're familiar with it, take a deep breath and start a never-ending process of learning the mess that is C++.
ShadowWolf
Profile Joined March 2010
United States197 Posts
February 25 2012 17:31 GMT
#14
The problem I have with advising to learn C before C++ is it implies there's some underlying benefit or advantage when, in my experience, there isn't any. Not to mention it looks like you're using Visual Studio so you're learning C89, which is quite out-dated and you'll never be exposed to much of the stuff you'll see in modern C compilers (there's a C99 and C11 standard of which VC supports nothing beyond that which happens to exist in both C & C++).

I can't think of what magic tricks you're expecting to learn by learning C before C++, so I can't think of why you'd actually want to learn C before C++ except in the case that you're going to write C code and not C++. The earlier you expose yourself to "complex" (they aren't by the way) topics like objects, relationships, generic programming, and what-not the easier it will be for you. Not to mention it's a lot easier to jump down a level from C++ to C than it is to go up a level from C to C++ in terms of abstractness.

Plus learning C++ you'll learn quite a few basic C concepts. Even if you don't plan to use them, you'll have to learn about char, etc. You can't work with the Win32 API and live in a pure C++ world unfortunately.

No. Learn C++ first. The C subset of C++ is easier to learn for C/C++ novices and easier to use than C itself. The reason is that C++ provides better guarantees than C (stronger type checking). In addition, C++ provides many minor features, such as the `new' operator, that are notationally more convenient and less error-prone than their C alternatives. Thus, if you plan to learn C and C++ (or just C++) you shouldn't take the detour through C. To use C well, you need to know tricks and techniques that aren't anywhere near as important or common in C++ as they are in C. Good C textbooks tends (reasonably enough) to emphasize the techniques that you will need for completing major projects in C. Good C++ textbooks, on the other hand, emphasizes techniques and features that lead to the use of C++ for data abstraction and object-oriented programming. Knowing the C++ constructs, their (lower-level) C alternatives are trivially learned (if necessary).


- http://www2.research.att.com/~bs/learn.html
Spikeke
Profile Joined October 2010
Canada106 Posts
February 25 2012 21:26 GMT
#15
Now my turn for criticism! >

Python: I've never really used it, seems simple enough. Not needed as much as you think. Although getting a feel for a basic-like syntax might help with beginners.
Flash: Ew, game programming with Flash is lame, more for non-programmer people.
C: I learned C++ "before" C and I wouldn't say it was any harder. I'm not going to nit-pick what pro and cons of learning each language is, just want to say that C++ is more modern and the benefits of learning C++ is that C knowledge comes free with it, otherwise you will have to go out of your way learning C++ after learning C.

I think it's awesome that you want to share information. But I think you can do it in a more structured style. This post seems to have several directions and bombards with information. If this for beginners like you say, then you should fully type out the syntax in your sample code, (like using curly braces and following coding standards). Also there is no way a beginner will understand complex syntax and terms so don't even bother. Bringing up void pointers and vectors in a introductory thread is too much for complete noobs, there are other things they need to learn first.
emucxg
Profile Blog Joined May 2007
Finland4559 Posts
February 25 2012 23:47 GMT
#16
Nice blog man. I have done a lot small programs with different kind of algorithms(I love math-like challenges xD), but never done any games yet.

But,ya im definitely interested

I have one question, when i start coding a game, for example tic tac toe, should i always start from GUI first or not?
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 25 2012 23:51 GMT
#17
On February 26 2012 08:47 emucxg wrote:
Nice blog man. I have done a lot small programs with different kind of algorithms(I love math-like challenges xD), but never done any games yet.

But,ya im definitely interested

I have one question, when i start coding a game, for example tic tac toe, should i always start from GUI first or not?

Nah I think you should just work in a windows console. Check out my series on creating a Windows Console game after you make a few programs in C.

For C reference, I suggest C Programming a Modern Approach 2nd Edition by K.N. King. That books absolutely rocks.
Warpath
Profile Joined April 2010
Canada1242 Posts
February 28 2012 04:46 GMT
#18
Flash is great if you want to make some quick cash on the side, easily. But if your looking to make a larger, deeper game, or get into a big or independent company you'll want C++ or C#, or maybe even LUA depending on the game.

Knowing C is never a bad thing simply because (obviously) its a faster language that has some pretty good usage. But with classes it makes transitioning to or from C an awkward experience as well as alloc commands that are wildly different from just using deconstructors.

objective C is a good language that will look good on a resume as well if you want to branch out.
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 28 2012 06:05 GMT
#19
On February 28 2012 13:46 Warpath wrote:
Knowing C is never a bad thing simply because (obviously) its a faster language that has some pretty good usage. But with classes it makes transitioning to or from C an awkward experience as well as alloc commands that are wildly different from just using deconstructors.

I don't think any learning programmer will feel transitioning to or from C to be so awkward as to think it would have actually been better to not learn C at all. I consider transitioning to/from C to be very trivial in terms of syntactical awkwardness, or even awkward in terms of switching to/from a procedurally oriented language like C.
Rayeth
Profile Blog Joined April 2010
United States883 Posts
February 28 2012 06:14 GMT
#20
I think you have some good idea here, but I want to put forward that the C++ vs C argument changes when you don't want to work in a games setting. For example, I work in embedded systems and use C almost exclusively for various reasons (very low level access to things like timers, registers, or other hardware; need to save cycles due to low power processors; and the compilers aren't standard and therefore limit our language choice). So the choice you make on what language to use is really dependent on what situation you're in. Gaming on a modern PC is one thing, but there are TONS of systems out there that don't have gigabytes (or even megabytes) of memory for you to use, and in these cases C (or sometimes even assembly) are pretty much all you've got.

This changes the game completely, of course. Everything becomes about how to optimize memory usage and how to do more with less. Making things work in confining situation is an altogether different type of skill from the creative impulse (IMO) needed to develop games. There is often time very little visual feedback when things are broken, which makes for fun times figuring out bugs. I like to think it makes me very good at spotting and fixing memory leaks, but I can't say that for certain


Anyhow, that isn't to say C++ or things like Python, etc don't have their places in embedded designs too. There are LOTS of different systems out there. Most can be done in many languages and are relatively fast and easy to use. For anyone interested in doing (or even trying out) embedded stuff, I find the MSP430 from Texas Instruments a great starter. Plus at only $4.30 its pretty damn cheap and has a wide array of hardware for you to mess around with. Plus there is a great community that uses that processor family if you need basic help.

Anyhow. Good blog! And remember there are lots of things to do with programming besides gaming. Computers really are EVERYWHERE these days.
The Innocent shall suffer... big time.
1 2 3 4 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 1h 55m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 139
Nathanias 138
Nina 102
ZombieGrub100
Dota 2
canceldota139
NeuroSwarm62
League of Legends
Grubby4693
Counter-Strike
flusha478
Foxcn456
Stewie2K418
Super Smash Bros
Mew2King85
PPMD58
Heroes of the Storm
Liquid`Hasu560
Trikslyr53
Other Games
summit1g10883
FrodaN3868
shahzam439
Skadoodle190
C9.Mang0190
ViBE92
ROOTCatZ80
Sick59
Liquid`Ken3
Organizations
Other Games
gamesdonequick4093
StarCraft 2
angryscii 28
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• sitaska39
• musti20045 33
• RyuSc2 18
• Kozan
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• HerbMon 17
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2585
• masondota21633
League of Legends
• Doublelift2613
• TFBlade915
Other Games
• imaqtpie1952
Upcoming Events
PiGosaur Monday
1h 55m
uThermal 2v2 Circuit
17h 55m
Replay Cast
1d 1h
The PondCast
1d 11h
WardiTV European League
1d 17h
Replay Cast
2 days
Epic.LAN
2 days
CranKy Ducklings
3 days
Epic.LAN
3 days
CSO Contender
3 days
[ Show More ]
BSL20 Non-Korean Champi…
3 days
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
Sparkling Tuna Cup
4 days
Online Event
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs Zhanhun
Dewalt vs Mihu
Hawk vs Sziky
Sziky vs QiaoGege
Mihu vs Hawk
Zhanhun vs Dewalt
Fengzi vs Bonyth
Esports World Cup
6 days
ByuN vs Astrea
Lambo vs HeRoMaRinE
Clem vs TBD
Solar vs Zoun
SHIN vs Reynor
Maru vs TriGGeR
herO vs Lancer
Cure vs ShoWTimE
Liquipedia Results

Completed

2025 ACS Season 2: Qualifier
RSL Revival: Season 1
Murky Cup #2

Ongoing

JPL Season 2
BSL 2v2 Season 3
Copa Latinoamericana 4
Jiahua Invitational
BSL20 Non-Korean Championship
Championship of Russia 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters

Upcoming

CSL Xiamen Invitational
CSL Xiamen Invitational: ShowMatche
2025 ACS Season 2
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
BSL Season 21
K-Championship
RSL Revival: Season 2
SEL Season 2 Championship
uThermal 2v2 Main Event
FEL Cracov 2025
Esports World Cup 2025
Underdog Cup #2
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.