Sign in to follow this  

Unity OpenGL 2D RPG examples/source code

Recommended Posts

Hi, I'm making a 2D RPG in OpenGL and I've been looking for source code, or simply just code snippets to help myself understand how to develop my own. I've not had much luck finding any however, so I'm looking for anything that is related this community might have. Thanks!

Share this post

Link to post
Share on other sites

What exactly are you looking for?

Snippets code for an RPG game, or snippets for displaying at OpenGL?

Given the popularity of the RPG, my guess is that github has a few zillion repositories of the former. For the latter, most OpenGL tutorials start with painting an image onto triangles. Mostly for a 2D game, that's enough at first.


There aren't many snippets published as snippet, since they're basically useless. Snippets only make sense in presence of a large surrounding network of other snippets. It's much like asking for car parts to construct a car. While technically it's possible, it's not the generally recommended way of doing things.

I somewhat suspect you never programmed before, or at least not a game. If that's the case, you may want to head over to the Beginners forum, and read the FAQ for how to start programming or start programming games.

Share this post

Link to post
Share on other sites

I have experience in programming, I'm only looking for OpenGL related code for the RPG I'm making as I'm quite new to learning it. I want to see how other people handled rendering, movement, etc, by putting into practise what I've learning in tutorials I've looked through for OpenGL. 

It's really mostly for reference while I work on my game. 

Share this post

Link to post
Share on other sites

You should address the two concerns separately. First you should learn how to draw sprites and text (I assume you'll want text in your game). If you want to use OpenGL then go for it. There are many tutorials online that will help you with that. Creating a game of any kind is a different thing though. My suggestion is you keep your rendering engine abstracted away from the game logic. You can design your RPG without even knowing which library will you end up using to render sprites on screen. You can imagine having a basic IRenderer interface with methods like DrawTexture() or DrawText(). How you implement that interface won't change the design of the rest of the project in any way.

Share this post

Link to post
Share on other sites

Cocos2d-x - You can use it as a game framework or you can read its sources to understand how it works. Supports 2d and 3d but lots of code and api is for pure 2d. Has scene tree. It doe sno thave particularly good architecture or code quality, but it has lots of users and features and good performance.

OpenFrameworks, Cinder - Use it as framework or learn from their sources. They do not have scene tree. They have excellent api if you are a beginner and you want to learn about opengl 3 style of rendering. I would really suggest at least swiftly reading through api and tutorial to one of these frameworks if you want to know how proper rendering works. But have in mind, that they are missing the scene tree, so you would probably have to implementi it yourself in proper game (not that hard).

godot - Slightly older framework for 3d with scene graph. The rendering code is very easy to read and duplicate in your own rendering framework and has some great simple (tutorial-like) architecture designs in 3d rendering. The api is not perfectly prepared for modern rendering techniques but it is a good beginning for newbies.

Ogre3d  -  Slightly older framework for 3d with scene graph. I would not suggest it for 2d games. It has slightly more features and users than godot, I think. I would suggest to look into ogre3d if you want to know something about gui libraries, lots of gui libraries used in ogre3d can be used stand-alone in your application. Or you can just look at their apis and implementations to learn about gui programming.

SDL, glfw, freeglut, sfml - These are the simplest frameworks that only provide thin layer between your multiplatform c++ code and windowing system in target os. They basicaly create a window and allow you to fetch inputs form keyboard and mouse and to call opengl functions. Use them as frameworks if you want to write in opengl. Or read tutorials for them - many tutorials for these libraries are in fact good basic tutorials for basic opengl.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Similar Content

    • By Mert Oguz
      well, i have started developing games last year, alone , I made a singleplayer 3d openworld rpg on unity you can look at it on googleplaystore ( kooru stone rpg ) whatever, this year, i wanted to make mmo, which gone really fine until I first try real hosting, I was working on "wamp" until then. The reason i am desperate now is that the way my game works.
      On my pc, using wamp mysql , with localhost as host for my game, i was testing my mmorpg with using andorid emulators, ofcourse no lag no issues no restrictions, beautiful dream... But then, I wanted to get real host from web, so, I rent a basic, cheaphest ever web host ( 10$ year ), and transferred my php files along with sql database. 
      So, I launched the game, still no issues, tried to handle 2-3 players by using my pc, phone, friend's phone...  
      After a while, ( after really short time (3-4mins)) host started not to respond, beacause those web hosting were not fit to handle mmos, i predicted that.
      now what i am explaining is that my game works like this and asking what way should i use to handle it :
      - Creates web request ( like : )
      -Reads request ( request result be like = "ID2-GoodGuyXx-23-123-4-123-43 )
      -Builds player using result string
      -does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )
      With my current ultimate cheap web hosting, i can handle 2 players with low lag ( lol ) but, i want to handle around 20-100 players,
      just need a clear path, i have been struggling with google cloud sql and other vps server dedicated server options, i dont wanna pay much and get ripped off.
    • By Apollo Cabrera
      That planet is awesome!!! It's just slowly dissipating into space. Death by emmissions
      Love the green and yellow-orange juxtaposition (did I just say that?).
    • By Marc Vandenbosch
      D.O.T is an abstract arena shooter in which you fight for highscore with good or bad weapons.
      Follow me if you want more info:
    • By Apollo Cabrera
      Yasss!!! My first Unity3d game is on the App Store and Google Play.
      Download please! About 30 minutes to get through 5 missions.
      Let me know what you guys think.
      Thanks a bunch
      Bleeping Bots MacOsx Demo Cut.mp4
    • By TheZeph
      I've been doing some digging and come to the conclusion that I'm not really qualified to identify a game engine for my project alone so I came here asking for some advice.
      My game idea involves movement inside a sphere where you always have your feet on the ground (the "walls" of the sphere), basically an inverted planet. It's supposed to be multiplayer so it's not just you moving in the world. When you jump, gravity (or force etc) pulls your character towards where it jumped from and the character model should have its feet pointing that way.
      I'm really new to this and my own conclusion is that it messes with core functionality of Unreal Engine 4 which makes it really hard for me as a beginner to wrap my head around. It comes with practice but It's hard for me to come to a fair conclusion on what engine to use based on my knowledge. Therefore I'm asking for some guidance. I have most experience with the Unreal Engine.
      What engine would you recommend?
      Is the game idea with being inside a sphere difficult to do in general? Do you have any tips?
      I'm kinda lost at the moment so thank you for the help!

  • Popular Now