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

@Aressera “You can create wrappers with #ifdef. It's really the best you can do. (Or you can use a third party library to do this).”

https://stackoverflow.com/questions/2029605/thread-safety-in-c

@trsh removed because was adding version 0.0.2, version 0.0.1 don't have much in there a 2 or 3 days work, this new one will have several weeks of work. For people following the posts probably will not be much help because now there are other topics which here not in there.

@mr_tawan The PHP version of it, the site is offline, host expired, on a low free web host is faster then most pages, it only slow when server lagging. Only html is faster, but we are comparing services not text.

Was i say before : writing this stuff i realize the more nested the information is slower you program will be. Large information structures, like structures and objects consume a lot of resources.

*Not trying to convince you people of any thing, go on work on your paid engines with no automated code, because they can't make money on auto code. My objectives is to people to chill out and have a nice free engine that we all can create games with no afford.

Crazy repetition of projects and of code, hundreds of projects not finished because people don't unite, is like society : large company's gain control of society because the lack of union.

Or we all can works a couple of weeks or months in a shared engine that can do all this stuff for us.

Personally I'm not going to bash you regarding writing game engine, as I'm also writing one at the moment. Just find that popular game engine are too complicated for my taste and for the game I'm working on. I'm pretty sure there's a lot of people think the same way and do the same thing.

However there are idea that doesn't sound right to many people, including using data object in disk (instead of loading into the memory), use C instead of C++, etc.

Was i say before : writing this stuff i realize the more nested the information is slower you program will be. Large information structures, like structures and objects consume a lot of resources.

This is why Data-Driven Design becomes more popular in the recent years. If you put related data close together, it tends to work well with CPU cache thus results in better performance.

http://9tawan.net/en/

Advertisement

@mr_tawan Don't make it personal, my project is independent of people opinions.

Actually was able to find the web page, think i change the password that's why could access.

http://www.tavern.html-5.me/

Use any login, it have the same services was any other frameworks and see the loading times. Some stuff come from DB, and the web host is a free plan, so is not very potent. Think the link “Magic The Gathering” come from the db it have a delay there.

This link have a foreach error : http://www.tavern.html-5.me/tavern/front_page/index.php?page=loja_mtg

Very fast for a web loop.

if and elses, width file objects VS frameworks nesting.

People worrying on engines ? Not doing this because of engines, doing this because there aren't any software engine in C, width a very well structure code which we can automate.

That's the main objective “market”. Another C++ engine probably a waste of time.

Another thing : people say C is equal to C++ in speed? Maybe, if you nest your C with structures and objects it will be same was C++. If you use procedural code, to take advantage of the procedural ya it will be faster.

I separate things in to file objects so i can use more if's and else's and not functions that go in to memory that's a reason why is faster. Still maintainable due to well structure of code.

How the main look, write it yesterday but is not finished still fixing some stuff.

For example, it hard code menu items, but that is just something, in some cases the code is bigger. Still seeing how is implemented probably not final.

In this style the main part is bigger but not that much, and libraries small. Is bigger because we need to access to elements. To add stuff to them.

Separating in to this steps so it probably can load more stuff in to the graphics, like 2D → 3D → ISO or holographic was some one suggested.

window.h - window
control.h - Area to draw
draw.h - Draw process
event.h - manage functionality
2D.h   - Graphics
interface.h - interface properties
font.h - Management of text.
cursor.h
keyboard.h
 
//Window
 
window_id = 1;
window_type = SIMPLE_WINDOW;
window_children = 10;
 
window(); 
 
control = newcontrol;
control_Region = 200px ;
control_size = 100;                
control_num_rects = 20;
 
control(); 
 
3D = 3_D;
 
graphics();
 
//Main Menu
 
text = "window title"; //
color_text = "black";
color_backround = "white";
interface_border = "solid";
interface_border_width = "2"; //px
 
cursor = "";
 
//Title
 
text_font = "title for the project";
 
//Buttons
 
interface_property = "button";
interface_border = "solid";
color_border = "gray";
interface_border_width = "1"; //px
interface_positon_y = 10; //px  

interface_positon_x = 10; //px
 
file_path = "images/texture_button";
open_file();
 
if(open_file() =! true){
 error open file;
}
 
button();
interface_id = 1;
interface_positon_x = 20; //px  
button();
interface_positon_x = 30; //px  
button();
interface_positon_x = 40; //px  
button();
 
Menu  
 
color_border = "black";
color_backround = "gray";
interface_border = "solid";
interface_border_width = "2"; //px
interface_buttons = 4;
 
event_ = "menu";
event();
 
menu();
 
Menu items
 
language = "EN";
 
event = "houver";
color_background = "gray";
color_text = "black";
event();
 
file_types = {"jpg", "png"};
event();
file_open();
 
event = "click";
text = "file open";
event();
 
item_default();
menu_item();
 
text = "new project";
menu_item();
 
text = "project edit";
menu_item();

jdc said:
I separate things in to file objects so i can use more if's and else's and not functions that go in to memory that's a reason why is faster. Still maintainable due to well structure of code.

