Friday, June 2, 2023

Style of the files

Style of the files

 This usely should be in a file for which part. Bit like C was design in the first place, like having one library for which theam. Strings will be in <strings.h>. In here if we are going to use the project it should be in <project.h>.  


includes/header_files/project.h

includes/progs/project.c  

Tool : Debug

 As the features in C are so complex I will write a Debug tool for each theme. The software will have a "Folder" or additional folder called "Debug tools", where they will be there. It makes various tests for example the images: it loads the image tests and outputs the image and all the image functions information; Maybe check for errors, see if the image is at 100%. This will help develop the software, and perform various tests. With this tool you can develop only the part of the images and connect later later, without all the code working.

Also found this software which have a interface working is very nice to study code. Since have information we can't find in the toturials.

https://sites.google.com/a/liesenberg.biz/cjogos/home/software/interfaces-graficas-em-c
http://www.enchantia.com/software/graphapp/

 

[b]The Box Version 0.0.2[/b]

Still it does not have that much work that i wanted but is the possible work. The file have like 30 pages. It should have every thing you need to understand and develop. It explain: interfaces, code, objects, objectives, tools, tutorials, planning, etc…

2 PDF, and the box folder :

You should have access to the public folder

https://drive.google.com/drive/u/1/folders/1LqXNvuu5p5t7cQ4yH-7YEqugL7glslMk

 

[b]Update[/b]

Missed a small thing, how to convert code to procedural to use with the global objects.

Think the theory of structural programming could also be called stack programming, or have a stack part in it, because we do things by stacks.

In this example we are going to see a stack.

In this function from Lips of Luna, nodes for 3D models. How to covert it to procedural code:

[code]
LIMdlModel* limdl_model_new_copy (

const LIMdlModel* model,int shape_keys)
{
 
int i;
LIMdlModel* self;


self = lisys_calloc (1, sizeof (LIMdlModel));
if (self == NULL)
 return NULL;
self->flags = model->flags;
self->bounds = model->bounds;

if (model->hairs.count)
{
 self->hairs.array = lisys_calloc (model->hairs.count, sizeof (LIMdlHairs));
 self->hairs.count = model->hairs.count;
 for (i = 0 ; i < model->hairs.count ; i++)
  limdl_hairs_init_copy (self->hairs.array + i, model->hairs.array + i);
}

if (model->lod.count)
{
    self->lod.array = lisys_calloc (model->lod.count, sizeof (LIMdlLod));
    self->lod.count = model->lod.count;
    for (i = 0 ; i < model->lod.count ; i++)
        limdl_lod_init_copy (self->lod.array + i, model->lod.array + i);
}
if (model->materials.count)
{
    self->materials.array = lisys_calloc (model->materials.count, sizeof (LIMdlMaterial));
    self->materials.count = model->materials.count;
    for (i = 0 ; i < model->materials.count ; i++)
        limdl_material_init_copy (self->materials.array + i, model->materials.array + i);
}
if (model->nodes.count)
{
    self->nodes.array = lisys_calloc (model->nodes.count, sizeof (LIMdlNode*));
    self->nodes.count = model->nodes.count;
    for (i = 0 ; i < model->nodes.count ; i++)
        self->nodes.array[i] = limdl_node_copy (model->nodes.array[i], 1);
}[/code]

The node.c file which will be kind of a stack if it works in C, didn't test it. This how i do it in PHP.

[code]#include model.h / global variables on models
#include draw.h

models = “model1, model2, model3” // models to load

#include node.c

----------Start  node.c----------------

while (models != not empty)
{
    for (i = 0 ; i < model->materials.count ; i++)
{
            limdl_material_init_copy (self->materials.array + i, model->materials.array + i);
    }

    for (i = 0 ; i < model->nodes.count ; i++)
            self->nodes.array[i] = limdl_node_copy (model->nodes.array[i], 1);
    }

}
---------end file----------

models_array // loaded models

#include draw.c // draw the models
[/code]

the global variable should have the models loaded after the include of the file. The file is only procedural code. and is very fast. and very easy to read. 


[b]Tutorial on code design and how the code is looking like :[/b]

[u]Code refactor on Lips of Luna[/u]

The refactor of code does not seem that hard once we have the planning, was able to refactor high amount of code. Doing like this: first remove all dependency and leave only procedural code, “leave notes in case we want to know what is going on lather” do not remove libraries because on 2º stage we are going to need to get that extra code from the dependency's.

[u]Object planning[/u]

