I'd highly recommend sfml if you're looking to use C++. Right now it's only for Windows, Linux, and Mac but they will be adding mobile support in the future. However, it took forever for version 2.0 to come out so I wouldn't expect mobile support any time soon.
If you're looking for something to go multi-platform right now there is cocos2d-x. It's only 2D though.
Awesome!
C++ and everything from scratch in Visual Studio! edit: I forgot to say I also used SFML, which helps alot!
I've played it and enjoyed when it came out but I didn't think about when I added it. Maybe my subconscious did it..
Using Unreal Engine 4 won't really teach you C++, given how heavily UE4's code makes use of their custom memory management classes, their macros, and their classes.
I think a much better way to learn C++ would be to download something like SFML and try to construct an engine or game using it.
Use a 2D graphics/media library (often used for game development) like SDL or SFML, and manually program and draw all of your GUI elements like buttons and such.
You can also dig into the documentation for your widgets library of choice and find ways to customize the look of everything while keeping the default behaviors and layouts and such so you don't have to rewrite the entire wheel.
SFML does not create a depth buffer by default:
http://www.sfml-dev.org/documentation/2.0/structsf_1_1ContextSettings.php
Change line 29 to:
sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "OpenGL", sf::Style::Default, sf::ContextSettings(24));
I remember being in the same shoes as you when I was 14. I got interested in C++ after playing Half Life and that's how I became a programmer.
Keep practising and practising. It's like a foreign language where the more practise, the better you get.
I suggest to learn from a book while also building a 2D game with SFML so you can apply what you've learnt. Go to Stack Overflow if you get stuck.
----SFML---- Languages: mainly C++ but also C, .Net, Java, Phython and a lot more which you can see here http://www.sfml-dev.org/download/bindings.php
SFML is not exatly an engine it is more a 2D framework for multimedia applications. It supports you with all kind of functions as 2D rendering, fonts, audio, texture loading, input, window handling and so on.
It is quiet complicated to learn because i would recommend using C++. But if you are familiarwith C++ and you have a good programming understanding it is perty easy to understand. The documation is great and there are tons of tutorials. The libary is ideal if you are used to C++ and know how to structure your code. But for total beginner it might be to hard, so I wouldn't recommend it.
Pros:
Cons:
So use SFML if you want to build a simple 2D Game, learn C++, lowlevel development. Also you probably have to use thrid party tools like Tiled or a physic libary like Box2D.
NO GOD NO.
This guy is a novice! While entity-component systems are elegant have great benefits once implemented, they require so much more boilerplate and are so much more complex than your average inheritance-based system that he's likely to just get stuck and end up nowhere.
I say this from personal experience. I was curious about component-based systems so I tried throwing a basic engine together using SFML, working sparsely on it over the space of about two months. I got nowhere. I kept getting hung up on details like how to communicate between components (Direct pointers? Message passing?), how to properly configure an object and add components to it, input handling, and all sorts of issues that had nothing to do with creating an actual game.
Later, I was making some boilerplate for a game I was working on with a friend. Based on my previous experience, I used a simple class hierarchy instead: a Sprite class that handled drawing a sprite at a particular position and size, a Mover class that derived from it that handled some basic physics, and an InputMover that used input to drive the motion — that was all I needed to make the early skeleton for the game. In the space of two evenings I managed to make something above and beyond anything I got with the component framework.
tl;dr Forget entity-component. At your stage, it's completely unnecessary. A simple class hierarchy can work wonders.
I'd say for graphics start with SFML. Using OpenGL directly is just going to be overkill for 2D games.
You're going to be spending enough learning to program the gameplay aspects so it's best to let something like SFML take care of drawing stuff on the screen for you.
When you want to make something that specifically requires OpenGL, then make the jump.
I would start by using something like SFML, which will automatically give you a window, graphics, input, sound, file loading etc. without too much effort; and it's relatively portable, which is a bonus.
Start by doing the simplest thing you can: displaying a simple window. If you decide to go with SFML, go through the tutorials to the point of at least displaying a sprite, handling basic input events and playing some sounds. This gives you almost everything you need to make a simple 2D game (other than the game logic, of course). Just take it one small step at a time. Make sure you understand everything before moving on to the next thing.
Once you have a reasonable grasp of SFML, you have to design a game. I would stick with 2D for now, since 3D programming has a pretty steep learning curve. Something like a basic space shooter should be relatively straight forward. For example, draw a space ship sprite that the user can move around with some controls on top of a starry background, and have enemy ship sprites randomly spawn at the top of the screen and move down. Add a gun to the player's ship. The easiest way to do this is to just have a vector of bullet sprites. When the user presses the fire gun, spawn some more at the position of the gun. On each frame, update each bullet sprite to move it and check for collisions. If a bullet hits an enemy, run whatever game logic you want to happen and remove the bullet from the list. If a bullet goes off screen, remove it from the list.
Try to use SFML (http://www.sfml-dev.org/) Its a library for 2d games with input, graphics, sound, and networking. It has near perfect documentation and its very easy to use. I recomend this library to all the people i teach programming, its a very good step before going into big engines or 3d graphics programming.
Just try this one or SDL (more C oriented) and try to create a few 2d games before going into 3d or unity as people is suggesting. At least as a middle step to get better at programming.
Well, it sounds like you have an interest in making games. As you said, making text-based games is a great way to master the basics of control flow, I/O, variables, functions, classes etc, so keep doing that for a while.
When you feel ready, the jump up to proper 2D games doesn't have to be huge. Check out SFML, it's one framework which is easily installed, but can handle all components of a 2D game like graphics, audio etc. It's also modern and clean object-oriented code. e.g. this is an arkanoid clone in only 160 lines of code.
Project Kaneda
What previously was Untitled Cyberpunk Roguelike now has a working title! Eventually I'll come up with a real name but Kaneda works for now.
This week I experimented with SFML and got basic tile rendering with color tinting working. I've chosen to use C++ to code the project with since that's the standard SFML language and I want to get more familiar with it anyway.
I'm hoping to finally be done with rendering and move on to some game logic this weekend. I want to create a prototype for the combat which will have a heavy emphasis on sneaking through unlit areas.
There are loads of libraries out there for graphics programming - anyone looking to start out in this sort of thing I'd recommend taking a look at some of the 2D graphics libraries. Personally I find SFML the easiest one to get my head around.
The tutorials are decent, and will walk you through how to create a window, and start putting images down, as well as responding to the keyboard/mouse.
There's loads of resources over at /r/gamedev too.
Only colliding with non-alpha parts is commonly called per-pixel collision detection. There's a code example of how to do this here but it's SFML 1.6, so the names are (probably) only slightly different, but the idea is the same.
I don't know what you mean by a SFML editor.
You can't clear shapes directly, but you can clear the screen with window.clear() and then redraw the scene without the rectangle you don't want.
For drawing multiple shapes, make sure you're drawing each RectangleShape with your sf::RenderWindow. Also you have (25+(j)), I think you mean (25*j). The following works fine for me:
for (int i = 0; i < 10; i++) { sf::RectangleShape rect; rect.setSize(sf::Vector2f(15, 15)); rect.setPosition(20 * (i+1), 20); window.draw(rect); }
I'd suggest this one: Joe's Blog: An Intro to Modern OpenGL
Or, take a look at SFML to take care of some of the groundwork for you.
And the GLM math library to take care of your matrix/vector math.
You can use: Qt ( http://qt-project.org/ ), SFML ( http://www.sfml-dev.org/ ) or GTKmm ( http://www.gtkmm.org/en/ ), have another api for gui but I didn't know them.
You can find good tutorials on google ( for SFML the website explain correctly the basics and the creator of SFML are on the forum )
First of all headers are not libraries. Those are different concepts. Installing a library means more than obtaining a header (unless it's a header-only library, which is assuredly not the case here.) In this case graphics.h appears to be some kind of archaic relic from the 90s days of Turbo C. There is little chance of that ever working on a modern system, although it appears that there might be a compatible port; however, what good does it do you to learn these completely antiquated tools?
Some examples of modern graphics libraries that are worth learning are SDL and SFML. Even GDI, itself a bit of a relic, would be a better choice than some kind of Turbo C/MS-DOS garbage. If someone is telling you to use these tools, they are doing a very poor job of teaching you properly.
I tried, I got hold of a copy of 2dtoolkit and thought it was a solid piece of software. However, I found doing anything complicated a little frustrating (such as multiple colliders on a single frame). I recently moved from using a 3D engine for 2d games to using a pure 2d soltion, SFML
I like C# since it is a productive language with developer tools like XNA. Unfortunately, poor cross-platform support is a show stopper since I prefer to support different OSes like Linux.
Perhaps you can take a bit of time to familiarize yourself with SFML and Git. It's perfectly fine if you are not familiar with the tools mentioned as long as you have time to learn them.
> Why would someone downvote my extremely thorough and well-thought out answer?
Because your answer is wrong. I agree with you that Python is a good choice to learn game programming but Tkinter? Really? Pygame or SFML for Python is a much better choice.
> If you get serious about coding, get a Mac. OS X is [Unix compliant](en.wikipedia.org/wiki/Single_UNIX_Specification) and endlessly customizable.
No. If you are serious about coding use a proper FOSS *nix system. To quote esr
> Under Mac OS X it's possible, but only part of the system is open source — you're likely to hit a lot of walls, and you have to be careful not to develop the bad habit of depending on Apple's proprietary code. If you concentrate on the Unix under the hood you can learn some useful things.
Source: http://www.catb.org/~esr/faqs/hacker-howto.html#skills2
If you're a software engineer and want to use a programming framework instead of an engine, I can highly recommend SFML. It's beautifully done (imho), has books as well as great tutorials available next to a great community.
C++: SDL or SFML. I have played around with SFML and it was a blast. The documentation for SFML is thorough and well-written, although there aren't many examples of full-length games that use it. There are also a few books on SFML that can help you along.
SDL is more of a tried-and-tested framework, with a large number of games made using it (including FTL). It also has one of the best game-making tutorial series of all time, the Lazy Foo series.
I'd highly recommend one of these two if you're looking to learn programming and game-making simultaneously. It will be a lot more difficult to get a game working than with Gamemaker, however.
If you are still in 161 then I would currently focus on simple games that you can write in C++ and slowly progress to more complex games as your comfort and skills grow. The emphasis should be on practicing good software design in addition to implementation and testing. I think you do tic-tac-toe in 161 right? Then how about Connect 4 next? Or a memory puzzle game? Then maybe start looking at implementing a more graphical game with C++ using the SFML library. Here's a decent list to give you some ideas. Then you'll be in excellent shape for 162 and have a decent start on a programming portfolio. I think one mistake that people make is that they don't do a slow and steady progression of completed work. They just try to jump from brand new programmer directly to writing Fallout 5: The Fallouttening which results in an unfinished mess in their Github profile. Remember, Real Artists Ship.
SFML 2.3 comes with more possibilities, e.g. you can request a debug context, see the official documentation.
There's an example using SFML that you can probably adapt for SDL : http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php
Your SDL window will basically become a widget that you can use as any other widget.
I'd recommend playing around with SFML, try make a basic game, it's a really straight forward media library, the website has plenty of tutorials on setting up and I've had a great time making games with it. If you need help getting started with it, give me a shout. I think I know exactly what you mean progression wise, once you get past the language basics, the best and really only way to truly get on your way is to start making things, breaking things and fixing things.
An API is just a collection of interfaces. It's the same no matter what API you use.
Basically, to use those interfaces you need to understand the documentation. What the documentation says is that if your programs tells the API "ping," the API will respond with "pong."
An API documentation is a great place to look up individual commands an API is capable of, but if you need to know how to use the API to do something in particular, you should be looking for tutorials instead.
Here is something completely unrelated, the C++ game development library SFML has "Tutorials" and "Documentation" distinctly separated.
Tutorials would teach how to get your first window open. Documentation would teach you what does void RenderTarget.setView(const View&)
do.
If you're looking for something similar but a bit more powerful than SDL, check out SFML
As Arelius said though, it's a bit hard to make a good suggestion with limited information about what you need.
> What image library should I use to rotate/flip/resize pictures from files?
Do you know about SFML? Here is a tutorial about loading, rotating, flipping and resizing sprites: http://www.sfml-dev.org/tutorials/1.6/graphics-sprite.php
I recommend acquiring some books that teach C++ programming using games.
If you already have a good foundation in C++, then I recommend checking out SFML, for dealing with all the fidgety things that crop up during game development, like: input, loading images, creating Windows, etc.
> Is it required to install SFML on every computer in order to run SFML projects, or is there some way to include the libraries in the repository?
Download the precompiled libraries, link to them, and include them when distributing your project.
From the website:
> Now compile the project, and if you linked to the dynamic version of SFML, don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is.
> If you are using the sfml-audio module (regardless whether statically or dynamically), you must also copy the DLL of the external library needed by it, which is OpenAL32.dll. These files can be found in <sfml-install-path/bin> too.
I know nothing of code::blocks, but what makes you think the window is crashing? You sure it's not just completing the program, returning zero and closing out?
You need a loop, or for it to wait for user input, or something, otherwise it'll just make the window, go straight through your code and return 0.
Edit: I assume you went through the tutorial to set up Code::Blocks. Try their example program as well: http://www.sfml-dev.org/tutorials/2.3/start-cb.php
Regarding framework: SDL2 is excellent, however, it is written in C so it might be not the best choice if you want to learn C++. There is a similar library with C++ API: SFML. It should introduce you to C++ flavoured OOP.
Not related to game development, but in my opinion very good resource on C++: Frequently Questioned Answers. It does not take new standards into account, but I find it to be still be quite informative and entertaining read.
S.F.M.L is a Simple Fast Multimedia Library that can be used with multiple programming languages and and multiple platforms. It can be used to easily create a window and handle graphics, audio, networking, and other system functions.
I'm using C++ and SFML
The good thing is I have almost complete control over the entire game engine and code.
The bad thing is I have almost no game engine or code unless I make it.
Like tulevikEU, I've had to deal with the various problems of writing Isometric rendering code, and there's tons of obscure edge cases when rendering in an Isometric format that no matter what technique you use, there's always going to be one or two rendering bugs.
If you're just starting to develop games, then I highly suggest Unity.
Library: http://www.sfml-dev.org/tutorials/2.3/
It should be in your repository, I don't know how Ubuntu does things but just search for "SFML". You will need the development packages (-dev). This is mostly geared towards 2D games, but since you said XNA it should be in the same ballpark.
C++ IDE: QtCreator, absolutely best IDE around. I've also heard good things about KDevelop but don't have any personal experience with it.
I'm not sure how familiar you are with getting stuff setup on Linux in general.
According to this page, it looks like the vs2015 versions of these DLLs is 140, not 120: https://www.visualstudio.com/en-us/downloads/2015-redistributables-rc-vs.aspx . So you're probably hitting this issue because SFML is dependent on vs2013 libraries but you're using vs2015. Indeed, there is no vs2015 build here: http://www.sfml-dev.org/download/sfml/2.3.1/ .
You either need to use vs2013, or you might be able to manually download the older C and C++ runtime libraries and convince vs2015 to use them. I'm not really sure how to do that, but you can get the redistributables here: http://www.microsoft.com/en-us/download/details.aspx?id=40784 .
It's a lightweight 'multimedia' API built with OpenGL. It should do everything you'll need for a simple 2D game: Window handling, input, sound, graphics, etc.
I used it often with C++ and can definitely recommend it. They have a pretty large selection of bindings, including .NET (although I've only used the .NET bindings once and can't remember if my experience was good or not).
Also it's got great documentation and is actively developed (as far as I know).
Hi brql,
The concept you're missing (because you haven't been taught it yet) is libraries. These are functions and classes written by someone else to help you accomplish a task. In your case, you're looking for graphics libraries and game engines.
Once you finish your C++ tutorials with the command prompt screens, take a look at SFML and learn about graphics! You'll be on your way to a game developer in no time.
Yeah, what's with the Android/iOS support. The changelog says "Support for iOS and Android platform" in 2.2, the front page (http://www.sfml-dev.org/) says "soon Android & iOS".
I'm going to assume that means, "it's supported but doesn't really work properly". I'd love to hear otherwise.
using these libs: http://www.sfml-dev.org/
try to code (kinda difficulty sorted): sokoban, reversi, draughts, chess, pacman, frog, super mario, alley cat, xenon, offroad, prince of persia... generally speaking, make a cover of any old game and you'll have fun
Video tutorials aren't going to get you anywhere. Get a book. You'll probably have to relearn a significant part of what you've seen so far, but once you reach classes again you can take a look at the SFML Tutorials. It's fairly easy to draw a few shapes on the screen and then make them move around. For GUIs, Qt is a better bet, but I wouldn't bother with it unless you have a specific app you wan to write in mind.
A game/multimedia library like SFML2, SDL2 or Allegro5 is the first thing you need, these will allow you to create a window, draw to it, and take user input (mouse and keyboard.) If you're comfortable with C++ the library's respective documentations / tutorials (SFML / SDL / Allegro) would be a good place to start.
I'd personally recommend SFML, the tutorials and documentation are better in my experiance, and the library is object oriented (textures are automatically deleted when they're out of scope, and so on.)
When you have a good handle on the graphics (drawing shapes and text to a window) and input (reacting to the user pressing keyboard keys) you can move to the actual game. First, you'd want a way of representing the game board, probably a custom Board class containing a 2D vector of integers representing the tiles:
// In the board class std::vector<std::vector<int> > tiles; Board(): tiles(4, std::vector<int>(4,-1)){ // [...] }
The Board class then needs a function to 'shuffle' the peices in a given direction and merge tiles as appropriate (the algorithm for this shouldn't be too complex, but you can always ask here or at /r/cpp_questions if you're stuck). In your game loop, you check for the user pressing the arrow keys, then call the 'shuffle' function on the board for the given direction. Finally you'd need to draw the board to the screen. For this you could create a draw function in the Board class, which iterates through each cell and draws a box for it, containing the value of the cell.
If you need clarification on anything, or more information, just ask.
Have fun! :)
It is cross-platform and imho quite suitable for game-building (and not only on hobby level).
However Game of Life consists not only of funny visualization - make sure you use good (not matrix-based) algorithm which allows to run on almost endless field :)
I thought pygame was dead, yes? As in, the last release was in August 2009?
Also:
eval
of network data!I was really excited when I read the headline, because I was hoping this library would get me away from the tyranny of pygame and its dark masters SDL and software rendering. At this point there's still no reason to switch away from the wonderful SFML and its only-slightly-less-wonderful python (2 or 3) bindings.
Please don't post comments like this if you do not have sufficient knowledge of the programming language used. C# is cross platform. SFML is also cross platform.
One of the dumb things they did was use WPF for the tools which does in fact restrict it to windows since no existing WPF tech exists that is cross platform.
This is created using gource, and the project being visualized is SFML
I hope is this a valid submission to data is beautiful!
The documentation for SFML is absolutely wonderful. The tutorials will walk you through getting everything set up and teach you how to do all the basics, and from there it's simply a matter of looking through the API documentation for any specifics you need.
glDrawPixels is what you're looking for. For simple rendering it doesn't matter too much what you use for windowing.
Also, a while ago I made a real time ray tracing renderer and I used SFML (which I really like). If you plan on doing something similar I would recommend looking into storing your ray tracing output to a texture buffer and drawing that through OpenGL. It's fairly easy to do and will save you a lot of time per frame by avoiding that matrix-passing overhead.
If you're most comfortable with C++, I'd recommend checking out SFML. It will get you up and running with fast 2d graphics, sounds, and some other useful stuff for games.
As for learning - yes, online tutorials are a good start. Or try making a (small!) game you really want to make and look up how to do things as you get stuck. Practice makes perfect.
The best language to pick is the one you know the best. If you know Java best, check out Slick2d if you know C++ use SFML or SDL.
For SDL/SFML you should use the 2.0RC versions as they both bring significant improvements to the libraries. Also as a note, SDL is a C library so you'll likely find yourself writing a good bit of boilerplate to wrap up the library into some classes, so I guess if you want to write the game quick you may want to go with SFML. SFML is a C++ library so it may require less boilerplate but I prefer SDL, mostly because I learned it first so I know it best heh.
So which language do you know better?
I started out in the same situation as you, I've worked as a programmer for years, but only started looking at gamedev seriously in more recent times.
A few years programming experience really gives you a big advantage starting out, there's a lot that you can just skip right past. Since you have c++ experience, and mentioned in the comments that you are interested in something 2d take a look at SFML 2.0. It's a great opengl library that's very easy to pick up, if you have a project in mind, you'll be able to get up and running quickly.
So if you want to go the C++ route, Box2d is a fantastic library for physics. As far as graphics you have a lot of options, but the two most commonly recommended for 2d graphics would be SDL or SFML. Whichever you chose get the 2.0 RC version as both are very near their 2.0 release and each offers significant improvements. I think SFML makes things a tad easier since it's a C++ API and has a bit more stuff in it, but I found that I preferred working with SDL.
Either is fine, it really just comes down to preference.
If you choose C#, XNA is the most commonly recommended one from what i see around here, but I don't have any experience with it, so no comment.
When dealing with game creation, you should probably use some sort of "professional-grade" memory management system. The Boost libraries are quite good and very user friendly. For graphics, the best option (in my opinion, at least) would be SFML. The SFML site has a few tutorials on using its components for game creation, so you can learn a thing or two from those. Hopefully this helps.
If you want to go more low level I'd personally recommend learning C / C++. These aren't exactly the easiest languages to just jump in to so I'd suggest to learn the basics first before jumping to game development.
For the game development itself I'd suggest something like SFML (http://www.sfml-dev.org/). It basically allows you to do the very very basics, like displaying an image and playing a sound, while leaving the rest up to you. Great if you want a more thorough understanding of game development.
> Is There an easy way to position things in the top/right corner, bottom/right corner, and bottom/left corner? Like, how could I position text in the top/right corner of the window?
I just wrote a sample code here.
> What is the best way to place text in a box? (like the text would wrap when hitting the end of the box)
There are neither "wrap" nor "justify" methods in SFML. But you can still use this example in python or use a GUI lib for SFML.
Developing a game/-engine from the ground up is a monumental task. Requiring a good understanding of a particular programming language( C/C++ ), a grasp of design patterns, having a grounding in mathematics never hurts, and the willing to learn.
Before diving head first into developing your own engine, it is best to have a written a few simple games. This will give you an understanding on what an engine is required to do.
I would recommend learning C++ and using the fantastic SFML library. It has great tutorials and deals with the drudgery of loading image files, input, etc. It is also cross-platform which is always a plus, in my opinion. http://www.sfml-dev.org/
There is a myriad of books on the subject that you will definitely find useful. My personal favourites are : Game Engine Architecture by Jason Gregory, and C++ for Games Programmers (2nd Edition) by Mike Dickheiser.
Most people who aim to develop their own engine, generally do it in stages while working on a game. The first game is usually a mess with code repeating itself, objects loading their own content, etc. The second game, the developer will usually attempt to implement a resource system, so content (images, sound, etc) is managed in a central location.
You'll slowly bit surely start implementing systems to resolve many of the problems that are created in building one-off games. Game object communication, input, rendering, etc. With this experience and knowledge you will be able to put it all together and develop a game-engine.
Hope this helps.
I think the easiest way to get started is to pick up a simple library that can open a window, handle input and draw things on the window. An entire engine would give you too many new things to learn.
For C++, I would recommend SFML.
It's a collection of librairies made on top of OpenGL to make graphics programming easier. It was made as an alternative to SDL, which is getting kind of old.
It also has a collection of tutorials put conveniently in a single place to start graphics programming.
With your math background you should be able to switch to 3D without too many problems, but you should start with 2D. I hope you really like vectors and matrices.
When you feel comfortable and have built a few games or programs, you can decide if you want to switch to an engine, dive into raw OpenGL or stay with what you already use.
Edit : I noticed I only talk about OpenGL, there's also DirectX of course (but I don't know the slightest thing about it)
theForger's Tutorial is a good place to start and takes you through the basics.
relisoft's tutorial is also good and covers a lot of the issues you face as a windows programmer.
You might find a library like Simple Fast Multimedia Library may get you closer to what you want.
I would recommend SFML over OpenGL and SDL. If everything's going to be 2D, there's nothing you need in OpenGL, and you're just going to be wasting time setting up the very basics, setting up image, sound, text libraries, etc. SFML is like a C++ based, object-oriented, modern SDL. It makes getting started very simple and covers pretty much everything media-related that you'll need.
If you do choose SFML, I would recommend the 2.0 beta, it's been in development for over two years now and is very stable.
I found the following tutorial to be quite useful, it uses SFML and C++ but the concepts are well explained and generic enough for other libraries or languages.
GatorQue holds your hand through the development of a fully usable engine from the ground up - keeping it very simple and focusing on having generic interoperating systems.
The code is a bit Microsoft-y looking, but that should only bother the pedants :)
What do you mean by "structure"? Are you referring to a codebase or game framework? Or do you mean you've elaborately designed every facet of your dream game? It needs to be the first.
Real quick, since I'm going to bed:
* Choosing C++ might be a decision you'll regret. I personally like it a lot, but to each his own
* Don't even think about 3D. Just don't. I've been using SFML and it's pretty much the best thing ever.
Would you mind giving us a little information on the skill level of your programmer? I'm sure I've got some advice if he's just starting out, but I don't want to waste your time and mine by telling you stuff you already know. ;)
Looks great for a first attempt! A couple of things:
You should split the code into different files, perhaps one file for each class, which is pretty standard and easy to overview
Comments! Commenting the code is a great thing to do, not only does it help others who might look at it (in this case you posted the source code), but also yourself
One thing that annoys me a bit is when a game uses a lot of CPU when it doesn't have to. Not because it slows down my computer but because overuse of the CPU makes it so hot and throttles up the fans to annoying sound levels.
The problem is not that your code is slow or anything, it's just that it is grabbing on to all the resources it can get. If you set a limited framerate (say 60) it will only use what it needs for a nice 60 frames per second. Honestly, who notices 200 fps instead of 60? You should have a look at sf::Window::SetFramerateLimit(60) for that.
Anyway, it's great start and good luck with tetris!
> I've heard good things about SFML, and would recommend it.
Came here to post this. Also, since documentation is ~~usually~~ always important, their tutorials seem rather nice.
You can't read both P14 (the D-Pad) and P15 (the other buttons) at the same time. Setting Bit 4 and Bit 5 of P1 to zero is how GB software communicates with the SGB. I'm not 100% sure what the value of P1 is if P14 and P15 are set to LOW, but iirc, it's something like 0xFF. Anyway, some games will read out P1 twice and combine the results into a single byte, but you can't read P1 once and get the results for all input.
To me, it might be a problem with how you poll any input in SFML. It looks like any input continuously goes from key-press to key-release. Key-release seems fine, so pressing is probably the culprit event. The problem may be that multiple key-press events are being generated. Check out this page on SFML's events, specifically:
> If a key is held, multiple KeyPressed events will be generated, at the default operating system delay (ie. the same delay that applies when you hold a letter in a text editor). To disable repeated KeyPressed events, you can call window.setKeyRepeatEnabled(false). On the flip side, it is obvious that KeyReleased events can never be repeated.
It says key-release events can never be repeated, but I wonder if the docs only mean key-release events aren't continuously repeated once a key is done being pressed. Use some print statements to see if you really are bouncing between key-press and key-release events when a key is being held down. I dealt with a similar issue with Qt recently. I suspect disabling key repeating would solve this issue. I've gone over your code, and it looks sound. In my opinion, most likely an API issue with SFML rather than any emu core error.
I've been a web-developer for the past 2 years and been meaning to break into game-dev. Now I know it won't be easy so I'm giving myself a few years to get really good at things.
I started off with the Unreal Engine but then realized that I'd be better off if I get a handle on cpp and general game-dev concepts first (I have no prior cpp experience), so I picked up Accelerated C++ and SFML and started getting my hands dirty.
As a game-dev (I'm assuming the programming aspect will be a major focus), you'll need to be good at programming, some math, rudimentary physics, game-engine concepts, etc. While engines like Unity and UE4 will do a lot of the heavy-lifting for you, I think game-studios will appreciate people more who have a deep understanding of what's actually going on under the hood.
I plan to implement a few simple games using cpp and sfml (like pong, breakout, etc.) and then see where I can go from there. Maybe, by then I'll have ideas for something of my own.
Let me know how your progress and if you plan to go down the cpp/sfml route, hit me up. I'll be glad to help.
Most people here seem to be suggesting solutions which output images at each stage of the program, which from reading your question is not what I think you are looking for.
If you are looking for a simple means of drawing stuff on the screen then you could use SDL or SFML. I haven't used either but both look fairly simple and similar. SDL is written in C and (obviously) has a very C like api, and SFML is written in C++ and the API might be more obvious to somebody who is more comfortable with c++.
SFML: http://www.sfml-dev.org/
The most accurate way to do this would probably be to render the entire scene to a texture at a low resolution. You could then render that texture upscaled to your window size using nearest neighbor.
I'm not sure how to do that in SFML 2, but I can look at the docs and see if I can't figure out.
Edit: Following the example at http://www.sfml-dev.org/documentation/2.4.0/classsf_1_1RenderTexture.php and using setSmooth(false)
// Create a new render-window sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window"); // Create a new render-texture sf::RenderTexture texture; if (!texture.create(80, 45)) return -1; // The main loop while (window.isOpen()) { // Event processing // ... // Clear the whole texture with red color texture.clear(sf::Color::Red); // Draw stuff to the texture texture.draw(sprite); // sprite is a sf::Sprite texture.draw(shape); // shape is a sf::Shape texture.draw(text); // text is a sf::Text // We're done drawing to the texture texture.display(); // Set the texture smoothing to false for retro graphics texture.setSmooth(false); // Now we start rendering to the window, clear it first window.clear(); // Draw the texture sf::Sprite sprite(texture.getTexture()); sprite.setScale(1600 / 80, 900 / 15); window.draw(sprite); // End the current frame and display its contents on screen window.display(); }
Sorry, what do you mean by "how is that no inheriting it"?
I assume you mean because with class declarations you have the single colon to do that?
That is not inheriting it, because it is not a class definition.
You are just initializing as you should, and that's good :D
Personally, I like to start it on a different line, like this:
MainWindow::MainWindow(unsigned width, unsigned height) : mainwindow ( sf::VideoMode(width, height), "RTS GAME" ) , window_width ( width ) , window_height ( height ) //You should init everything that relies on the constructor in the initialization list {}
or sometimes like this:
MainWindow::MainWindow(unsigned width, unsigned height): mainwindow ( sf::VideoMode(width, height), "RTS GAME" ), window_width ( width ), window_height ( height ) {}
Also, the sf::RenderWindow class has a function to get the size of it, so there is no need to store that yourself.
I used Code::Blocks with it before
I used SFML for creating a window, GLEW for the OpenGL stuff, and GLM for maths.
You can easily link SFML, there is a great tutorial on the offical website: http://www.sfml-dev.org/tutorials/2.2/start-cb.php
However, it seems to be a tutorial for MinGW, but I guess you could a window using other libraries.
After you have created a window, then OpenGL should just work out of the box.
However, to use modern OpenGL, you need to download GLEW.
I recommenced downloading the source and just copying pasting those files into your project (to avoid linker hell).
GLM is just a header library. You can either download it into your project file, or into your compilers include/ directory.
And then you can just used this to learn, brilliant tutorial: http://learnopengl.com/
Try reading this http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use
also codeblocks uses mingw, so this may have some useful info for you http://www.sfml-dev.org/tutorials/2.3/start-cb.php
I'm sorry my instructions were not clear enough. Vanilla SFML uses .hpp files. I do not know why your SFML headers by default use .h, since SFML is a C++ application. SFML uses *.hpp extensions. Follow this tutorial to compile SFML programs: http://www.sfml-dev.org/tutorials/2.3/start-linux.php
You found out wrong then. SFML still provides all the necessary dependencies for Windows.
My guess is that you didn't read the official tutorial on how to use SFML with VS 2015 and thus you didn't link SFML's dependencies, as clearly stated in the tutorial. ;)
Keep in mind that opengl32.lib as well as others are system libraries and are provided by the Windows SDK or Visual Studios, thus they don't get shipped with SFML.
I can tell you how I compile SFML on Windows with Visual Studio Express if it helps. Install the latest Visual Studio Express for Desktop, it's free, you just need to create or use a Windows Live account. Get the Windows package that corresponds to your version here. Contrary to the suggestion I just copied the lib's, includes and dll's to the corresponding directories in my VS install...
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
From a Windows command prompt run the environment setup script...
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
Now compile with cl...
cl /O2 /EHsc /Wall /w /FeSFMLGame SFMLGame.cpp /link sfml-graphics.lib sfml-window.lib sfml-system.lib sfml-audio.lib
As noted here you will have to have the needed dll's in the same directory as the exe.
May I suggest SFML.NET for your rendering library? It has a very modern API and is a wrapper around OpenGL so you get cross-platform and great performance. I have a lot of experience with both so I'd be happy to help you with them. I'm not sure what your exact programming experience is so if you're 100% new I suggest staying to console before going to 2d.
Thanks lambda! The game is programmed in C++ with SFML and a couple other cross-platform libraries, but I'm developing on Windows now. Porting will mostly involve simple loading/filesystem changes and I assume they'll be mostly the same for Mac and Linux. But if a Linux port ends up being a lot more effort than expected I can't justify spending a lot of time there, as the userbase on Steam is sadly miniscule :(. Most likely I'll get it for free with the Mac port though.
You could use just the audio part of SFML. It has a setPitch
method on sf::SoundSource
.
Another advantage of using SFML is being portable.
I use Phaser, too, and funny enough I made a similar jump to making games in C++ a couple months ago. So I can tell you what I used, at least.
Namely, SFML. It's not an exact equivalent to Phaser, because it pretty much just handles the multimedia side - creating a window, drawing to said window, handling audio and network (if you need network).
So unlike Phaser, SFML doesn't provide physics or a built-in game/update loop - you'll have to write those things yourself.
Making a basic game loop is pretty easy, of course. For the physics, if you want a library solution to that, you can maybe try Box2d. I've heard good things, but I've never used it myself. Right now I'm making a 2D Zelda-like game with SFML, so I don't really need to worry about physics beyond simple collision detection.
Check out SFML, I've used it for a university project and there have been coded a lot of cool games using it. I didn't use it to learn C++ but I started out with C# at the same time and I felt like it provides you with enough game-related stuff while not taking away the ability to have "full control" over things like your game-loop, the website also provides tutorials to get you started!
"Unresolved reference" means that something you're using (eg, sf::Color::Green
) does not exist (or could not be found). You've likely not included the libraries properly.
Have you read this: http://www.sfml-dev.org/tutorials/2.1/start-vc.php
I would try to look into some library like openTK or sfml.NET, for low-level rendering. You can google tutorials for the libs. sfml can be easier to you because it's actually proxy from c++ to c#, while keeping some c++ concepts.
If you don't want to keep your hands dirty - download an Unity and give it a try.
http://www.sfml-dev.org/download/sfml.net/ http://www.opentk.com/doc
edit: links
I would start with C++. The concepts you learn coding in C++ will translate to pretty much everything else.
Get your IDE up and running.
Get SFML compiling per their instructions: http://www.sfml-dev.org/tutorials/2.3/
Follow along: https://www.youtube.com/watch?v=kAbkFY6lwAY&list=PLHJE4y54mpC5j_x90UkuoMZOdmmL9-_rg
Or read / supplement: https://it-ebooks.info/search/?q=SFML&type=title
The shell will only expand the tilde when it's at the beginning of a word:
$ echo -I~/tools -I~/tools
$ echo -I ~/tools -I /home/user/tools
And the slash is necessary; writing ~foo
means the home directory of the user named foo, which you don't want. So you either need to put a space there, as jesyspa says, or use $HOME
instead:
$ echo -I$HOME/tools -I/home/user/tools
Also, as jesyspa also says, you'll need to link the appropriate libraries. If the library is installed properly, this can be done easily with pkg-config (e.g. pkg-config --libs sfml-all
), but it does not appear that you installed the package correctly since it in a non-standard location. I recommend that you start over, using your distribution's packages and following this guide.
Thanks!
> one big allocation on the heap isn't costly enough to worry about
That's a relief to know. In that case I'll simply pass a maximal number to the constructor.
>Read up on branch mispredictions if you haven't.
I have. With my name it's basically inevitable. ;)
>if you see one using "new" for the individual particles run away though
I've actually seen an old, often forked game which does that. It works surprisingly well for a four digit number of particles.
It probably just shows how amazingly fast computers have become.
>You could experiment with SIMD but I can't offer any guidance there.
If I wanted millions of pixels, I probably had to do all on the GPU like real AAA engines. Which looks impressive, but is kind of an overkill.
Speaking of CPU-GPU bottlenecks, do you know if it's cool if I use the SDL draw function to draw each particle or should I really put them in some kind of vertex array, similar to http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php ?
Is that even possible for particles? My OpenGL knowledge is rather limited.
Is you're going to use it while teaching OOP, I'd say SFML would be the best choice. Quite simple, can use GPU acceleration, utilizes classes, interfaces etc extensively. You can see a basic code sample here: http://www.sfml-dev.org/documentation/2.2/
Checkout http://www.sfml-dev.org/ . Very well documented and super intuitive to use. Will handle everything like sound, networking, graphics, windows, threading, etc... It's easy to load in graphical resources and tile them down, then handle events like key/mouse presses. I think working through the tutorials will give you a really good idea of how to get the main rendering loop working.
Also, if you haven't already, put your design down on paper first, it will make your development much smoother. Design the architecture to support all the things you want to do so you don't code yourself in a corner and have to rewrite. Rewrites, for me anyway, end up becoming death sentences for my projects. I just lose motivation. But each project I start, I learn something from it.
I'm not sure on where you stand as far as skill level/experience, but this is where I would get started.
The tiles are polygons which I fill with a color. I'm just appending tile vertices to an sf::VertexArray
There's fog of war, but it's pretty subtle. Maybe I should increase it?
http://i.imgur.com/hrrI57k.png
http://i.imgur.com/Tjbj44b.png for comparison with no fog of war
As an aside, if you solely want to create 2D games, there's no need to learn C or C++ for that. There's game libraries in almost every major language. A good choice if you don't have any particular needs other than to make a 2D computer game would be Python with Pygame.
At any rate, you'll need a book to learn C++. The general consensus that I've seen is that there's no good online sources for learning C++ as a beginner. With that said, there are some free resources, such as Bruce Eckel's <em>Thinking in C++</em>, which is available as a free ebook (not for an absolute beginner, but works fine for someone who knows a fair bit of Java already).
I advise against trying to learn C++ from "random Youtube videos and things like that". There's a lot of misleading and confusing crap. It's not exactly a simple language.
Regarding the lack of assignments, you'll just have to force yourself to make projects. For example, a good way to test your understanding of pointers would be to create a linked list. For someone with your experience, a linked list should be very simple and you should already be very familiar with the concept and can thus focus entirely on the language. Then choose other small projects as you wish. It shouldn't take long before you can start creating the game and use that as a project to learn on.
Do note that SDL is perhaps not the best library for a new C++ user. It's a C library and thus you will not be writing idiomatic C++ code. Frankly, I think that sucks balls and is reason enough to avoid it. You could try SFML as a C++ alternative.
Have you looked through the documentation? Why do you think you need to know the client's IP address?
There is a tutorial on communicating with sockets which should get you started.
Websites? I'm not sure about general websites for learning c++
When it came to using the internet to learn I was mostly looking up OpenGL tutorials which happened to be in C++. So I would supplement those tutorials with a book.
OpenGL is a C api which is used for drawing graphics. It's used a lot for video games and 3d related projects which is why I got into it. If writing video games is something that interests you that can be a good way to get into programming. SFML is a even better entry point because it's much easier to use than OpenGL for a beginner
I think doing some of the SFML tutorials to get something up on the screen then playing with them and modifying them is a good way to trigger the programming spark. As you do the tutorials you will most likely come across somewhat foreign concepts but that's good. Then you have something to look forward to learning about when you read your book :)
If games & graphics don't interest you there are other paths you can take but the general process is the same, try doing a small project or tutorial and then go back to the book to cement all the concepts you went over during the tutorial/project.
EDIT : Since I learned to program a lot of online free programming school courses have come about. I don't have any experience with them but you could certainly give them a try. Some examples of those sites are coursera and edx. I can't vouch for their quality though.
It looks like you've compiled your own code in debug mode but told MSVC to link against the release version of the library (sfml-system-s.lib as opposed to sfml-system-s-d.lib etc). As I understand it, this doesn't work well in the Windows world (the standard library has a different ABI between the two).
Have you seen SFML's own guide? It mentions these details, as well as another step you should do for the static ("-s") libraries: define SFML_STATIC in your project.
What kind of gui do you want to start with? One with widgets (buttons, textboxes), or more like a canvas to draw on (like a game)? If the latter, I suggest SFML. It's a great C++ graphic library (has awesome other uses as well). Well documented, beginner friendly.
I've been poking around in SFML. It's C native, and appears to have C# bindings. Offers a fair amount of low-level control, if that's what you're after.
I don't know a lot of experiecne with SFML, and wouldn't necessarily recommend it. Worth looking into, though. Then again, I'm bookmarking this thread to check out everyone else's suggestions, too.
Good luck.
Seconding Pac-Man, has relatively simple AI routines and it's a nice way to approach learning AI as a beginner. Pac-Man Dossier covers the AI of the different ghosts if you're going for an accurate remake of their behaviours.
I suggest making it in SFML. If you're not familiar with C++ this might be a little extreme though. XNA might be the next best thing.
Well, that depends entirely on what you are programming with and what API's you are using. I highly recommend SMFL ...but I am not sure about using it with C#.
Anyway, it has a nice view system for you to use that is a helpful level of abstraction away from the view ports in open GL. You can also just call a particular function and start working with Open GL right there alongside your SFML code.
As for cutting the dungeon up, it is best implemented with a recursive function ...but the tricky part is organising your binary tree properly.
store first room at head of binary tree select a point along the top wall somewhere in the 2nd and 3rd inter-quartile range
i.e. divideRoom = (rand() % (roomWidth / 2) + roomWidth / 4);
I am sure there is a better way to write that.
store the two subsequent rooms as child nodes of you head rinse and repeat
Does that make sense?
*** edit ***
If you are using c# I suggest Unity!