Beginner game-development in C++ and lua [closed] - c++

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am a total Beginner in C++ and programming generaly.
I have watched a couple of hours tutorals of C++ and read alot about it (Could you recommend some tutorials?), but what I´ve come across and couldn´t understand was Librarys.
I want to develop games in C++ (I think, it seems most interesting atm).
I can understand that I need a library for game programming in C++, but I don't know much about what a library is specifically, and where to find these librarys.
Also, I´ve read that Lua should be good to script the games with. I would like to know if this is true?
If its true, I would like to know where to find tutorials for Lua?
If not true, what is good then?
Thank you for your time.
This is my first question here.
I apologise if it wasn´t a proper question for this website, or if the english was bad.
I still hope you can give me some kind of answer and/or response.

You may want to try out Löve2d, a framework across Windows, Linux, and MacOS X for writing games in Lua. It bundles various game libraries for sound, graphics, physics etc so that you don't need to deal with that directly, and it lets you focus on the writing of games.

A good library to get started with game programming is SDL. http://lazyfoo.net/SDL_tutorials has some great tutorials to help you get started (the most comprehensive and easy to understand that I've found), but you need to understand program structure and such to get some practical use out of the tutorials.
OpenGL is pretty standard for 3D game programming, but it's more advanced than SDL. I'd recommend making sure you understand at least basic C++ before you move on to game programming... http://cplusplus.com/doc/tutorial would be a good place to start.

Here you can get very good and complete video tutorial of cs Indian institute of technology

I'm sure someone will come along and post an essay answering your questions in more detail, but here are the short answers.
A library is nothing more than a reusable collection of code. People write code and package it up for other people to use in their own projects. Libraries you would need for games include libraries that handle graphics, audio, networking, font/image loaders, etc.
Lua is great to script games with. It integrates very nicely with C/C++. Visit Lua's home site for tutorials.

Check this link out http://cplusplus.com/doc/tutorial/ for libraries here is the STL http://cplusplus.com/reference/.
Here is a reference on Lua, http://lua.gts-stolberg.de/en/index.php?uml=1.

can understand that much that I need a library for game programmig in C++, but I dont know much about, what A library is specificly, and where to find these librarys.
#TheBuzzSaw already answers what a library is, so I'll answer where to find. But wait, before WHERE, you have to know WHAT library to use. There are a lot of game libraries out there, both low level (loosely coupled between components) and high level (tightly coupled). The low level ones have separate functionality for graphics, sound, AI, etc. processing and usually each functionality can be used for things other than games. While the high level ones "glue" them together to form something that's ready to use as a whole (for instance, it provides scene class with events, music, etc. you just have to set some values to use). Due to the many number of then, I can't really say where to find before you know which one to use. One quite complete one is SDL, it's a low level one. Allegro is another one.
Also, I´ve read that Lua should be good to script the games with. I would like to know if this is true? If its true, I would like to know where to find tutorials for Lua? If not true, what is good then?
Lua is good, and it's used a lot in games. Ruby is good, some games use it. Python is good as well. Basically, most scripting languages are good for game scripting. You just have to consider what language features your game required, how fast you want it to be usually contradict with its syntax flexibility, etc.

Related

How to develop small software or application? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Hya Gurus,
I've been learning c++ for 8 - 10 months and want to develop a software or small applications (i am self taught using some books) so just consider me as C++ entry level programmer.since i don't know win32 etc for GUI development i can use some library.
I know most of c++ features , data structs , algos and have read some c++ book and scott meyer's effective c++.
but problem is that i am unable integrate all my knowledge to build a software and i think i am a adhoc coder. when i see even small simulation or little application codes i understand the code sometimes (sometimes not since understanding them is hard by just seeing code) but i find even code of page 4 - 7 so large that i think i can't develop applications.
for e.g : if i want to develop my own chm reader or FTP or any appz or softw you consider serious coding, how do i develop it? then i find myself completely lost by just start typing code i know won't ever be able to develop it. (i feel 0% confident)
so what i want to know how programmers like you guyz learn to develop serious application when after drilling their teeths in c++ only, do i need some other books to learn how to develop software? or what is the process to become serious application developer ?
Any help is very appreciated.
P.S (Impotant) : i'd love if you could tell me how you became serious developer after learning C++ , what you had done etc pleaseeeeeeeeee. and any personal advices to me .
Edit:
I don't know UML or Soft Engineering , do i need to learn them?
Thanks a lot again ))
Programming large applications is a long and arduous process. Even with medium sized software.
Even the veterans need time to read new code. I remember just recently starting work on an existing software project that had around 150 classes. It took a while just to figure out how the basic input was handled, let alone the whole structure.
What you need to focus on is increase your confidence in building software.
Try creating something trivial, something you know you can program. Try to make it a bit bigger by adding some features, not much though, and keep doing that. Over time you will be a bit more confident in big code.
Programming takes practice and you need to keep at it. It might sound like a daunting undertaking but real confidence in a language takes years of practicing.
Look at the questions here about good software books as well.
I would suggest that you read up on the usenet groups on c and the books by Scott Meyers and Andrei Alexandrescu. Whey don't you try to find out what the Loki lib can do.
Also a good place to start is looking at the boost libs.
Find some small project that you like and see what you can learn, it is an iterative process.
You can also join an open source project.
Good luck,
Lars
you must have perform practicals every day and start with small application then watch project code i hope by performing practical you will easy to understand any code.

