You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There have been a few times where I have needed to make the console background transparent while debugging. Just to make it so a black box isn't covering up a portion of the screen.
When a console is created new_custom_console() the Console structure's address is assigned to the FILE->data pointer. This pointer is of type void, so it seems you can't access the members of Console without knowing the exact byte position that controls the transparency of the sprite relative to the start address of the FILE->data pointer.
There is workaround I have for this by re-declaring the Console structure in my program's header file, and then assigning the data member of my FILE structure that I use for my console to a new Console structure pointer. Below is an example of this.
//program.h
//type definition copied from new_custom_console.c into my program's header
typedef struct {
short int x;
short int y;
short int width;
short int height;
sprite *s;
} Console;
//declare a FILE structure in order to open a new console with
FILE *myConsole;
//program.c
//create the console
myConsole = open_custom_console(d, 3, 8, 0, 40, 4, 15);
//set the data member to a temporary Console structure to gain access to the hidden sprite structure
Console *co = myConsole->data;
//now I can make the console background transparent
co->s->trans = 1;
This works, but I wanted to see if there might be a chance of adjusting the FILE structure could be altered to not lose the ability to access the sprite structure in the Console structure.For example like this:
FILE->Console->s->trans = 1;
Doing it this way would reduce the lines of code needed, not needing to keep track of two structures to change members of one of those structures.
If this isn't possible, could we at least make the type Console more globally accessible as opposed to keeping it only in new_custom_console.c, so I don't have to redefine the Console type in my program's head files?
The text was updated successfully, but these errors were encountered:
There have been a few times where I have needed to make the console background transparent while debugging. Just to make it so a black box isn't covering up a portion of the screen.
When a console is created new_custom_console() the Console structure's address is assigned to the FILE->data pointer. This pointer is of type void, so it seems you can't access the members of Console without knowing the exact byte position that controls the transparency of the sprite relative to the start address of the FILE->data pointer.
There is workaround I have for this by re-declaring the Console structure in my program's header file, and then assigning the data member of my FILE structure that I use for my console to a new Console structure pointer. Below is an example of this.
This works, but I wanted to see if there might be a chance of adjusting the FILE structure could be altered to not lose the ability to access the sprite structure in the Console structure.For example like this:
Doing it this way would reduce the lines of code needed, not needing to keep track of two structures to change members of one of those structures.
If this isn't possible, could we at least make the type Console more globally accessible as opposed to keeping it only in new_custom_console.c, so I don't have to redefine the Console type in my program's head files?
The text was updated successfully, but these errors were encountered: