• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Discussion] Creating 2D Games Quickly/Easily ; )

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
I was recently browsing for a good way to render 2D graphics and do windows in c++ w/o using an overbearing engine or library >.<. For example, I avoided things like win32 code (horribly ugly), divx (overcomplicated), opengl (wtfx), and various game engines (cramming things into a box and calling it art is never a good idea).

I found a thing called SFML, which allows you to create windows and graphics with extremely nice looking code ^)^. It works for c++, which is also a major plus. Furthermore, you can use standard c++ (no weird wtf languages or entry points). It also works on Windows, Mac, and Linux (gg). It runs on OpenGL as well and you can do graphics through OpenGL if you want something more complicated (ok I suppose, but OpenGL needs some heavy loving before I'd support it myself).


Here is code for creating a window and waiting for it to close
Code:
#include <SFML/Window.hpp>

int main()
{
    //used for catching events like keyboard input etc
    sf::Event event;

    //800x600 window
    //title: My window
    sf::Window window(sf::VideoMode(800, 600), "My window");

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();

            //there are many other cool events, check them out ^)^
            //i did a notepad thing, was pretty cool ;D. I also did a chat
            //thing
        }
    }

    return 0;
}

Very easy to understand code, main method entry point, and object orientated. If you want to embed OpenGL into the window, you can do that too ^_^.

SFML also has networking, audio playing, and 3D sound playing. The great thing is that again, these libs work across windows, mac, and linux. It's very difficult to find a lib that is fast on those 3 operating systems (one that even works on all 3 without weird things like ming).

If you don't need the sound or networking, you don't need to use them. All of SFML's features are modular (they are all in their own libs). When you want to use a feature, you just link to the lib and you are good to go. This means that you could easily replace SFML's audio with a better sound engine like FMOD if you wanted to.

I think that it is an excellent framework if you want to start to get into game development w/o being overwhelmed by a huge game engine ^_^. This also allows you to work on your own game engine quickly and easily. Furthermore, it is fast ;o.


I have found a couple of problems with SFML (one rather major), but other than that it is great to work with. It is also being actively developed and its tutorials are constantly updated. If you look at the tutorials, you will realize just how small SFML really is, and you only even need a few of the features out of it.


http://www.sfml-dev.org/
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
Apparently no one does 2D acceleration any more. All 2D graphics are 3D graphics clampled to a 2D plane using a different sort of projection. This allows the graphic card manufacturers to optimize their hardware and still support 2D. It also vectorises the graphics to some degree. You can even use tesselation for better curved surfaces (like a bendy rope).

Microsoft provides you with a library in DirectX for 2D support although it is noting more than a wrapper for some Direct3D code (says so in documents) aimed at allowing hardware acceleration for UI components.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,180
When making a 2D game there are two basic types of graphic you have available.

Bitmap
These are like your sprites of old. They are a finite matrix of pixel data that can be directly mapped to your display buffer. You can do the most amazing artwork using these and any modern GPU can render thousands of them without problem (fill rate limited). The disadvantage is they require a lot of memory and storage and do not scale well with resolution (appear small).

Vector
The most popular graphics in recent years. These can be viewed as a resolution independant image description that then can be rendered to a display buffer. Most flash games use these as they produce smooth looking results with little memory or backing storage requirements. They also allow for neat and dynamic effects not possible with sprites such as deformations, damage simulation or smooth rotations. Although they are normally limited to very simple line like drawing you can vectorise bitmaps to allow more complex art but doing so will inherit a degree of resolution dependance based on the size of the bitmap and how much scaling it undergoes. It should be noted that vector graphics is the super set of general 3D graphics used by games like WarCraft III or StarCraft II so it is unsuprising that a lot of the same opperations used for 3D will be used when doing 2D vector graphics making it much more demanding that simple bitmap graphics. It can also be more difficult to create a vector engine as you have to handle a lot of vector and matrix mathematics compared to bitmaps which can be implemented by memory copies.

Almost every game nowdays uses vector graphics as you can achieve superiour image quality using them. However you cannot beat the nostelgic effect that bitmap graphics have if you want a game to feel retro.
 
Level 3
Joined
Oct 7, 2011
Messages
37
You might want to take a look at Slick2D possibly fairly easy to get off the ground and works quite well has no networking but has physics sound and graphics engines is Java based though but you might have more luck using Java if it has to work on multiple OS's
 
Status
Not open for further replies.
Top