Learning about game development, any books recommended? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to write some games, but I don't have any game development experience. Any books are recommended? Is this necessary to have a good Maths skill when taking about some physical actions? Also, is it complex to do some AI design? thz a lot.
Please have a look at http://www.gamedev.net/, especially "Books" and "For Beginners" section.
Also, not disrespect intended, but your question to me sounded like "I think writing games is kewl but I don't want to do any hard work" - which is not a good attitude to take since writing games is among the hardest programming tasks, especially these days.
And yes, you can't survive without knowing a good deal of math/physics to write action stuff for a good game, and writing a decent AI is a pretty complicated thing.
There may be off-the shelf components (game engines, AI engines) already available as an example, look at "Unreal" engine.
I would HIGHLY avoid OpenGL, DirectX and other lower level APIs unless you are interested in the inner workings of such APIs. If you are just starting out there are a great number of game development libraries tools you should look into ...
Unity 3D
Torque
XNA
Here are some book samplings on all three of these tools...
Unity Game Development Essentials
Bunch of Torque Books on Amazon
Bunch of XNA Books on Amazon
Unfortunately I can't comment specifically on any of these books as I have not read them but I have worked with all the frameworks I mentioned. Pursuing any of them will put you on the road you are interested in, which is learning about game development.
Yes you should have a good grasp on linear algebra, physics, etc. I'm not sure of your education level but high school math should give you a grasp of most of what you need.
There are tons of sites on game development with tutorials, discussions, etc. Gamedev.net is a great place to start looking as has already been mentioned. Start participating in their communites, asking questions, etc. Try out the various libraries I've mentioned and see if you find them difficult, easy, etc. One may suit you more than the others.
I support the DVK suggestion. GameDev is the best place to start. And NeHe (nehe.gamedev.net) has dozens of tutorials ranging from basic to advanced OpenGL.
My advice to you is to focus primarily on OpenGL, and learning how the 3D world works. At this point, you'll probably need a math book, specially for linear algebra and trigonometry. It may take a month, at least, to understand the camera, the coordinates, and to get familiarized with terms and concepts.
A good math background would be helpful to play with physics, however, you can learn as you go. The same is valid for AI, but you'll need more complex algorithms and statistics than math itself.
As for the books, I recommend the following:
Beginning Game Programming (the collection made by GameDev)
3D Math Primer for Graphics and Game Development
The OpenGL redbook is a good reference too.
There are many others I'd suggest, but these will give you a good start.
I'm also not suggesting any book on AI or Physics because it would be, at most, a guess.
Game programming gems (Book series). They could be hard to read, but many chapters are enlightening...
A good game framework could be found on many projects, if you want starts quickly.

