This is my programming questions thread.

I've started learning C++, so I was looking at some source code and I saw an fdh file. I was wondering how its different from .h and .cpp files.
Is this a valid operator in C?

Code:
->

If so, what is it used for?
It's used for accessing a structure element. This is used in place of the . operator when used as a pointer to a structure:


Code:
typedef struct my_struct {
    int abc;
} my_struct_t;

void main(void) {
    my_struct_t *test = (my_struct_t*)malloc(sizeof(my_struct_t));
    test->abc = 1000;
}
Using the C libraries, is there any way to display numbers above the range provided by gfx_PrintUInt?
Create your own routine to convert a number to digits in a string, and display the string.
How do I create and use Transparent sprites? I tried a few times but I've never gotten it to work for me.
calcnerd_CEP_D wrote:
How do I create and use Transparent sprites? I tried a few times but I've never gotten it to work for me.

Convert it the same way you do with normal sprites; just specify the 'TranspColor:' in convpng.ini and use gfx_TransparentSprite instead of gfx_Sprite.
Thanks Mateo! I finally got it to work! Smile

Next question: How would I use commands like gfx_ShiftRight? What are some of its uses?
calcnerd wrote:
How would I use commands like gfx_ShiftRight? What are some of its uses?

They shift the window by the specified pixels. By default the window is the screen dimensions; although you can change the size of the window with gfx_SetClipRegion. Smile
How would this be used in a game? I've tried a bit, but I haven't found any examples yet.
calcnerd_CEP_D wrote:
How would this be used in a game? I've tried a bit, but I haven't found any examples yet.

It could help with magic effects, like a screen shake, or even some sort of scrolling. (I'm not entirely sure about the uses of it, but I believe those are plausible.) Wink
Is there a way to erase sprites fast? So far all I've ever done was fill the area with rectangles.
calcnerd_CEP_D wrote:
Is there a way to erase sprites fast? So far all I've ever done was fill the area with rectangles.

Well what are you doing? As for using the shifting routines, there is indeed a demo that demonstrates them.

Here's a screenshot. Right now I'm trying to get scrolling done. Sorta a game, but I've just used it to mess around with stuff and try new commands. Totally copied gun sprite off doom.
EDIT: Here's an animated gif of it know. It looks really glitchy since I'm using gfx_FillRectangle.
inb4 DOOMCE?

But about that flickering, you may want to implement buffers, depending on how slow/fast your game is Wink

But yeah, you wanna use gfx_Rect..., it's faster than the fullscreen thing.
Quote:
you may want to implement buffers

How do I implement buffers? I've tried it occasionally, but never gotten it to work.
calcnerd_CEP_D wrote:
Quote:
you may want to implement buffers

How do I implement buffers? I've tried it occasionally, but never gotten it to work.


It's ez pz once you get it. Wink I had a hard time as well, thought it was much more complicated than it was. basically, you have this buffer, which sorta is another screen that you can draw to that doesn't display. what you do, is gfx_SetDrawBuffer(); draw stuff, (you won't see anything on screen yet) and then do gfx_SwapDraw(); and you will see things magically appear, and it will eliminate flickering. Wink
calcnerd_CEP_D wrote:
Quote:
you may want to implement buffers

How do I implement buffers? I've tried it occasionally, but never gotten it to work.

There is also this nice and helpful wiki page that describes how buffers are implemented Smile Feel free to read the doc, and suggest more topics for documentation! Very Happy

Link: https://github.com/CE-Programming/toolchain/wiki/GraphX-Library:-Buffering
Thanks for the help! Smile I got it running a lot smoother, and I added a better firing animation.

Is there any way to get better color conversion with convpng? If so, what would I have to change in my code?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement