create a simple light 2d Engine using c++ , c# and SDL or OpenGL

Started by
11 comments, last by Sound Master 5 years, 2 months ago

well Hello internet , greeting to all of you smart beautiful Developers people :D 

its something i dream about to make my own simple 2D game engine from scratch

and to make it Easy for my self i thought ill be able to use C# for the game coding and Basic manipulation and Animation ,

and C++ for the Graphic Engine and the heavy stuff of Importing and exporting and rendering 

 

but the problem is i only have Experience in C# and Graphic and Illustration Design ( that's = no worry about the Animation and Assets :D)

so i don't Have any Experience in SDL/OpenGL or C++ i only know some Basic , 

and since SDL/OpenGL tutorials are available in youtube i didnt find an advanced one talking about combining between C# and C++ like Unity3D did in their engine 

any help in this will be Awesome :D 

Advertisement

Why not just write it in C#?

And what is your reason for wanting to write an engine, as opposed to merely writing a game from scratch without using someone else's engine?

@Irusan, son of Arusan , well as i heard before c# is kinda limited when it come to graphic and rendering 

1 hour ago, Irusan, son of Arusan said:

And what is your reason for wanting to write an engine

that's require a long long answer but ill make it short as possible 

1 - one of the benefits is to avoid writing the same code from scratch over and over that's why the engine come in handy 

2 - its a passion , something i want to do 

3 - i like making my own tolls ,  it make me feel comfortable ,

4 - i don't feel comfortable using other people engines no matter how they good 

7 -  im tired of the 99 mile page all about complicated User Agreements and term of service of other engines that limit my market

"your not allowed to that , your not allowed to that , , your work belong to us , your stuff included to us .. bla bla bla " im tired from all that bull#@*/ " some of those term of service are longer then (The Hobbits novel series :D ) 

8 - i like to modify and add specific futures to my engine in a way satisfy my needs in any time i want so i don't feel tied waiting year or 2 to get other people adding them in their engines 

and so on and so on ..... i have more and more reasons .. you get the basic idea

and i don't get it when i say "game engine" people start panic , no no man im not looking for something huge 

i just want to create a simple interface with couple of buttons and portViewer to see what im doing live and manipulating the characters and the Assets in my game using the mouse , that's it and the rest will become better over time , that's it just a simple light engine as i mention

but why im asking because i stock when it come to combine c++ with c# , and call those Vector functions from c# as Library like unity 3D engine do , they use c++ to handle the heavy graphic coding and c# as a tool for game management and assets manipulation  , that's basically what i want to understand 

 

 

Right, I get all that. I'm making my own game from scratch too. What I'm getting at is that you don't need to develop an "engine" to make a game. Obviously, you will need some subset of the functions that an engine provides in order to make a game but making "an engine" implies you are building a reusable general purpose library (and, usually, set of tools) that is intended (or at least designed) to be used by people other than yourself and is developed separately from any particular game. Most modern games are built on top of such separable engines, but it's simply not the case that they have to be.

You'll likely want to make them in a way that is fairly separated anyway for reasons of good code structure and design, but what I'm trying to get at is that you don't need to think about that as "writing an engine" and if you do think of it that way and if what you really want to do is build a game from ground up using your own technology you are better off thinking and talking about it in those terms than trying to "write a game engine". That's just making a rod for your own back. Of course, if making an engine is really what you want to do, go for it, but don't do it out of the incorrect view that you have to have an engine to write a game.

You're right, of course that Unity uses C++ for it's more low level stuff as do most games and game engines. My point is that you don't have to. C++, implemented well, is faster than C# but not by much. For a 2d game, on modern hardware, that difference is likely to be totally unimportant, at most you're nudging up your required spec by a CPU level and likely not even that. If you're comfortable in C#, I'd stick to that, learning OpenGL and then like is already a big job for you. Most of the time, how you design and structure your code, and manage your render calls is going to be a more important factor than the small difference in performance between C++ and C#.

Indeed if you want a 2D game, you dont need all the extra stuff and make a very small file, nothing is loading.

If you can play sounds, music, render meshes, and show bitmaps, some alpha blending, joystick input = a game engine, or if you dont want to freak out : a game project.

Then you can add many things, the fun part, it is hard work to get to the fun part, lazy people skip the hard work and want only fun part.

It is very rewarding to make your own "engine", even if it only does 2D stuff.

If you dont like small things you are not worth the big things.

4 hours ago, adamhuman said:

well as i heard before c# is kinda limited when it come to graphic and rendering 

That is patently untrue.  I've been doing this kind of stuff in pure C# off and on for almost 15 years now, and performance is not an issue, especially for 2D games.  Frankly, the kind of performance I bet you think you need requires quite a bit of effort even in a native language like C++.  If you insist on going down this path, realize your world is going to get quite a bit more complicated by merging the C#/C++ world together, so a look at C++/CLI might be beneficial. That said, I would definitely not recommend you try and mix up the languages like this.

