The Box, development tool, "Structural programming"

Re: The Box, development tool, "Structural programming"

Postby jdc » 20 Nov 2018, 10:04

outdate post...
Last edited by jdc on 14 Oct 2019, 16:57, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 20 Nov 2018, 12:17

outdated post...
Last edited by jdc on 14 Oct 2019, 15:13, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 20 Nov 2018, 15:31

Think i will opt to start having something working before go in to heavy code refactor, that way the software is already working and doing something... (lather analyse that better...)

I will opt with GTK+ it seems pretty simple in this tutorial, (only a couple Labels), for the menu. Is open source, can develop a very powerful application (2D).

It have that procedural linking style, which i like to work with, and is very simple.

This cover the loading of images in to the software, "external library'"s.

If you want to follow there are a tutorial in the video. With the GTK can start building the menus for the program, and putting something working.

https://www.youtube.com/watch?v=ajNvsv1ka4I

For the 3D think i will use OpenGL, because it uses the same principle was C, it's cross platform, and can work width a minimal graphic quality.

For the OpenGL it seems is necessary "Glut", it have a similar style was GTK.

https://www.youtube.com/watch?v=3aJ8OR1 ... G3rF99gkvk

Maybe can use both Glut+GTK to have more functionality available.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 20 Nov 2018, 18:02

outdated post...
Last edited by jdc on 14 Oct 2019, 16:58, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 24 Nov 2018, 14:05

Also remember another thing that we could add to the software is a debug, implement some kind of test's so we can minimize more the margin for erros which translates in more development time.

