Advertisement

Game engine in C and open source, The Box, structural programming

Started by December 22, 2019 10:49 AM
129 comments, last by alex4 4 years, 8 months ago

[Hijack deleted by moderator.]

Attempt to replay to all

If you people like C++ go ahed, debate C++ in post's, or topic's, how good it is and how much you like.

Was for PHP, yes, C as similar sintax to PHP i start doing all thing in PHP and learn how to do a procedural engine and manage code so bringing that experience to C.

Only on The box version 0.0.2 more things will be available for people to follow.

A engine in C is not bad, was some one mention in a Ogre3D topic that a engine in C is needed because all can communicate with C.

It's a matter of syntax and large engine can be programmed in C, was long you know how to inherit stuff, is mainly the only thing you need to avoid repetitions.

How to automate, generate the file project, and functions automacatly for users.

Free game dev is up you can follow all posts on objects, tools, planning etc... in there.

For example working in this objects:

  • color.h
  • path.h
  • control.h
  • grahics.h
  • variables.h
  • interface.h
  • image.h
  • ...

Converting all things to objects, the problem is that most software attempt to put every thing in one file which is bad. Let's say that you only need colors, or variables for next program. A lib png, may use colors and variables. If you have your variables and colors in a jpg lib, you can't reuse, you may not need to add jpgs to a project.

You can program a large program was long you don't repeat your self.

How i do it: Inherit file objects, the point is to declare every thing one time and reuse.

The syntax will be like base C.
color_text = blue;

color_background = blue;

use_colors_defined_before ();

very similar to C base functions, it uses globals variables, to pass information in a object style

char c;

printf("Enter character: ");

c = getchar();

it assumed a printf function.

Advertisement

forget recruit for projects:
may advice work in a open source engine, then all can program to it. Much more easy then do individual projects, then ask for help.
Create templates of projects, something i'm doing for this projects, people will only need to edit. Will save huge amount of time.

@Hermetix C is very intimidating and i have many years of programming procedural code LOL.

Write a proper tutorial:

How the syntax looks line in this project The Box.

Works like Html CSS, but is made with File objects in C.

Values will be persistent until new is added.

include “color.h”

color_text = "black";
color_background = ""white;
button1();
button2();
button3();
color_text = "green";
button4();

All buttons will have text black and background white. Button 4 will have white background and green text. Only one property is updated.

It's the same was CSS. Values are persistent until a new value is add that override part of the values.

- How it's done

variables are global, that's how it's done. The color_ is a reference to the object color.h, which is done manually is not called in code.

the color.h will simple have global variables.

color_text;
color_background;

To change font. font.h will have global variables on that.

font_weight;
font_italic;
font_style;

A example with the font

color.h
font.h

color_text = "black";
color_background = ""white;

button1();
button2();
button3();

color_text = "green";
font_weight = "bold";
font_style = "arial";

button4();

A costume button 4 with a font arial, bold weight, and color text green and a inherit background color white;

-------------

The same can be applied to functions. At the moment i don't have a real example will make one for the tutorial. “Costume_function”.

color.h
font.h
interface.h
costume_function.h

color_text = "black";
color_background = ""white;

button_costumized(); addeds : border, solid, 1 px;
"
property_border_style: solid;
property_borde_width: 1px;
"

button1();
button2();
button3();

color_text = "green";
font_weight = "bold";
font_style = "arial";

button4();

All 4 buttons will have a customized border. First 3 will have: a text color black and background white. 4º button will have a customized style was before. text color green, font weight bold and a different font arial.

No variables are passed to functions at any time, only when needed or variables repeated because, they are inherited, only one time will a variable be declared.

A FILE object is declared only one time in file.h

file.h
FILE * FILE_pointer;

A example with the file pointer.

color.h
font.h
interface.h
costume_function.h
file.h

open_file(); // Get styles

"
receives FILE_Pointer; From file.h
"

color_text = "black";
color_background = ""white;

button_costumized(); addeds : border, solid, 1 px;
"
property_border_style: solid;
property_borde_width: 1px;
"

button1();
button2();
button3();

color_text = "green";
font_weight = "bold";
font_style = "arial";

button4();

open_file(); // Get styles for a menu

"
receives FILE_Pointer; From file.h
"


The style is the same was previous example, now the openfile() is using the same file pointer which is a object variable, if needed to store values, which are a less thing since most time we will be doing something and outputting the values. Are stored in arrays, structures, or files, with the values and passed to the functions, with the same thing global variables.

The variables with the stored information have plural names, to be different from objects, which are single abstraction. For example “char menus”; will store information that is needed to call back. Maybe a menu position, to know which are where. But since many information is in files, object abstraction is probably enough.

Store information and load dynamic information