4 hours ago, adamhuman said:

1 - one of the benefits is to avoid writing the same code from scratch over and over that's why the engine come in handy

The same could be said by using Unity or Unreal.

4 hours ago, adamhuman said:

2 - its a passion , something i want to do

I get that.  But ask yourself, what do you really want to do here?  Do you want to make a game?  Or do you want to make a rendering API and/or Engine? For myself, I don't care about the former, I gave up on that when I was in my 20's.  But I do continue on building the latter even now in my 40's because I find it fascinating and fun for learning, knowing full well that I will almost certainly never make a game.  Knowing where your objective is makes getting there a lot less frustrating. 

4 hours ago, adamhuman said:

4 - i don't feel comfortable using other people engines no matter how they good

I'm going to assume based on this statement that you have very little experience in real world programming. But if you feel this way, you'll never function well in a team, or even using any API that you didn't write. You need to break yourself of this "not written here" mindset, that way lies madness.

4 hours ago, adamhuman said:

7 -  im tired of the 99 mile page all about complicated User Agreements and term of service of other engines that limit my market

Given the bullshit surrounding Unity the last couple of weeks, this is entirely understandable.

4 hours ago, adamhuman said:

8 - i like to modify and add specific futures to my engine in a way satisfy my needs in any time i want so i don't feel tied waiting year or 2 to get other people adding them in their engines 

That's a good reason.  But you need to ask yourself:  What do I need to implement that isn't provided by another engine?  Can I implement it using the other engine (FYI: the answer is yes more often than not)?  How do you know you can't do what you need in the other engine without having tried it?

It's all well and good to want to learn, and write a bunch of stuff, but you also have to set realistic expectations and mixing things up like this is likely going to end in frustration. If all you want to do is plop a few sprites on the screen and have them pew-pew at each other, then you can do that in any number of engines without much work. 

If you insist on writing code to build up your game/engine/whatever, then pick a single language that you're comfortable with, pick up an API (MonoGame for C#, SDL for C++, etc...) and play with it until you see some results. The benefit with both MonoGame and SDL is that they're open source, and as you get more comfortable with using them, you can crack them open and see what makes them tick, and then you can think about writing an engine or whatever.

Before you totally understand unreal-engine and unity you could have wrote that yourself, then you understand better.

What do you think big game companys are made by : they copy old code and make improvements, maybe they made it 64 bit also, etc etc.

I also copy codes from 10 years ago or longer in all my projects, once some code is good : it is worth a lot, that is why they also dont give the source code to the core of these engines,

many times open source projects give not so professional codes like non-open source has.

 

I have these tested codes and want not make it open-source, meanwhile i would like to work with someone.

So i,m keeping the engine for myself, how can i work with another programmer then ?, use pre-compiled .dll files like big engines.

No way i go spend time on hiding codes, maybe i will make a topic and ask for people to build together, with improvements from others,

i think that topic gets to hectic to manage and fight whos code is best.

On 1/23/2019 at 1:40 PM, adamhuman said:

combining between C# and C++ like Unity3D did in their engine 

Don't bother, just stay in C# land and do the whole thing there.

You won't get any benefits from C++ <-> C# interop, only headaches. Unity only did it because they knew their users would prefer to code in C# as a scripting language than C++, so that was one of their USPs.

I would recommend you look at MonoGame. Think of it as a C# equivalent to SDL.  Both MonoGame and SDL are not engines, they are frameworks - huge difference - you still have a lot of stuff to code for yourself, but they do provide you with enough abstraction to get going without having to worry (too much) about platform differences.

If you do want to go lower-level then you could look at one of the C# bindings for OpenGL.

 

I study math for game developers, writing shaders in GLSL, development a little 2D game engine. At first time I decided to use C++ but it was very long and complicated. I chose C#/OpenTK, TypeScript/WebGL and JS/ES5/WebGL. I chose OpenTK because it is not dead and it is used by MonoGame and Xamarin. I study ES5 because it is popular and TS because it is better then ES5 and similar to C#. TS and C# was created by Anders Hejlsberg. I want to make a little games for practice with multiplayer using: SocketIO (or WebSockets), NodeJS, MondoDB.

I read these books. I love them. These are exellent books for beginners:

I like these resources to study math for game developers:

I wrote Resource Manager for loading shaders and textures. I know how to draw multiple textures, colored and textured objects at same time (how to switch shader programs). I know how to write Camera class and another things.

This is my current process:

 

ColoredAndTexturedObjects.png

I am using C, SDL and OpenGL. I have 2D physics engine for now but am planning to extend it to 3D as well. 2D is just a side project. I have already enough infrastructure for simple 2D games yet for 3D, still, a lot of work needs to be done.

Embrace pressure. Because without pressure happens no progression...

This topic is closed to new replies.

Advertisement