This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-04-27 18:28:11

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

C++ talk

Since the focus of my C# thread changed to C++, I decided to make this thread so the other thread can get back on focus to C#.

You post almost anything that has to do with C++ here.

If you don't know C++, you can go here: http://www.cplusplus.com/doc/tutorial

Offline

 

#2 2010-04-27 18:53:55

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

Here is a madlib made by gershmer that I ported into C++

Code:

#include <iostream>
#include <string>
#include <conio>
using namespace std;

int main ()
{
   string mlnoun, mladjec;
   int mlnum;
   cout << "Noun: ";
   cin >> mlnoun;
   cout << "\nAdjective: ";
   cin >> mladjec;
   cout << "\nNumber: ";
   cin >> mlnum;
   cout << "\n\nWelcome to my " << mlnoun << ".\nIt is " << mladjec << ".\nPay me $" << mlnum << " or else!";
   cout << "\n\nPress any key to close.";
   getch();
   return 0;
}

Last edited by ThePCKid (2010-04-27 19:09:02)

Offline

 

#3 2010-04-27 19:20:02

gershmer
Scratcher
Registered: 2009-02-12
Posts: 1000+

Re: C++ talk

ThePCKid wrote:

Here is a madlib made by gershmer that I ported into C++

Code:

#include <iostream>
#include <string>
#include <conio>
using namespace std;

int main ()
{
   string mlnoun, mladjec;
   int mlnum;
   cout << "Noun: ";
   cin >> mlnoun;
   cout << "\nAdjective: ";
   cin >> mladjec;
   cout << "\nNumber: ";
   cin >> mlnum;
   cout << "\n\nWelcome to my " << mlnoun << ".\nIt is " << mladjec << ".\nPay me $" << mlnum << " or else!";
   cout << "\n\nPress any key to close.";
   getch();
   return 0;
}

Oh my gosh. Thanks for porting it to C++, what would I do with it, though?


Visit my site, Gershmer.net
Leave me a voicemail at my Google Voice number, [removed]

Offline

 

#4 2010-04-27 19:33:01

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

gershmer wrote:

ThePCKid wrote:

Here is a madlib made by gershmer that I ported into C++

Code:

#include <iostream>
#include <string>
#include <conio>
using namespace std;

int main ()
{
   string mlnoun, mladjec;
   int mlnum;
   cout << "Noun: ";
   cin >> mlnoun;
   cout << "\nAdjective: ";
   cin >> mladjec;
   cout << "\nNumber: ";
   cin >> mlnum;
   cout << "\n\nWelcome to my " << mlnoun << ".\nIt is " << mladjec << ".\nPay me $" << mlnum << " or else!";
   cout << "\n\nPress any key to close.";
   getch();
   return 0;
}

Oh my gosh. Thanks for porting it to C++, what would I do with it, though?

I don't know, but if you put the code in a C++ compiler and compile it, you can run your madlib offline!

Offline

 

#5 2010-04-27 19:44:00

TheGenius95
Scratcher
Registered: 2009-06-09
Posts: 500+

Re: C++ talk

I love computers, but I don't know very much about programming itself.  For example, where do I compile these C++ programs at?  It seems like something I could learn.


http://i51.tinypic.com/i40h3l.png
^ Oooh, shiny!

Offline

 

#6 2010-04-27 19:48:55

TheGenius95
Scratcher
Registered: 2009-06-09
Posts: 500+

Re: C++ talk

I'll come back tomorrow.

CURSE YOU, SIXTY SECOND RULE!  MAY YOU ROT IN A CAVE IN THE MIDDLE OF NOWHERE LISTENING TO BARNEY CD'S UNTIL THE END OF TIME!


http://i51.tinypic.com/i40h3l.png
^ Oooh, shiny!

Offline

 

#7 2010-04-27 19:54:25

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

Here is a quick program/tool that I made that sees if a number is even or odd

Code:

#include <iostream>

void main ()
{
   int numb;
   std::cout << "Type in a number (0 to exit): ";
   std::cin >> numb;

   if (numb != 0)
   {
      if (numb%2 = 0)
         std::cout << numb << " is an even number.\n";
      else
         std::cout << numb << " is an odd number.\n";

      main ();
   }
   else
      exit (0);
}

Offline

 

#8 2010-04-27 19:56:53

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

TheGenius95 wrote:

I love computers, but I don't know very much about programming itself.  For example, where do I compile these C++ programs at?  It seems like something I could learn.

There are many compilers out there.

Try Googling "C++ compiler"

Offline

 

#9 2010-04-27 20:16:57

TheGenius95
Scratcher
Registered: 2009-06-09
Posts: 500+

Re: C++ talk

ThePCKid wrote:

TheGenius95 wrote:

I love computers, but I don't know very much about programming itself.  For example, where do I compile these C++ programs at?  It seems like something I could learn.

There are many compilers out there.

Try Googling "C++ compiler"

Okay!


http://i51.tinypic.com/i40h3l.png
^ Oooh, shiny!

Offline

 

#10 2010-04-27 21:37:53

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

gershmer wrote:

ThePCKid wrote:

Here is a madlib made by gershmer that I ported into C++

Code:

#include <iostream>
#include <string>
#include <conio>
using namespace std;