tool.h
interface_index_keys = {"interface_id", "menu_position", “text_color”, “background_color”, “”};
“information_menu.txt”
20, 1, black, white;

The information will be in txt, files, it will make it really dynamic, can chance any thing in the software. The format choose a simple keys to load and to map, if you see it have the same name of variables. and files have limited information to speed the search process.

The keys map the file, and will also work with simple idex, which are separated files with only the id's to speed search of information in files. Like a database work but only with txt files.

With this format we can load a hole project from a txt file, and probably will not consume many resources.

If your reasoning is that the lower level you go, the faster your game will be, why stop at C, why not program in assembly?

Apparently C# is just as performant as C++ for most software development except for very low level rendering code etc.

There was a time when choosing to program in assembly gave you performance benefits that were worth the time it took, but that time eventually passed, a long time ago, and everyone moved to C.

And now technology has progressed to the point where you most probably shouldn't be getting bogged down with C for your whole engine because you won't get enough performance back to justify the time you'll spend when you could be using C++, or better yet, an existing engine. They allow you to deploy to multiple platforms, so you can put your game not just on Windows, but on consoles like the Nintendo Switch, mobile phones etc. and actually make money and make a living out of it. Good luck doing that in C while rolling your own engine!

For local multiplayer retro themed games, visit Domarius Games.

Advertisement

Domarius said:
If your reasoning is that the lower level you go, the faster your game will be, why stop at C, why not program in assembly?

Because modern C/C++ compilers optimize the machine code they generate so well that unfortunately it ends up faster than any human-written assembly.

Thanks, assembly is to much, but i though on it, since C can communicate with other languages. Maybe is a option, In Graph App, they delegate to external programs part of the services which is something i was not aware it was possible. Only programmed in PHP for a good time so it was only server. When you are at the computer, you can do much more things. Like using isolated programs that communicate which other.

You can have several langues in a project think Blender is part in C, assembly and in python.

Graph APP team have something in assembly, you can check that if you interested in Assembly, and in the Box project.

Tycoon, was a game build in assembly only because at that time they needed high performance to have that many stuff loaded in to a game.

The project is not just for high performance is for educational purposes also. We don't have a C program that allow people to learn. And if tomorrow a new machine/console, come out and want more support is not dependent in this libraries can write is own.

Raspebarrie Pi a machine that could use well on this software and also Linux which is all build in C, you can have high compatibility if you write something in C.

C++ can do all that? Yes, but is very depend on library's if you chance or want to work in another OS you need to do things in windows first. Which means even if performance is not affect which it is. Can't play a game i made with Unity 3D but can play world of warcraft. And is very big, a simple map 4 wall and 2 characters 400 mega. Most web games for unity 3D can't play them.

To conclude the topic : performance is affected, size is affected, operating system is affect, and machine/computer is affected.

Would like to see some source, screenshots and possibly a demo for The Box. Using C only is a nice idea. I have considered sticking to C as well, but I find the C++11 STL classes such as map and vector too useful. Maybe there is a C library that emulates them? The cool things about C is that a C compiler is very small, and can be made to run on embedded devices. What kind of doors does this open up for games?

Let's suppose you released your games as physical devices, like handheld games or arcade machines, C would be the way to go. Although most new arcade machines do use Unity, not all do and those are the most unique.

Let's suppose you decided to wipe the slate clean and develop your own graphics hardware architecture that pertains exactly to your game. What if you invented some new way of drawing that does not use pixels or polygons? C would be the way to go. Look at what Ken Silverman is doing with VoxieBox.

I am in favor of not an open source engine, but a set of modular open source libraries that you can plug in and out of your project depending on what you need, whether C or C++. Let's say you have no code of your own and you want a scene editor and a bloated C# VM with tons of pre-made layers for everything, you can import that. Let's say you don't and you only want high-performance rendering because you already have your own editor and scripting, then you only import that part.

Tutorial Post, on software functionality

At the moment you have to pay for all this, and the project will do all this things free.

first stage – design the project with the design tools, design document, game lore tool, add : history and characters to the game. Using build concepts available.

Second stage - template , load a previous template with the basic project on that theme, for example a isometric game.

third stage - have libraries to load a basic art to structure the project, for example a 3D low polly library. Which make all the game playable.

fourth stage - add functions automatically, from code snippets or create own functions from standard functions tool without using the code editor.

fifth stage – design the basic stuff, like levels. Simple audio/video edit, interfaces.

six stage – access the market for : founding, jobs, or help on the project

Seven stage – auto compile to platforms, without the need for knowledge on how programming

eight stage – publish to a free platform

nine stage – create the community with the social tools, also free. (You pay the social networks today indirectly at the cost of your privacy. Publicity)

*Servers if some one want to set up lather could also be added, for example for simple games. If the server is using the same libraries.

This topic is closed to new replies.

Advertisement