I'll say it again, this is Really Bad design for all the reasons I mentioned earlier which you brushed off by linking to an unrelated stack overflow post. I'm trying to save you headache when you later realize you used a bad design and have to rewrite everything. It's happened to me, it will happen to you.

You don't seem to have sufficient understanding of how C code is translated into binary - you aren't saving anything by using global variables to pass parameters to functions. It's actually going to likely be less efficient because the globals won't live on the stack (which is in cache), and so accessing them may require going all the way to RAM (200 cycles), whereas normal parameters are passed on stack (fast, <10 cycles) or in registers (faster, 1 cycle).

Trying to save memory - how does using if/else instead of functions save memory? This makes no sense at all. if/else must exist inside a function, which will be located in memory. I can see no code size benefits from this very weird concept of “file objects”.

I remember in the early smartphone OS Symbian, global or static variables were not allowed because of the reasons mentioned above.

But what i really wonder here is: How can ‘file objects’ containing C code be used as such? Do you compile them at runtime, or do you use php but only the C subset of it? What is it?

(I may have missed the explanation somewhere within the thread, but if this is meant as a tutorial you should explain this in opening post.)

Advertisement

@Aressera “You don't seem to have sufficient understanding of how C code is translated into binary”. WTF is this? You on drugs?

Hope you keep your crazy comments for your self, there are people working here.

@joej can't replay personally to all people you have to read how things go, that is the bad part of programation the topics evolve very fast, to keep up you need to read and study how things are done. A simple topic can evolve in to a manual. Let's say you doing your engine in a couple of days you already need a manual to understand it and explain it to people.

Any thing wait for 0.0.2 version

jdc said:

@Aressera “You don't seem to have sufficient understanding of how C code is translated into binary”. WTF is this? You on drugs?

Hope you keep your crazy comments for your self, there are people working here.

@joej can't replay personally to all people you have to read how things go, that is the bad part of programation the topics evolve very fast, to keep up you need to read and study how things are done. A simple topic can evolve in to a manual. Let's say you doing your engine in a couple of days you already need a manual to understand it and explain it to people.

Any thing wait for 0.0.2 version

Well, thanks.

I asked the second time the simple question ‘What are file objects?’, and you fail to give a short description on your general idea? Although this is your tutorial about ‘file objects?’

I'm not going to study 5 pages that only show code to lay out a user interface. This code does not solve any problem, does not transform any data, it does not even have a function. It only is layout data of some UI. I can do this using CSS and will hire a web designer for that. Why should a developer bother with this? Study yourself how papers are written. They start with a MOTIVATION section, addressing an open problem. I neither see any problem you aim to solve, nor do i see how functional programming or ‘file objects’ are of any specific help with such trivial tasks.

In short: I have no idea what you talk about and how your code is executed. I do not even know what language it is.

If asking for this is too much bother for you, and you don't want any critique or corrections, i suggest you use a blog post, not a forum topic. This way disturbing comments from clueless people here do not clutter your text, and there is no need to insult those people just trying to help (or at least to prevent others from paying attention to all this here, which seems nothing more than BS to me at this point).

“I have no idea what you talk about and how your code is executed. I do not even know what language it is.”

It says in the topic “Game engine in C” you need basic understanding in programming to debate engines. It's and advanced topic. It's not like opening a file in C. It uses all kind of knowledge from different areas i hold not attempt to write a engine if already don't have a good grasp in programming.

I advice you to start in PHP like i did when you know a lot of programming try C, is not easy to start in C.

Most people that are debating the topic have a moderated though about this because is hard thing to do.

Hi,

I think I missed this post, sorry about that.

Hermetix said:
You have to compare similar implementations to say which language executes code faster.

So you came to the same conclusion I was saying: “only certain implementations can be compared, not languages in general.” Good! I'm glad we agree!

Aressera said:
You don't seem to have sufficient understanding of how C code is translated into binary

You are probably right. I can only repeat myself: “it is much more important how experienced the programmer is in the given language than what that language actually is”.

@jdc: you clearly need to learn more on how to use C. There's absolutely no shame in that, and actually doing this engine in C is the best way to get more experience with C! So I say keep on doing it, just don't forget to stop sometimes, take a step back and look at the bigger picture. Don't be afraid to refactor what you've already implemented, if you think you've found a better alternative to some parts. Be prepared to rewrite your entire codebase a couple of times. That's absolutely normal when you learn new things, and my understanding is you are new to implementing a game engine in C. No worries, everybody had to start somewhere!

No need to be rude, people here are trying to help. You seem to be the guy who has to learn from his own mistakes, and I can absolutely relate to that. I was told way to many lies in my life to take anything that's being said for granted. I too have to see everything for myself. So my advise here is, if someone tells you this is not the way to do it, then implement their version too, and compare with yours. Always measure (speed, memory consumption etc.), be empiric instead of emotional. It's enough to decide which path is better for your project when you have evaluated the results, there's no need to rush to conclusions. If you take this advice, your engine is going to be awesome!

Cheers,
bzt

This topic is closed to new replies.

Advertisement