Discuss Scratch

NxNmultiply
Scratcher
100+ posts

Cross-language workaround

R4356th wrote:

NxNmultiply wrote:

R4356th wrote:

say []
in C++:
printf ()
Uhh, this function appends text to console output, not changes the graphical speech visualization.
What do you mean?

I haven't ever seen an environment where printf makes Scratch style speech appear, overwriting the previous one.
R4356th
Scratcher
1000+ posts

Cross-language workaround

NxNmultiply wrote:

R4356th wrote:

NxNmultiply wrote:

R4356th wrote:

say []
in C++:
printf ()
Uhh, this function appends text to console output, not changes the graphical speech visualization.
What do you mean?

I haven't ever seen an environment where printf makes Scratch style speech appear, overwriting the previous one.
Yeah, but in a way, it does the same thing. Says or prints something.
Sheep_maker
Scratcher
1000+ posts

Cross-language workaround

R4356th wrote:

NxNmultiply wrote:

R4356th wrote:

snip

I haven't ever seen an environment where printf makes Scratch style speech appear, overwriting the previous one.
Yeah, but in a way, it does the same thing. Says or prints something.
One could argue that it isn't sufficient because the text can't be hidden afterwards, so there can't be a
say [Hello!] for (2) secs
Scratchers also use the say block for an animated dialogue reveal, which reveals each letter every frame, but with your workaround it would result in triangular text:
H
He
Hel
Hell
Hello
Hello!

- Sheep_maker This is a kumquat-free signature. :P
This, my signature, appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
Post count: more than 6
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

As for graphics, the WriteConsoleOutput function (Windows 2000 and up) writes characters (either 8-bit or 16-bit) and attributes (includes 4-bit foreground color and 4-bit background color). With a pixel font and 480 characters per row and 360 rows, this should simulate the Scratch stage, though there can only be up to 16 colors. The colors may be changed over time in Vista and up with SetConsoleScreenBufferInfoEx, however there can still be only up to 16 at a time. I don't think TrueType anti-aliasing would work (gamma-correct shades in 1÷16 increments in classic GDI, shades in 1÷6 increments with gamma depending on the tuning and shifted red and blue channels in ClearType GDI) because the only way I got a pixel font working is as a bitmap font, because outline fonts must have a point size from 5 to 72, and the point size is based on the font height. So, 16 colors only, and the colors may be changed by the application in Vista and up but still 16 at a time.

Last edited by NxNmultiply (March 28, 2020 18:51:21)

Wettining
Scratcher
500+ posts

Cross-language workaround

NxNmultiply wrote:

(()mod())

The modulo operation does not exist on doubles, it is only a mathematical abstraction of Scratch (and Javascript). Therefore it must be implemented in software, therefore long double to handle intermediate precision.

In C++

double mod(double a, double b){
    long double c = (a/b);
    long double d = 0;
    long double e;
    while((c-d)<0){
        e = 1;
        do{
            e *= 2;
        }while(e<=(d-c));
        e /= 2;
        d -= e;
    }
    while((c-d)>=1){
        e = 1;
        do{
            e *= 2;
        }while(e<=(c-d));
        e /= 2;
        d += e;
    }
    return (a-(d*b));
}
Or just
std::fmod(5,3);
R4356th
Scratcher
1000+ posts
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

The printf or std::cout function also always appends the text at the end, so if graphics is already drawn in the console, they would be scrolled up by the function.
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

wait()secs
In C++:
#include <windows.h>
void wait(double time){
        Sleep(int(time*1000.0));
}
R4356th
Scratcher
1000+ posts

Cross-language workaround

forever

end
in C:
while (true)
{

}

Last edited by R4356th (April 19, 2020 12:17:59)

NxNmultiply
Scratcher
100+ posts

Cross-language workaround

R4356th wrote:

say []
in C:
 