Object planning this is already on the internet i din't invent it, the theory : “if a object is doing to much is bad and is if bad doing to little. So a object should deal with a set of functions in a proper way". For example Lips 3D model load first file is ok in therms of planning but the 2º part i called in this example : ”open model" and “load of model”, in this case is load of model, there are several files scattered with 50 lines  which, in this case is doing to little.

I will convert them in to the “load model”, to deal with materials, particles, etc…

[u]Code [/u]

Is more advanced then my PHP engine, it was only one layer, or two layers. In here we have several layers, and inheritance.

I usely put all variables on top to be more readable, but in here since we may reuse variables, putting them above the include, for now putting the settings in if and else, if need some kind of setting from file is just a matter of setting to true. “files_list = 1; // true”

to refactor functions : it transform them in a if with a true state, to use e need to set it to true.

But still have to see what will be the better design.

[u]Dynamic functions[/u]

For now setting all to file object non dynamic, lather when it evolves if procedural can't handle it i will create a “system object” to pass things to procedural or handle the parts procedural can't.

A bit like PHP : it uses procedural based on a Object, or a set of objects.

[u]How the code looks:[/u]
 

[code]#include variables.h
#mouse.h
#keys.h

language = "PT";
#include language.c

operating_system = "windows";
#include settings.c

mouse_arrow = "costume arrow";
#include mouse.c

keyboard_esq = "jump";
#include keys.c

//Concatenate

#include path.c //Open directorys

folders = {"", "c:/the_box/projects/models", "c:/the_box/projects/images"};
folders_index = {"models", "images"};
files_list = 1; // true
directory_list = 1; // true

#include open_folders.c // open folder

images = {"image1.jpg", "image2.jpg"};
images_index = {"menu_button", "menu_effect"};
#include jpg.c

models = {"model1.3D", "model2.3D"};
models_index = {"character", "character2"};
#include open_models.c // models open

3D_low_poly;

#include load_models.c

window_height = 400;
window_width = 400;

#include window.c

control_height = 400;
control_width = 400;

#include control.c

text_style = "liberation serif";
text_color = "black";

property_background = "white";
property_menu;

property_buttons = {"button1", "button2", "button3"};

property_button;

#include interface.c

draw_menu;
draw_map;
draw_models;

#include draw.c[/code]

DTR Database text reader



For now there is this stuff i'm working. A text format to manage projects. The text format, xml and jason are a bit heavy, creating something that is similar but in a more light version.

A way that this could work :

"link of the file", "place used" (main menu), order of display (1).
C:\Users\jdc\Documents\the_box_external_librarys\magic.png , main menu  , 1 ;

It could be a transitory way before the file is added in to the code files in a function format or it could work this way, if it does not consume a lot of resources since one of the objectives of the project is to have a very efficient code.

A general overview of a project in the : text projects code :

[code]

</1>

<title>

Mediev Titans

<description>

A DOTA inspired game, strategy

<3d models>

C:\Users\jdc\Documents\the_box_external_librarys\3D_medivel\Goblin\Goblin_model\GOBLIN.fbx  , level 1  , 1 ;

<images>

C:\Users\jdc\Documents\the_box_external_librarys\magic.png , main menu  , 1 ;
C:\Users\jdc\Documents\the_box_external_librarys\final.png , level 1  , 4 ;

<levels>

Main Menu ;
Level 1 ;

[/code]

The dev version is online it have a lot of updates, working with file.h and path.h to manage stuff for file "browser tool" and "code editor tool". The stuff i posted before is now used, we will repeat the code in file.h and path.h in : browser tool and code editor since they use the same things. To prevent this, the code is moved a level in the hierarchy to a "object" or structural programming format. So they inherit.

This format is useful to code,  It allow to write allot of pseudo code before we can start testing things. Because you can start codding normally, and if something repeats at some point is just a matter of moving the code up and down if is repeated or not.

The stuff in the folders is still a bit messy and not documented, it still need more work, the external library have a low poly 3D library that i'm working. Just one thing that is +- organized.

https://drive.google.com/open?id=1LqXNvuu5p5t7cQ4yH-7YEqugL7glslMk   The Box

https://drive.google.com/open?id=1D4Vi9dwreux0TX8-iQuYTJkv1HrnUH5x  External librarys

https://drive.google.com/open?id=1JndNxwLra9uMxhQ_PlF_UZjYF4nnt2di External Project

https://drive.google.com/open?id=1ZPZdAr6--7oiWyNv7_9Z67b7kErTkgGD External tools

 

a small update:

How to to add large amount of information to txt files.

In previous update, i have something that look like a xml, but now i'm thinking there is no need for the user to read the files, the software can do that, and display the information formatted. It allow more amount of information in a file.

