The "to do list"
The file is online, it have all the functionality need for this stage. No point in waiting to lunch it width the 0.0.3 version, since is needed now. The rest of updates if not necessary will come width the version, like updates to the to list and planning of the project. Or improvements to code.
https://drive.google.com/open?id=1tw3UoJJI4cYsx6rH_ncojxIxZNTvzwtO
Game engine in C and open source, The Box, structural programming
Added a discord server : https://discord.gg/g54Fgc
To prevent repetition from topics and debate ideas and code
jdc said:
Joej you want to work in visual study code?
Go work for Microsoft.
I'll consider it, thanks.
Now we have 3 files.
As for people debating : read the MVC, “separate logic from presentation” and the DRY principle “Do not repeat your self”. This stuff is the basics for coding. If you only work in engines that you can't see the source you will never learn this.
In here we are applying this principles we don't repeat any thing and separate logic from presentation in the same principle 2 files and another as the root which will handle more stuff lather.
bitmap.h
bitmap.c
test_bitmap.c
I was reading that you need a structure to load a bitmap, but if any one can confirm the information appreciated. Or i will dig a bit more in to it lather.
struct BMP
{
char Type[2]; //File type. Set to "BM".
unsigned long Size; //Size in BYTES of the file.
unsigned long Reserved; //Reserved. Set to zero.
unsigned long OffSet; //Offset to the data.
unsigned long headsize; //Size of rest of header. Set to 40.
unsigned long Width; //Width of bitmap in pixels.
unsigned long Height; // Height of bitmap in pixels.
unsigned int Planes; //Number of Planes. Set to 1.
unsigned int BitsPerPixel; //Number of Bits per pixels.
unsigned long Compression; //Compression. Usually set to 0.
unsigned long SizeImage; //Size in bytes of the bitmap.
unsigned long XPixelsPreMeter; //Horizontal pixels per meter.
unsigned long YPixelsPreMeter; //Vertical pixels per meter.
unsigned long ColorsUsed; //Number of colors used.
unsigned long ColorsImportant; //Number of "important" colors.
};
Don't know if it just need the header size.
In the test_bitmap.c we can have external libraries since we are only testing, before our costume code is done to assemble in to a large engine.
the static variables work in a loop. People argue a lot about this when i start posting static variables.
images = “”;
while(){
color = “”
name = “”
width = “”
image_array_Store;
…
}
I store only values that needed to change. A image few thing chances after load unless you are using for some kind of dynamic. In this case it chances since it will used BMP to store pixels information. It will store for example other images. But images it self will not change.
The code for the files :
test_bmp.c
Load the objects in to test debug tool bitmap : path and bitmap. As mention do some debug also for the bitmap to know if have any errors.
//https://www.daniweb.com/programming/software-development/threads/146692/how-to-display-a-image-in-c
//https://cboard.cprogramming.com/c-programming/50007-reading-bitmap-image.html
// https://codereview.stackexchange.com/questions/8213/bitmap-implementation
#include <alloc.h>
#include <conio.h>
#include <graphics.h>
#include <stdio.h>
#include <stdlib.h>
#include "../application_structues/bitmap.h";
#include "../application_structues/path.h";
char images[5];
int loop;
void main()
{
int color;
int gd ;
int gm ;
gd = VGA ;
gm = VGAHI;
printf("%s \n File name");
printf("%s \n size", Size);
printf("%s \n reserved", Reserved);
printf("%s \n Offset", OffSet);
printf("%s \n Offset", headsize);
printf("%s \n Offset", Width);
printf("%s \n Offset", Height);
printf("%s \n Offset", Planes);
printf("%s \n Offset", BitsPerPixel);
printf("%s \n Compression", Compression);
printf("%s \n Compression", SizeImage);
printf("%s \n Compression", XPixelsPreMeter);
printf("%s \n Compression", YPixelsPreMeter);
printf("%s \n Compression", ColorsUsed);
printf("%s \n Compression", ColorsImportant);
initgraph(&amp;gd, &amp;gm, "");
images = {"test.bmp", "test2.bmp", "test3.bmp"};
folder = "c:/documents/the_box/debug_tools";
#include "../labraries_stack/bitmap.c";
getch();
closegraph();
}
The variables images and folder working . And the stack file to open images. Loading system library's to test debug tools
bitmap.c
the stack file. Going to get most possible performance by doing all width loops. For example string concatenation in a loop. This is the point of low level can get more performance width procedural code.
//https://www.quora.com/How-can-I-display-image-in-C
//int ShowBMP(int x, int y, char* FileName)
size_t loop = sizeof(images)/ sizeof(images[0]); // elements in the array
/*
To determine the number of elements in the array, we can divide the total size of the array by the size of the array element.
*/
if(loop == 0)
{
printf("error in the images array");
}
else
{
}
while (loop != 0){
int b,a;
BMP BMP_obj;
unsigned char* Datas;
int in = 0;
unsigned char c = 0;
int string_lenght;
int string_lenght2;
images[loop];
if(folder == ""){
printf("folder variable error");
}
//folder = "c:/documents/";
string_lenght = 0;
string_lenght2 = 0;
while(folder != '\0'){ // length of string 1
string_lenght++;
}
while(images[loop] != '\0'){ //
string_lenght2++;
file[string_lenght] = images[loop];
}
//for (j = 0; s2[j] != '\0'; ++j, ++i) // concatenating each character of s2 to s1
//{
// s1[i] = s2[j];
//}
printf("After concatenation: ");
puts(s1);
// terminating s1 string
s1[i] = '\0';
while(file[string_lenght] != '\0')//calculate lenght of string
{
}
FILE_pointer = fopen(file, "rb");
if(!FILE_pointer){
printf("Error : Unable to open file");
}
fread(&amp;BMP_obj, sizeof(BMP_obj), 1, FILE_pointer);
if(BMP_obj.BitsPerPixel !=4) // This isn't a 16 color bmp we can read;
{
fclose(FILE_pointer);
printf("Error : File format not supported ..");
exit(0);
}
fseek(FILE_pointer, BMP_obj.OffSet, SEEK_SET);
Datas = (unsigned char*) calloc(BMP_obj.Width/2+1, sizeof(unsigned char));
for(b = BMP_obj.Height; b >= 0; b--)
{
fread(Datas, sizeof(unsigned char), BMP_obj.Width/2, FILE_pointer);
c = 0;
in = 0;
for(a = 0; a <= Obj.Width; a += 2)
{
c = (Datas[in] | 0x00) >>4;
putpixel(a+x,b+y,c);
c = (Datas[in] | 0xF0) &amp; 0x0F;
putpixel(a+1+x,b+y,c);
in++;
}
}
free (Datas);
fclose(FILE_pointer);
loop--;
}
The bitmap.h
Still is not doing as much i wanted but is the possible work at the moment. To do Objects you need a lot of knowledge.
const int BmpHeaderSize = 54;
struct BmpHeader
{
char ID[2];
long FileSize;
long RESERVED;
long BitmapDataOffset;
long BitmapHeaderSize;
long Width;
long Height;
short NrOfPlanes;
short BitsPerPixel;
long Compression;
long BitmapDataSize;
long HorizontalResolution;
long VerticalResolution;
long Colors;
long ImportantColors;
};
Path.h
Is still a bit mess. But it suppose to inherit pointers for files and directory and variables for the same.
char file[] ;
char file_path[] ;
char folder[];
char * path;
size_t string_length;
int path_length;
int extension_length;
int length;
const char * extension;
FILE * FILE_pointer; // FILE is a default structure that holds the information on the file, in order to work with files. Requires stdio.h, scanf printf
DIR * DIR_pointer; // DIR is a default structure that holds the information on the directory,
Hope you people like the post, i will try to put it working as soon as possible.
Hope you people like the post, i will try to put it working as soon as possible.
I don't think you have to rush. I mean, take your time, get it to work, and then share with us later so we can discuss a thing or two. At this point I think you already have an idea you want to try out, and you want to talk about it (not discussing about it), which is fine.
One thing you might not aware though, this forum exists since the era when everyone had to write their own engine. Even today there are veterans who are very well-verse in wring game engine. Some of them even wrote game engine entirely in C before.
What I want to say is, at least consider reading comments and give it a thought. They are trying to stop you from running straight into nowhere.
http://9tawan.net/en/
Ya but this is a long therm project, not rushing any thing.
Never thought in completing it in a short therm objective. Most of this stuff and tools have long therm objectives. I will do them when i have enough knowledge. Probably in a couple of years. Start the project so that we have something “going”. One of the objectives is schools. That's why i document all the tutorials, for people to learn.
One think i missed in posts is : often people say it does not work, but point to code, and example and better ways to do it never Shaw.
I have the experience to do it and I read people comments.
Why post? People in our social life don't talk about programming is “more just for fun”. And people help out debating ideas, most of this stuff i probably did not develop so fast if i was only there thinking alone.
How the interface is evolving
We can now use the concept of layers, we set the background to layer 0. The interface to layer 1, and mouse 2.
But in a game we could have background to 0, interface since is above graphics to layer 5, then images, models etc,, in the middle layers, layer 2 models, layer 3 images, layer 4 effects.
layer[0] = "background";
background_color = "white";
layer[1] = "interface";
links = 1;
menu = 1;
text_style = "";
menu_title = "Tutorials Menu : pick option";
menu_links_ = {"1. List tutorials ", "2. Add Tutorial", "3. Add Dev Log", "4. Add Book", "5. Add Guide"};
layer[2] = "mouse actions";
I was thinking
in games like DOTA, since the map does not change, it could store parts, of it in the layer map.
layer[0] = “background”.
layer[1] = “map”.
The performance will be very fast once it store all the map. Then we get monitor position on the map.
But in more dynamic games or fast games, don't know if it will have any effect on performance. Game will end very fast, the time to store every thing it will probably not happen.
Any way for what i read C# stores things in bitmaps. Don't know if is only for images or also for graphics.
jdc said:
Ya but this is a long therm project, not rushing any thing.
Never thought in completing it in a short therm objective. Most of this stuff and tools have long therm objectives. I will do them when i have enough knowledge. Probably in a couple of years. Start the project so that we have something “going”. One of the objectives is schools. That's why i document all the tutorials, for people to learn.
One think i missed in posts is : often people say it does not work, but point to code, and example and better ways to do it never Shaw.
I have the experience to do it and I read people comments.
Why post? People in our social life don't talk about programming is “more just for fun”. And people help out debating ideas, most of this stuff i probably did not develop so fast if i was only there thinking alone.
Well if you want to ‘discuss’ or ‘debate’, I think you will have more weight once you have something to prove your idea. Things like “number”, “performance”, “statistic”, etc. If you don't have any of these thing then no one will want to talk with you.
Also I think the thread becomes something like journal, which may be the blog section is more suitable.
http://9tawan.net/en/