For who is following along we are at GTK, they recomend to install mysy2 if on windows (don't imagine many ppl using linux):

https://www.gtk.org/download/windows.php

Install msys2

http://www.msys2.org/

then GTK recomend we get glade.

https://www.youtube.com/watch?v=vOGK3TveDDk

which i check what it is, is a graphical software to develop the app so we can develop something whitch just a few clicks.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby Lyberta » 24 Nov 2018, 18:50

jdc {l Wrote}:(don't imagine many ppl using linux):


I'm pretty sure for most people on this forum GNU/Linux is the only OS they use.
User avatar
Lyberta
 
Posts: 642
Joined: 19 Jun 2013, 10:45

Re: The Box, development tool, "Structural programming"

Postby jdc » 24 Nov 2018, 22:02

Good for them. Lyberta

T
Last edited by jdc on 14 Oct 2019, 17:02, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 25 Nov 2018, 09:53

outdated post...
Last edited by jdc on 14 Oct 2019, 17:05, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 27 Nov 2018, 11:20

post outdated...
Last edited by jdc on 14 Oct 2019, 17:07, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 27 Nov 2018, 13:46

outdated post...
Last edited by jdc on 14 Oct 2019, 17:08, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 28 Nov 2018, 16:21

outdate post
Last edited by jdc on 14 Oct 2019, 17:09, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby smcameron » 03 Dec 2018, 01:07

"smcameron", not "scamerson". Ranking 0.1 out of 5? Ha. Nice burn.
smcameron
 
Posts: 307
Joined: 29 Oct 2010, 23:44

Re: The Box, development tool, "Structural programming"

Postby jdc » 12 Dec 2018, 11:02

smcameron lol
Last edited by jdc on 14 Oct 2019, 17:11, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 07 Jan 2019, 14:13

Lunch a 0.0.1 version, is not a version is just a structure. If i can have things ready i will lunch 0.1.1 a working version.

The files i'm working are in google drive public folder, (some code are from other projects is there just to know how thing are done) https://drive.google.com/drive/folders/ ... ugL7glslMk

what is PHP ? - Hiper text Preprocessor Programing Language.

This means that PHP way of doing things can only be replicated with the Preprocessor which in C are the .H files.

For what i read C is a single treat language you only have main() to work with.

The structural programming can be achieved with this:

main (){
include "image.h"
include "image_JPG.h"
}

For what i tested both files .h can communicate with which other. The ".c" extension can't access which other files.

The .h files need to be in main, to work with variables, because of the single treat thing. People for what i read advice not to use variables inside .h but only declare them. This way we can use files like in PHP.

image_jpg.h is inheriting successfully from image.h

add a Patron page so ppl can contribute with $$; https://www.patreon.com/user?u=16271332

We can see now a structure in the main. Looks is like a configuration page. (is Tweakble in the code or lather outside with a interface.)


{l Code}: {l Select All Code}
   main(){
   #include "application_structures\time.h"
   #include "application_structures\error.h"
   #include "application_structures\file.h"
   #include "application_structures\string.h"
   #include "application_structures\paths.h"
   #include "application_structures\database.h"
   #include "application_structures\image.h"
   #include "application_structures\image_jpg.h"
   //#include "application_structures\image_png.h"
   //#include "application_structures\image_gif.h"
   
   #include "application_structures\sound.h"
   #include "application_structures\keys.h"
   #include "application_structures\resolution.c"
   //#include "application_structures\interface.c"

   #include "application_structures\model.h"
   #include "application_structures\model_textures.h"
   #include "application_structures\model_animation.h"
   #include "application_structures\model_particles.h"
   #include "application_structures\model_bounds.h"    //colision, triggers
   
   #include "application_structures\model_blend.c"
   //#include "application_structures\model_DAE.c"
   //#include "application_structures\model_FBX.c"
   //#include "application_structures\model_OBJ.c"
   
   #include "application_structures\camera.h
   #include "application_structures\camera_RTS.h
   //#include "application_structures\camera_FPS.h
   //#include "application_structures\camera_2D.h
   //#include "application_structures\camera_3Person.h
   
   #include "application_structures\print_screen.h
   

   #include "application_structures\movement_RPG.h"
   #include "application_structures\movement_Vehicles.h"
   
   #include "application_structures\AI.h"
   
   /* GAME STRUCTURE LIBRARY */
   
   #include "game_strutures\game.c"
   #include "game_strutures\money.c" //timers
   //#include "loots.c"
    #include "game_strutures\spells.c"
   #include "game_strutures\abilitys.c"
   #include "game_strutures\items.c"
   #include "game_strutures\items_sci_fi.c"   
   #include "game_strutures\items_rpg.c"
   #include "game_strutures\items_fantasy.c"
   
   /* TEST LIBRARY */

   //#include "variables_interface.c"
    //#include "interfaces/interface2.c"

   if (debug == 1){
      //fprintf (stderr, "%s:%d: %s: Assertion `%s' failed.\n", error_file, error_line, error_func, error_assert);
      //abort ();
   }

   printf("Choose interface : ");
    scanf("%s", str1);

   printf("Enter interface : %s", str1);

   interface = atoi (str1); // Convertes the string to a integer
   
   /*
   
      TOOLS LIBRARY
      -Interfaces can be in .c since they do not delegate any to other files.
      -The previous .h files cam delegate to .c files.
   */
   
   if(interface == 0){ // Main Menu
      //printf("Main Menu loading");
      
      #include "interfacces/main_menu_GTK.c"
      //#include "interfacces/main_menu_SDL.c"
      //#include "interfacces/main_menu_Free_GLUT.c"
   }
   else if(interface == 1){ // Character Creator

      //printf("Character Creator loading");

      #include "interfaces/character_generator_GTK.c"
   }
   else if(interface == 2){ // Shadder Tool
         //printf("Interface2");
         //#include "interfaces/interface2.c"
   }
   else if(interface == 3){ // Map Editor
         //printf("Interface3");
         //#include "interfaces/interface3.c"
   }
   else if(interface == 4){ // Variable Manager
         //printf("Interface3");
         //#include "interfaces/interface3.c"
   }
   else if(interface == 5){ // Generic Animation
         //printf("Interface3");
         //#include "interfaces/interface3.c"
   }
   else if(interface == 6){ // Particle Tool
         //printf("Interface3");
         //#include "interfaces/interface3.c"
   }
   else if(interface == 7){ // Particle Tool
         //printf("Interface3");
         //#include "interfaces/interface3.c"
   }
   else if(interface == 8){ // Level Models Position
         //printf("Interface3");
         //#include "applications/the_box/levels_models_position.c"
   }
   else if(interface == 9){ // Level Editor

         //printf("Interface9");

         //#include "applications/the_box/levels_models_position.c"
   }
   else if(interface == 10){ // Database tool
         //printf("Interface9");
         //#include "applications/the_box/levels_models_position.c"
   }
   else if(interface == 11){ // Options
         //printf("Interface9");
         //#include "applications/the_box/levels_models_position.c"
   }

   system("cls");
   system("pause");

    return 0; // Zero indicates success any other failed
}



The point of this is , if some one code a camera_RPG for their game if using a inheriting structure, can be use in your game also. A waste of time we all have to program that rpg camera again and again.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby Octavekman22 » 07 Jan 2019, 15:13

I want to know about structural programming
Octavekman22
 
Posts: 1
Joined: 07 Jan 2019, 15:12

Re: The Box, development tool, "Structural programming"

Postby Lyberta » 08 Jan 2019, 11:20

jdc {l Wrote}:For what i read C is a single treat language you only have main() to work with.


Actually, ISO C supports multithreading since C11. But most people who write C still fallback to OS API for threading.

jdc {l Wrote}:For what i tested both files .h can communicate with which other. The ".c" extension can't access which other files.


#include directive is just textual inclusion. You can access stuff that was declared before in the same translation unit (read: .c file).

jdc {l Wrote}:The .h files need to be in main, to work with variables


You can use dependency injection to pass pointers to variables you need.

Octavekman22 {l Wrote}:I want to know about structural programming


Here: https://en.wikipedia.org/wiki/Structured_programming

Basically, it's a very old paradigm that produces unreadable code mostly because of ban on early exits.
User avatar
Lyberta
 
Posts: 642
Joined: 19 Jun 2013, 10:45

Re: The Box, development tool, "Structural programming"

Postby jdc » 09 Jan 2019, 07:17

Lyberta

din't know the concept already existed and using the same name lol. I didn't read the theory, just got it from programming. My first post called it something different, then get in to this name when i mature the concept.

But one thing they got it right in the Wikipedia article, is allow to use less functions and much more if/elses, which your code become simpler.

Octman

A practical example on the inherit.

image.h -> Contains the stuff that repeats. Variables and functions. For example the height and weight repeats in the other 2 files. A compress image function, may also repeat in the other 2 files.

image.h -> repeat variables and functions
image_JPG.h -> receives variables
image_PNG.h -> receives variables

image.h
//image_JPG.h
image_PNG.h

in this way we have less code, and can comment any library that those variables are still there. If we comment image_JPG there will be nothing there that affects our system, because we put the repeating stuff in to image.h, and they
don't collide, because both are using the same structure the "image.h".

Often we can use just use if and else, because of the inheriting, the variables are at image.h with default defaults, is just a meter of doing simple test with : if and else.

In may PHP code, i removed a great amount of functions in to if/elses.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 11 Jan 2019, 00:58

How a function will look like:

Thought that it may be something like this (functions, and files) :

save.h
save_rpg.h
save_sci-fi.h

but it may end be just something like this, much simpler (1 variable):

{l Code}: {l Select All Code}

bool save = false; // inherit from save.h or other file, since is doing to little

if(save == true){
   
   int models = 0; //save this variables
   int level = 0;
   int equipment = 0;
   int skills = 0;
   int spells = 0;
   int user;
   
   FILE * fp; // writte to a file or a database
   fp = fopen ("c:\\temp\\1.c","w"); /* open the file for writing*/
   for(counter_1 = 0; counter_1 < 10; counter_1++){ /* write 10 lines of text into the file stream*/
       fprintf (fp, "This is line %d\n",i + 1);
   }
 
   fclose (fp);/* close the file*/
   save = false;
}


Since every thing is inherit, there is no point in writing a function, this goes in to the game while loop. once something activate save to true, it saves.

Never get to a point where this stuff get to 1000 lines, when we need to add something it become a bit of confusion, but if get to that not sure how it will be improved. But probably will not get to that since must of the code is inherit, when we get to the lower levels there is to little code.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 15 Jan 2019, 10:51

outdated post...
Last edited by jdc on 14 Oct 2019, 18:03, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 29 Jan 2019, 08:12

I see a lot of interest of people in coding, but not that many are successful in doing some programming or learning.

I think the main aspect of programming is learning how to debug code. Because most of the problems are related to conflicts inside the code.


There are probably many approach to debugging was there is to programming.

But this is how i do it.

I separate the code in to library's, not just to do better programming but also to do better debugging.

I this error in c : "unexpected token in variables", since i read the tutorials and have some experience in programming i already know that is not related to variables.

how did i debug this error and in general?

I move the code to a smaller environment. like the file main_tests.c which i now updated it to the google drive project.

in the file you can post the stuff related to what you are doing.

For example if you are working with images. Post only image code.

"variables"

image.h
image_JPG.h

"functions"


So now you have only image related code in to do tests in 2º main file. In this case It will output no error because it was not related to variables.

In this way you can code like i do, can code large amounts of code, then debug bits. If you are not doing like this you need to program first and plan lather. But you need to plan first code lather. To have a better code need to plan first and prevent from having unmaintainable code.

This style of coding is good for debugging since every thing is modular, can test only the needed parts.

Is this need?

Compilers often send weird errors not always is related to any thing
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby Lyberta » 30 Jan 2019, 06:37

The idea is that you compile each cpp file separately.
User avatar
Lyberta
 
Posts: 642
Joined: 19 Jun 2013, 10:45

Re: The Box, development tool, "Structural programming"

Postby jdc » 04 Feb 2019, 06:06

Lyberta

all stuff is linked if you read the Make file in C it is linking stuff. High level languages have automated way to this stuff, in lower level you need to do all stuff by hand. So when people say to me that a lower language does not work in a way, it is much more likely that you make a low level language work the way you wanted then a high level language because. A high level my already have a very high level of nested stuff. In a PHP framework i could't even add a array unstructured to the framwork. It only handle logic connected stuff. That's why frameworks are so heavy they add layers of processing to the raw stuff, also hard to learn because they created a new set of rules.

Stuff that i added to the project:

windows.h -> handles a basic windows in a procedural way.
STB image -> this library have image handling in procedural code, working on to separated in to the image.h, image_JPG.h etc...
Attempting o see if Ogre3D could be use for better graphics, but they say it needed to speak to C which is no implemented.

this post address that issue.

https://forums.ogre3d.org/viewtopic.php?t=63153

Maybe use horde3D which have a way to communicate with C

A example on ho to convert code variables "structures" to the box general structure

{l Code}: {l Select All Code}

enum ITEMTYPE
{
      MI_PARENT, MI_ACTION
};

struct MENUITEM {

      enum ITEMTYPE type;
      char *name;
      char *helpstring;
      void *p;
};

struct MENU {

      int vertical;
      char *name;
      int left;
      int top;
      int right;
      int bottom;
      int count;
      struct MENUITEM **menuitemlist;
      int curritem;
      struct MENU *parent;
};

char menu_item_TYPE; // Actions : MI_PARENT, MI_ACTION
char *menu_item_name;
char *menu_item_helpstring;
void *menu_item_p;

int menu_vertical;
char *menu_name;
int menu_left;
int menu_top;
int menu_right;
int menu_bottom;
int menu_count;
struct MENUITEM **menuitemlist;
int menu_current_item;
struct MENU *parent;


we convert it to better named variables, and put actions in to comment's.

It removes redundancy, simplifices, and is easy to add and remove things in the code.

In here we removed 4 lines with 1 enum less.

2 lines from a nested menu item structure.

2 lines from a nested menu item menu.

the linking variables part is no implemented.

This is to show how the code reads better.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 04 Feb 2019, 11:05

outdated post...
Last edited by jdc on 14 Oct 2019, 15:14, edited 1 time in total.
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Re: The Box, development tool, "Structural programming"

Postby jdc » 24 Jul 2019, 17:42

The database concept.

Separation of the database engine to array format.

in our array db we can automate the db calls in programing. To build high complex relations lather.

by creating a array stucture with the rules then we can create new rules. was we need them. Which can help see the relations, which we can't if they are already in a engine format. Also allow to use bette with seveal engines. For example a image structure array allow to build rules for .PSD and .JPG. It is not just for DB's.

Probably more stuff build in a universal format will lather allow much more projects to be imported to othe languages.

Files:

database.h // generic variables
database_mysql.h // calls
database_sql3.h //lite , just for example
database_interface.h // interface in procedural
databes/box_db.h //separation of the database engine to array format.



*I only study db's have to see how to apply to othes.

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

Now the files will have the tutorials on top of the file if you want to work on them or learn will be more easy to follow.

How the database_interface.h look : examples for a procedural interface. All related tutorials on what is being done at the moment.

For example if you follow the tutorials they are emolating DOS to have a procedual interface working



The files shoud be in : https://drive.google.com/drive/folders/ ... 7K9ajqU1UT

if you need to contact you can use this email eva.project.dev@gmail.com
jdc
 
Posts: 67
Joined: 29 Jun 2017, 16:48

Who is online

Users browsing this forum: No registered users and 0 guests