Which project or data is just a single line.

The software read like this and apply this format : name, author, genre, type, image, web page, etc... it uses order or numbers for position on which entry.

The txt file have only the information. The software recognizes positions. If there is no info in entry slot a empty field is added, like ", ," :

[code]lensman , autor , anime , sci-fi , 0.3 , lensman.jpg, https://www.youtube.com/watch?v=RpmTynxXGCM ;
Hunter D , autor,  , 4.5 , hunter_d.jpg,  ;
Eva  , autor , game , sci-fi ,  , eva.jpg, ;
Pokemon , autor , anime ,  , 0.3, tides_of_time.jpg, ;[/code]

This will be very fast execution. the code do this: It "explode" the strings by tokens first ";" an then by "," to get positions, and convert to data format to display.
 
Maybe it will use symbols instead of the language symbols ";" and "," to be compatible with descriptions on projects. but it will be the same thing.

Graphical Code


 External projects librarys will be inside the external includes : the_box\external_includes. 


To install you need to run the make file, only then you can compile it width the Gcc compiler  width the compiling flags for the library if it have some. In linux that is simple think it comes as they call it "out of the box" in windows you need the make a software to use make. I didn't use it but read this software may do that

https://chocolatey.org/install

 

Code for a menu

https://stackoverflow.com/questions/39025074/c-program-how-to-print-in-table-format-alignment

Ncurses

https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html

https://invisible-island.net/ncurses/announce.html#h2-overview

Graphapp

http://www.enchantia.com/software/graphapp/

Another Graphics 

https://www.codeproject.com/articles/363908/simple-two-file-graphics-library-for-c-cplusplus


How to display info in a table format to console just with raw code.

[attachment=0]7uLn0.jpg[/attachment]

A bit on my develop of the software, how complex the lore tool is becoming.

For example we can add all kind of lore stuff in to a files "database" format. Then it connect all this stuff to the design document. When your are building the document you can link stuff at that point from : -> projects to design document; from -> lore to design document, and to templates.

So let's say some one add a nice environment like a history with a few cities and a few characters to the "box lore tool".  if you want your game to follow up on that history you just need to connect that "lore" to the design document or project and use the same librarys/templates and is done.

Think it will be also good for standardization of history's, for example the concept of race orc, can become more elaborated and standardized adding good environment to games. Or people could also go with their own stuff. But if you do not have that kind of skills to create this very nice story. You can set your environment on something already stable.

Another think i though in adding is a "project finance" tool like kickstarter , why pay 5% or 10% when you can add this stuff automatically in to a server and let people make their own decisions. Once you create your project you can automatically config what kind of finance could help your project.

How the  links code look inside of the lore tool : Add stuff seperatilly with more detail or add with generic menu with all the options. If some already is scripted this functionality it add it automatically with "standard functions tool" to maybe the mapper which is the generic overview off all the relations/connections:

[code]    printf(" Game Lore Menu : pick option \n\n");


    printf("1. Exit tool\n");
    printf("2. List Lore  \n");
    printf("3. Add Lore  \n");
    printf("3. Add Design Document  \n");
    printf("3. Name Generator  \n");
    printf("3. Create character  \n");
    
    printf("10. Game lore : Add Religion \n");
    printf("10. Game lore : Add Races \n");
    printf("10. Game lore : Add Spells \n");
    printf("10. Game lore : Add Items  \n");
    printf("10. Game lore : Add Skills  \n");
    printf("10. Game lore : Add weapons \n");
    printf("10. Game lore : Add armor \n");
    printf("10. Game lore : Add Classes \n");
    printf("10. Game lore : Add History \n");
    printf("10. Game lore : Add Geography \n");
    printf("10. Game lore : Add Maps \n");
    printf("10. Game lore : Add Families \n");
    printf("10. Game lore : Add Guilds \n");
    printf("10. Game lore : Add Worlds \n");
    printf("10. Game lore : Add Citys \n");
    printf("10. Game lore : Add Monster RPG  \n");
    printf("10. Game lore : Add Monster SCI-FI  \n");
    printf("10. Game lore : add NPC  \n");
 [/code] 



Stand alone progs

[b]Git Hub[/b]
[b]Standalone[/b]
[b]pointer variable[/b]
[b]main tests[/b]
[b]variable names[/b]
[b]learn[/b]


- Adding updates to git hub, organizing is a bit confusing. (the code update from the books is still on working...)
https://github.com/saintsoftware/the-box

- all programs will be in a stand alone format, so its easy to to work on them it out affecting all other programs.  Now we can start using them as soon as some code is in there.
 ---- standalone/links.c ; etc...

- A update on the pointer definition
[code]type define * ptr.[/code]
 The pointer abbreviation already exist is [u]ptr[/u], defining pointers as a asterisk : " * " ; look a bit weird. and most if not all languages have adopted the "int" "char" 3 letter abbreviations for variables types.

[code]int ptr integer1
char ptr character1[/code]

on --- includes/macros.h

- separating main for tests and for code.
main_ut, main, main_help_info. (maybe only 1 main for tests will see lather)

- adding a bit updates also do function names.
 maybe adopting C abbreviations for them. (will see how it goes)

[code]f_count_chars();
f_count_lines();[/code]

f -> file
c -> character
i -> integer

etc...

used in C as "uint" -> unsigned int

- Also adding a learn folder
A folder width all the examples we can find or are relevant to work and develop width C.
some stuff is in Portuguese if have any problems use google translate.

Structures


 

[b]The main[/b]

main()
{

if(zone == liberta city)
#include shop_obj;
}
else if(zone == main menu){
#include main_menu
}

You don't need any thing... is just modules width no dependency's... Easy thing you will ever find.

 

[b]Advantages:[/b]

you do not need to write your Database, if you don't want to; you can just alter global variables for shop, You don't need to write a save if you don't want, etc... all functionality in the same variables and modular...

all the functionality possible already written:

-camera
-character movement
-attack
-AI
etc...

You can still have your variables, in the objects, you just need to know the standard.

class character
{
name;
age;
race;
etc...

character_the_box() //on init object
{
name = character_name;
age = character_age;
}

when you initiate it loads game variables...


[b]Missing another thing.[/b]

How to configure your project.

'Build a costume array index's, width the same names as global, and the Box will know what you are using.

The Text RPG i'm using. Will be something like this:

char character_index_array = {
"character_id",
"character_name",
"character_race",
"character_age",
"character_languages",
};

id for database store. Some things you need knowledge but is as i write or on files, or on posts. You don't need to learn a new framework.  

So that the game can load character, and database can save, or files.

[b]Never Shaw?[/b]

100% procedural engine. Think people stop developing procedural engines, that may be the biggest reason.

 [b]C++ is faster?[/b]

You can't go below objects because is based on them. They consume a lot of resources. In C you can add assembly which will be very specific i doub this articles, based on limited tests. On all the internet say procedural is fast. The logic is against C++. How something that use and load more information can be faster?

Frameworks faster? Even professional console e-game players say the games are slow that will affect their  performance. Is not faster, it can code faster because you have more things arranged.

I think is a matter, of standards, and costume games width modules, not large paid frameworks.

But will see is still evolving. My PHP engine as much more limited it only use principles of what i'm doing width this engine, improving a bit more the concept.

Questions and comments help a lot because most of the time we are centered in design and development don't have time for this questions or reflections, so when i See them ya "that is a good point" Made a lot of updates width questions/comments on game dev.

* PS: most C functions where not build for performance, they load many not needed stuff. But if you refactor them, and they load only the needed thing, "if i where you will not bet my money on C++".

A detail

You can use your logic to make all things you want, when you are finished.

character->save
shop->save
item->save

And you save all things back to globals, and will give zero errors. No need to use structure variables if is not needed or don't want in the objects.

Why the style



Ya adopted this style because i having memory problems and when i get to the code i could not read it. Not that i have problems in reading functions. Another thing, lather it was much more easy to read and maintain.

Move from functions to more of CSS "html cascade style sheets" style of code. And most people prefer this style of code, because is easy to program, width out making many thinking.

to writte like 100k of CSS code and maintain CSS is much more easy.

They don't like it? In the end is a bit hard for other people to help out because or the project is not mature enough they don't understand objectives, or the design is still improving.

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

[b]News[/b]

Thanks for keeping me motivated, think i will lunch this time 0.1.x version which will be a big thing, from 0.0.x. Finished all the things i wanted. Have C algorithsm working. Think most of the basic stuff will be working in next version. [b]Will be a working version[/b]

And i was about to give up the project, if was not for people comments and support.

Adding assembly to refactor some of C heavy functions like: printf, draw or loops. Not for all things, but like why use printf generic for all things when we could have print_int, which will consume much more less resources. Specific just for integers.

Liberta thinking in adding C++ for heavy libraries which i'm not thinking in re-writing now, (more on a long therm) since C communicate width every thing, you can even add assembly directly to code, if you want to program some raw graphics to add, if they have all the dependency's. I can add the files to the project.

Costume stuff in directx and opengl will be nice. Maybe add a folder for C++ stuff.

Personal tastes & Unit Tests


Personal tastes

All come down to personal preferences, we can't control all things. This style works, it have it's positive and negative. Other styles will have the same. C++ is probably great, still is the same it have positive and negative. If something works and you can create large code or a engine on it you can't say it failed is just a matter of personal style.

If any day you thingking in adding code to the box will be pretty easy you just need to see standard global variables , that are in the "header_files" folder, now i thing it is called rpg.h made a couple of mistakes in this version it should be called game_structure.h or standard variables in the future, and add them to objects. If your code alter the state of the variables, other code can still be added.

global variable.
object c++
procedural code

For example one aspect of C++ you will not get that much performance as C procedural, C procedural will not do much as C++ to start width (code). Etc...

https://stackoverflow.com/questions/199 ... -in-c-code


Liberta one time you mention structural programming already exist, but is not the same thing. This method derive from studying MVC it works the same way; the main, will load stuff in to it. Is more "Pattern programming" or "Pattern structural programming" probably more accurate.
-------------------------------

Unit Tests

Some one at discord "The code Den", say to implement unit tests. I was reading about, is the same as the Box or structural programming is not a framework, as i though in begging "why implement a framework to test code which will require X hundred of hours to learn it will not be very productive". But i as reading is just a method like the box not a framework; It can be a framework but to start is a method.

If you want to study methodology https://en.wikipedia.org/wiki/Unit_testing you have here the unity tests, it is the same as the box, don't know if i need it because once we start repeating code, it will always the same we no longer add or learn new stuff. I code for hundreds of hours width out any errors, another method for errors probably to much.

"I will see how it goes..."

Procedural true performance

Procedural true performance

 
One of the benefits of this engine is the procedural speed people where asking or saying is not faster. But you can check your self How 2 loops not nested are faster the 1 nested loop.  

https://stackoverflow.com/questions/8547778/why-are-elementwise-additions-much-faster-in-separate-loops-than-in-a-combined-l?rq=1

Added to git hub don't like that much, all things done by hand, like move files by command, and only 1 which time. All tasks kind of manual. Only upload 100 file which time. No empty files. The program is suppose to fill those files they are not there just to take space. If they take any at all.

https://github.com/saintsoftware/the-box

Added the documentation folder.

This will help for people to learn in the project. For example, instead of reading a wikipédia article on JPG, we can get those articles and mount something more elaborated. Like width code examples. OR things connected width the project. In next update already have many stuff on BMP. If you need to learn BMP for raw applications or engines, you will have there a well planned documentations.

Folders for this:

->Documentation

   ->BMP
      -article1
      -article2
     ->JPG
    ->3D theory
...



Thursday, June 1, 2023

Functions, new programming language, Text read 2.0



Width books is pretty easy to advance in your work. One of the books is 3º edition and the other 4º edition revised. the code is all tested...

Count chars from a file
[code]
int count_chars (FILE *f)
{
int r = 0;
while(fget(f) != EOF ){
r++;
}
return r;
}
[/code]

Count chars and lines from a file

[code]
int count_chars_lines (FILE *f, int *nl, int *rc )
{
int rc = 0;
int rl = 0;
while((get(f)) != EOF ){

if (c== '\n'){
rc++;
}

}
*nl = rl;
*nc = rc;
}
[/code]

was debating a bit on global's. but what it seems is that global's in C are the pointers, you can access any thing in a structure form. In 2º function he return the values width pointers and not return.

For the new programming language or at least rules to read text made some updates compared width the before raw style:
[code]

----STR file-----

/t title
/ta tags
/d description
/c code

</1 start line + line number  t/ (b,i,ul) title or tiles ta/ 'tags' tag1, tag2, tag3 ... ;
[/code]

mixing database rules , width html tags and programming format ';' like end of line, so that the text files do a lot before programming.

[u]
What we can do width this: [/u]

[list]
- is not need but we can first define tags
- First tag and number.  we can index things in a db format to speed the use of the file, also to allow comments and other stuff not programming. Will not be confusing adding numbers to line? no because if you start the file the program does that auto
- The t/ tags allow to have pre format things for the programming to process
- The character ';' The end line. determine the lines to prevent excess processing. it have no closing tag  like html. it adopted programming style. it have a general line close. also to prevent excess text.
- /T (b,i,ul)  style in tag makes pre interface elements. like say that the title will come in bold italic in a unordered list. This prevent to re compile the code just for the style which is a lot of work.
[/list]

Call it STR standard Text reader

hi

DTR 1.x working version

  DTR   is live and running!! think can say in a solid way this is a 1.X working version of it. have all my data files in it now. this is ho...