#Can we show changing texts in the windows?
63 messages ยท Page 1 of 1 (latest)
I cannot compile this because pong.h is missing
here's the rest of the files
okay i will see
thks
how can i use vectors? Cause that means i would have or change everything
this functions needs a vector and a rectangle variables
and also how do i use rectangles ?
Do you understand using a struct?
yeah i know about structs
Then you should understand the Vector2
It is two floats, x and y
oh okay
sounds simple on paper
It shouldn't need explanation beyond that
Have you opened raylib.h?
the file itself ?
Yeah
nah i'm just using it in this project
i haven't opened it
Well you should
It's documentation
lemme check that then
thanks
Can we show changing texts in the windows?
Okay so i have a question. Now that my program is working, i made a score system. But all the draw text functions have const char*. Isn't there a way to show the score that is changing
TextFormat("score: %d", score)
or sprintf
oh okay
thks again i guess
don't store the pointer this function returns btw
oh its about pointers? i will read it in the raylib.h
what do you think a const char* is?
yeah i know about "constant" char ๐ thanks
char* <- this is a pointer type
you know that, right?
wait you cannot change the value of a const char with a pointer, can you ?
i know its a pointer but the const char cant be change.
you can change the value of the pointer but you can't write anything through the pointer
ohh thats broken
const is kind of useless tbh
yeah ๐คฃ
it doesn't help that you can cast the const away and write to it anyway
if you wanted both then that would be const char* const
this is "a pointer that can't be reassigned and can't be written through"
so by using a pointer you can change the value of the const char without passing the char itself
No
C has a (crappy) string convention of null-terminated string
you should read about it
i didn't know about it damn
the pointer is pointing to some memory, that contains an "array of chars", ending with a 0 byte
so you dont really change the const char then ? only the pointer
no that's just how you pass a string
it's const to indicate to programmers that it doesn't modify the "chars" the string is pointing to, it just draws the string
read this
(it's important, and basic)
yeah thanks because i didn't know anything about this
I try to avoid the standard C "pointer to null terminated char array" when I can
This isn't one of those cases
okay i will try on a small file to see if i understand
You can certainly just pass char* to these functions. That const is function internal thing effectively.
const char* dog = "Dog"; // Pointer to constant char
const char* cat = "Cat";
char* const horse = "Horse"; // Constant pointer to char
const char* const sheep = "Sheep"; // Constant pointer to constant char
char* cow = "Cow";
// These are valid.
cat = dog;
cow = horse;
dog = (char*)sheep;
// And you can draw them all.
DrawText( cat, 20, 20, 20, RED );
DrawText( cow, 20, 50, 20, RED );
DrawText( dog, 20, 80, 20, RED );