printf( )
For it to work you have to also position the cursor (#include <windows.h> SetConsoleCursorPosition(hConsole, {X, Y});) at the location of speech, which would be somewhat complicated to determine.

Last edited by NxNmultiply (April 19, 2020 15:09:20)

NxNmultiply
Scratcher
100+ posts

Cross-language workaround

R4356th wrote:

That is a known fact.
Uhhh this isn't in the official C specification because they don't need to cross-language workaround Scratch blocks
ElsieBreeze
Scratcher
100+ posts

Cross-language workaround

NxNmultiply wrote:

R4356th wrote:

say []
in C:
 
printf( )
For it to work you have to also position the cursor (#include <windows.h> SetConsoleCursorPosition(hConsole, {X, Y});) at the location of speech, which would be somewhat complicated to determine.
If only Windows handled the console sensibly like Linux does.

Greetings! I'm ElsieBreeze (but y'all can call me Elsie). I'm just a girl who loves to code, nothing too extravagant

I run Windows 10 in a Virtual Machine for Gaming:tm: and Gentoo/Linux on my main system. DNS over Tor is fun.

Like Tetris? Try https://xnopyt.com/js-tetris.html Or, for a twist: https://xnopyt.com/js-pentris.html
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

ElsieBreeze wrote:

NxNmultiply wrote:

R4356th wrote:

say []
in C:
 
printf( )
For it to work you have to also position the cursor (#include <windows.h> SetConsoleCursorPosition(hConsole, {X, Y});) at the location of speech, which would be somewhat complicated to determine.
If only Windows handled the console sensibly like Linux does.
?
Wettining
Scratcher
500+ posts

Cross-language workaround

NxNmultiply wrote:

ElsieBreeze wrote:

NxNmultiply wrote:

R4356th wrote:

say []
in C:
 
printf( )
For it to work you have to also position the cursor (#include <windows.h> SetConsoleCursorPosition(hConsole, {X, Y});) at the location of speech, which would be somewhat complicated to determine.
If only Windows handled the console sensibly like Linux does.
?
https://thoughtsordiscoveries.wordpress.com/2017/04/26/set-and-read-cursor-position-in-terminal-windows-and-linux/
Windows is just weird
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

Wettining wrote:

Stay on topic immediately.
Wettining
Scratcher
500+ posts

Cross-language workaround

NxNmultiply wrote:

Wettining wrote:

Stay on topic immediately.
It is on topic? The link shows how to set the location of the text cursor on *nix and Windows consoles in C/C++ which is almost necessary knowledge for programming in these languages and relates to what NxNMultiply was saying
NxNmultiply
Scratcher
100+ posts

Cross-language workaround

clear graphic effects

In C++

double effects[7];
uint32_t currentcostume[172800];
uint32_t costume;
typedef struct sprite1costume{
    const uint32_t costume1data[172800] = ...;
    const uint32_t costume2data[172800] = ...;
    ...;
} TYPEDEFERROR;
void cleargraphiceffects(){
    for(uint8_t i=0; i<7; i++){
        effects[i] = 0.0;
    }
    for(uint32_t i=0; i<172800; i++){
        currentcostume[i] = sprite1costume[costume][i];
    }
}
Maximouse
Scratcher
1000+ posts

Cross-language workaround

Sheep_maker wrote:

R4356th wrote:

NxNmultiply wrote:

R4356th wrote:

snip

I haven't ever seen an environment where printf makes Scratch style speech appear, overwriting the previous one.
Yeah, but in a way, it does the same thing. Says or prints something.
One could argue that it isn't sufficient because the text can't be hidden afterwards, so there can't be a
say [Hello!] for (2) secs
Scratchers also use the say block for an animated dialogue reveal, which reveals each letter every frame, but with your workaround it would result in triangular text:
H
He
Hel
Hell
Hello
Hello!
Previous output can be hidden by printing a carriage return.

You are reading Maximouse's signature. Learn more about signatures
Click here to make pixel art.
Be strong

Paddle2See wrote:

It's impressive how many suggestions are duplicates!

Powered by DjangoBB

Standard | Mobile