What are the best affordable c++ audio libraries? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm looking for a c++ audio library that can play mp3s and mix audio. I can spend some money on it, but I'm on a somewhat tight budget, so the less the better. It really needs to just run on Windows and Mac OS X although Linux and embedded devices are a big plus. Anyone know of a good library or two?
Thanks!
From the game development world, you'll find a lot of good libraries. Obviously "mixing" doesn't tell what exactly you want to do but in a lot of games we mix tracks and sound to get some kind of ambiance so I guess it can be useful for you:
UPDATE: fmod now have a free indie license.
FMOD http://www.fmod.org/ : might be expensive even if they have a "casual" (think "indie") license. However, it's certainly the "standard" in the industry because it's uncontestably very powerful.
Irrklang http://www.ambiera.com/irrklang/ : have been used and recommended by several indie game developers. It's cheap, even if you buy the most expensive version.
Bass http://www.un4seen.com/ : used in several games so good quality, but more exepensive than Irrklang while cheaper than FMOD.
Clam http://clam-project.org/ : this is more free and flexible that the previous libraries but also might be too flexible for your need.
CAudio https://github.com/wildicv/cAudio : wrapping OpenAL with a C++ interface and adding higher lever constructs, it might not fit your need, depends, but also I'm not sure of the quality of the library; maybe worth a try as it's the most open-source of all.
If you are not pressed by time (or want to help), there is also Plaid/Audio, a promising software audio processing library which is still a work in progress but is extracted from the engine used by SourceSelf (a game which use player's sounds -like, your voice- as input).
I'd have a really close look at sox. It's excellent. We're using the sox C++ library to do real time transformation of RTP streams. Works well.
JUCE is an awfully nice portable toolkit for graphics and audio. The main architect created it for real time audio processing, but it's evolved into a wider range of tools.
No firsthand experience, but PortAudio is highly recommended.
Though it does do ten zillion more things that you don't mention, I can't fail to recommend Qt with Phonon -- I learned about it only earlier today (from another Q&A on SO!) and it's opening new frontiers for me. If you need even a tiny fraction of the incredible power of Qt, that's definitely something worth trying (LGPL, so free and unencumbered as long as you don't modify the library itself).
libmad - MPEG Audio Decoder
http://www.underbit.com/products/mad/
Have you looked at libavcodec? seems like it would be what you are after. You are able to grab it from the ffmpeg site.
Look at TempAu
It is lightweight and simple, crossplatform and plays mp3.

Suggestions of excellent examples of real C/C++ code [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I'd like to study some good C/C++ code. The code should:
be good in style and structure, presenting best practices
be a real life program (not an example or toy)
not too big so it doesn't takes ages to analyse it
Windows and/or Unix
I know there are 1000s of open source projects out there. But I'd like to hear your suggestions.
I am Java programmer and I am curious how good project in c/c++ is structured (files), granularity of classes/functions/files, documentation/comments, build tools etc.
Multiple suggestions are welcomed e.g. this is good windows example, that is good pure C etc.
I would specifically mention memcached. It's a great example of fairly short, readable code with a clear purpose.
Second, I would recommend the Apache web server. It's a fantastically well-run open source project that you'll learn a lot from, both about the language, as well as general design practices and networking/threading.
I'd vote for nginx: http://sysoev.ru/en/ as an example of a very good C programming style
Samba: a large, cross-platform (POSIX-based), pure C, very popular network server.
Samba has good developer documentation, and the code base itself is very well organized; I've had no problems diving into just about any location within the code to answer a question I had about its inner workings or to track down a bug.
I find the implementation of Lua is quite nice C source. But languages are a bit odd as an example project.
Diomidis Spinellis has some suggestions in his book, "Code Reading: The Open Source Perspective", Addison Wesley, 2003. ISBN 0-201-79940-5.
Perhaps the book could be useful to you.
URL http://www.spinellis.gr/codereading/
Google's Chromium is pretty huge, but you don't have to analyze it all to appreciate its clean, peer-reviewed structure.
Also, it's a good example of nicely done developer environment deployment.
Here's the main file for relayd, which is a daemon that handles load balancing and failover. It's nicely written, full featured, clean C code. It's big enough that you get a feel for a "real world" program, but not so big that you can't get your head around it with some work. Great for secure, well written networking code, daemons, etc.
Modesty aside, there's also a little tiling window manager for X that I've helped with. It's quite small but it's a real wm, and the other coders on it have high standards (and hold me to them!)... Nice for learning basic X stuff.
K&R has many good examples of real programs. For instance, on page 115 of the Second Edition there are two simple implementations of the echo command. From there, it might be interesting to see how the command was implemented over time. For instance, there is a version in the GNU coreutils source. A version derived from BSD can be found in BusyBox source.
It might be interesting to see how the newer versions compare to the textbook examples. Why are the programs that are used in real life longer? How much of the code is related to new features and how much is related to dealing with edge cases? How would you write the same code in Java?
As for C++ I would recommend you the Qt library sources and KDE's source code and its programs.
It's beautifully written code and the way that you should program in C++.
More C++ suggestions in: Examples of “modern c++” in action?

What project would you recommend me to get up to speed with C++ [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I know that C++ is a very complex language that takes many years of practice to master.
Taking that into account do you know of a small project (around a 1k of loc) that tests all of C++ major features (inheritance, pointers, memory management, etc).
The thing is I'm a Java/Python programmer and I really want to learn C++ so I've been studying C++ for a while but haven't tested anything of what I've learned beyond small exercises.
I want to take all of that knowledge and put into practice.
Doing this alone you will obtain many harmful habits. It's much better to get an internship with a company that has high competence in C++ development and train under guidance.
C++ is like a grenade without a safety pin – looks cool and you've heard that all "real professionals" use it, but you don't know when it is to explode. A tremendous amount of features that can be used for good or for evil without knowing whether it's really good or evil. That's why guidance is a must here.
A memory manager. That should get you thinking about:
free store management
pointers (of course!)
inheritance (you will want your driver code to use this)
templates (another way to pass the manager around -- driver #2)
designing user defined data structures (a memory block)
efficient use of standard container(s)
algorithms (to move around, figure out empty blocks, defragment)
Effective C++ and More Effective C++
Other than that, pick a (small?) personal project you want to write and do it in C++. You are not going to learn C++ by reading a 1000 line project.
I'm not sure about anything that tests all major features. There are a lot of them, and some are rarely used together (templates and virtual functions come to mind. Both achieve a form of polymorphism, so you often use one or the other depending on your needs.)
A suitable project in that it'd touch on all the important features might be something apparently simple like writing a correct container class, similar to std::vector or std::list. Ensure exception safety, iterator validity, the appropriate time complexity on all operations and every other requirement specified in the standard.
The problem with this, as well as most other projects, is that you won't really know when you're done. Making a resizable array might take 50 lines of code, and 20 minutes of your time. And then a beginner would think he's done. Making it exception-safe requires you to be able to spot all the places where the class might be thrown into an inconsistent state by an exception.
That's a kind of general problem with C++. It's easy enough to think you get it, and the compiler certainly won't notify you of aspects you've forgotten to handle. So you might think your code is perfect, and yet it'll crash for all sorts of odd special cases.
As sharptooth said, for a language as messy as C++, writing code on your own is risky. It is easy to fall into the trap of "I've written some code, it compiles and it seems to run. Therefore it is correct".
Of course you could post your code here or on other sites for review, or maybe just supplement your coding with reading the docs for actual high quality C++ code (most boost libraries tend to have comprehensive documentation, specifying both the rationale for various design decisions, and how it safely handles all the weird special cases that tend to crop up in C++. The C++ standard itself would be another excellent resource, of course. In either case, these might help you determine what problems to look out for)
When I was learning C++, I used it to write my own language for writing Colossal Cave style adventures. Like most computer languages it never saw the light of day, but it did teach me a lot about C++.
Whatever you choose the thing to avoid when learning C++ is GUI programming, which is a trap which will drain all your gumption and probably teach you bad C++ habits in the process.
I'd recommend creating a text based game. That really helped me firm up my C++. Doesn't take too long and you can exercise all the features you want. Come up with the game yourself. It is more fun that way.
Another great idea is to write a simple mathematics library, supporting Vectors Matrices etc.
But with todays libraries, that is only of academic use.
In order to learn C++ it is useful to look at a lot of well written C++ code.
I think the Qt library is quite nice for this so I suggest: Write an Qt application.
Look how they use C++ and create your own graphical components in a similar fashion.
Ideas:
- Stock chart viewer widget that connects to one of the financial websites and scrapes history data.
- Simple Excel like spreadsheet widget.
Depends on what area you want to work in. But nothing worth doing correctly comes in at less than 1000 lines of code.
If you are going to be writing games then try writing a Tetris clone.
If you think you will be using sockets etc then writing a simple chat/irc client would help.
Do you have a specific itch that needs to be scratched? When was the last time you thought "this sucks, I could do better?". Can you do better?
I would recomend writing a Tetris clone.
You can learn a lot of c++ concepts with this and learn a 2d library like SDL or maybe even OpenGL throgh SDL.
It is always good to have a project with visual results and at the end of it you can play it.
There seem to be two themes coming from the answers:
You need to pick a project that might involve more than 1K LOC in order to get the true experience of the project.
You need to also pair up with an experienced C++ developer, who can help you think through problems and avoid pitfalls associated with the language.
You can get around both of these by swing by sourceforge.net and signing up to help with an existing C++ project. As long as you don't mind your code being open source, you should be able to find an existing project to learn from plus experienced developers who can help by reviewing your code and offering guidance.
An interactive world:
A matrix where each position can be a Void or a Being.
A Being is something with a few attributes: age, Time left, gender, neigbor connections, etc. Capable a few interactions: fights, having sex and kids, friendships, etc. Some have special Skills, depending on their fathers (inherited trades)... like ability to kill, ability to make food,, etc...
Possible outcomes of those interactions and skills are changes on the self attributes, or creating offspring (when possible), or change neigbor attributes.
At each iteration, print the matrix as symbols/numbers on the console (depending on the attributes, etc), starting from a Biblical iteration 0 (initial conditions of your choice... you're God here).
Now you got some real-life pattern simulator, and learned something about inheritance, polimorfism, virtual functions, instantiation of classes, etc.
I would suggest a simple text editor would be a reasonable goal.
It's a problem domain that you have a good grasp of.
You have memory management issues, library class reuse issues (stl/curses?), pointer issues, and lots of options where derived classes can be used.
For polymorphism, perhaps, you can have the editor read from a keyboard, or suck commands in from a text file.
There is another good one.... dealing with files.
You don't have to cross platform it. You don't have to open source it. You don't have to show it to anyone. You don't even have to finish it. It can be an exercise just for you.
If you're learning fron a book, it must have plenty of well-thought-out exercises you can implement and learn from. Also check out the university sites and their C++ labs / assignments.