int main ()
{
   string mlnoun, mladjec;
   int mlnum;
   cout << "Noun: ";
   cin >> mlnoun;
   cout << "\nAdjective: ";
   cin >> mladjec;
   cout << "\nNumber: ";
   cin >> mlnum;
   cout << "\n\nWelcome to my " << mlnoun << ".\nIt is " << mladjec << ".\nPay me $" << mlnum << " or else!";
   cout << "\n\nPress any key to close.";
   getch();
   return 0;
}

Oh my gosh. Thanks for porting it to C++, what would I do with it, though?

Here is a new version:

Code:

#include <iostream>
#include <string>
#include <conio>
using namespace std;

void main ()
{
    string mlnoun, mladjec;
    int mlnum;
    cout << "Noun: ";
    std >> mlnoun;
    cout << "Adjective: ";
    std >> mladjec;
    cout << "Number: ";
    std >> mlnum;
    cout << "\n\nWelcome to my " << mlnoun << ".\nIt is " << mladjec << ".\nPay me $" << mlnum << " or else!";
    cout << "\n\nPress any key to exit.";
    getch();
    exit (0);
}

It fixes a bug

Offline

 

#11 2010-04-27 22:11:18

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

Here is a calculator that I made in C++

Code:

#include <iostream>
#include <conio>
using namespace std;

void main ()
{
    int num1, num2;
    char oper;
    float result;
    cout << "Type in a number: ";
    cin >> num1;
    cout << "\nType in an operator (+, -, /, *, %): ";
    cin >> oper;
    cout << "\nType in another number: ";
    cin >> num2;
    
    if (oper == '+')
        result = num1 + num2;
    else if (oper == '-')
        result = num1 - num2;
    else if (oper == '/')
        result = num1 / num2;
    else if (oper == '*')
        result = num1 * num2;
    else if (oper == '%')
        result = num1 % num2;
    else
        result = 0;

    cout << "\n" << num1 << oper << num2 << "=" << result;
    cout << "\n\nPress any key to make another calculation.";
    getch();
    cout << "\n\n";
    main ();
}

Last edited by ThePCKid (2010-04-28 08:27:11)

Offline

 

#12 2010-05-01 22:43:58

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

Sorry for bumping.

Code:

#include <iostream>
#include <conio>
using namespace std;

int num;

void main ()
{
    cout << "Enter a number between 1 and 3: ";
    cin >> num;
    
    if (num == 1)
        cout << "Hi Bob!";
    else if (num == 2)
        cout << "Hi Sheldon!";
    else if (num == 3)
        cout << "Hi Christoper!";
    else
        cout << num << " is not between 1 and 3.";

    cout << "\nPress any key to exit";
    getch();
    exit (0);
}

The power of bordem has struck again!

C# version

Last edited by ThePCKid (2010-05-01 22:46:25)

Offline

 

#13 2010-05-01 23:56:42

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: C++ talk

Finally home sweet home!!!!!!!!!!!! i mean C++ forum  big_smile


btw c++ begginers can also ask us  big_smile

Last edited by fanofcena (2010-05-01 23:58:21)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#14 2010-05-01 23:59:05

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

fanofcena wrote:

Finally home sweet home!!!!!!!!!!!! i mean C++ forum  big_smile


btw c++ begginers can also ask us  big_smile

Thats right!

Offline

 

#15 2010-05-02 00:04:33

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: C++ talk

PC kid are u intrested in development of a header like Scratch.h with all basic functions of scratch i did the spite making part , Flow of control and variables can be derived from C++ basic but the other fucntions like ghost effect, ask , sound etc  are u intrested in developing such thing??


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#16 2010-05-02 01:06:20

ThePCKid
Scratcher
Registered: 2009-09-16
Posts: 1000+

Re: C++ talk

fanofcena wrote:

PC kid are u intrested in development of a header like Scratch.h with all basic functions of scratch i did the spite making part , Flow of control and variables can be derived from C++ basic but the other fucntions like ghost effect, ask , sound etc  are u intrested in developing such thing??

Yes!

Offline

 

#17 2010-05-03 08:22:06

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: C++ talk

ThePCKid wrote:

fanofcena wrote:

PC kid are u intrested in development of a header like Scratch.h with all basic functions of scratch i did the spite making part , Flow of control and variables can be derived from C++ basic but the other fucntions like ghost effect, ask , sound etc  are u intrested in developing such thing??

Yes!

OOpz i didnt showed on scratch server since that message nicely sorry ma mistake ::

Well PC KID i want to know how much c++ u know be frank jst tell me i am happy to teach i might write an article on how to code on C++ teaching young brains basic of analysing the code they write on C++ . I hope we do it ASAP so far here is how to handle that

functions :: the basic functions that are not in C++ so leave set variable , and controls

Sprite :: A sprite can be considered as a structure
like

Code:

struct Picture// Our own image format lol
{ int x[900];
  int y[900]
  int color[900];
};
// now thats actually information of image for maximum 900 pixels We will increase it later
struct Position
{ int Xpos;
  int Ypos;
};

sturct Sprite{
picture Costumes[10]; // say 10 costumes for the sprite we can write infinite list as            //well but i am not sure u are aware with pointers or not
Position Pos;
int Pen;// this stores if a pen is down or not jst a 0 or Anything variable
int Show?;// same as pen but decides if to show the sprite
int Graphiceffects[10][1]; //The 10 graphic effects with amount they are used for this
 };

tats jst a basic example but we have to build over on this skeleton ok?? cuz when its done i can simply write a C++ compiler for scratch projects lol


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

Board footer