Jump to content

someboddy

Ultra Members
  • Posts

    1,661
  • Joined

  • Last visited

Everything posted by someboddy

  1. Anyways, lets go on. One of the most important tools in every programing language is the if sentence. The if allows you to change the course of program. How do you do it? like this: if(/*expression*/) /*command*/ or if(/*expression*/) /*command*/ else /*alternative command*/ The expression is the condition for the command to be executed. If the expression is true, then the command will be performed. Otherwize, the alternative command will be performed, or nothing, in the case of the first form. So how do you make expression's? Very simple. a>b: a is larger then b. a<b: a is smaller then b. a==b: a is equal to b (remember: two equal signs). a!=b: a is not equal to b. a>=b: a is larger or equal then b. a<=b: a is smaller or equal then b. so: if(a>b) cout<<"a"; else cout<<"b"; Prints "a" if a is bigger, or "b" is be is bigger or equal to a You can put more then one command like this: if(a>b) { a=a+1; b=b+1; } So lets combine what we learned: #include<iostream.h> void main() { int age; cout<<"Whats you age?"; cin>>age; if(age<18) cout<<"you are not old enough to drink"; else cout<<"you are old enough to drink, but I cheap so I wont buy you beer"; } That will be all for today. Class dismissed
  2. wait you've never made a graphics game? not even in SDL? I have done few with game makers. I am trying to learn C++, but I stopped after my hard disc got broken.
  3. That game rules. I just installed it to replay the human campaign since I can't play Doom III without my new processor (should be here today or till Wednesday). AvP freaks me out. The motion detector especially. You'r probebly talking about the first stage of the human campaign. Pure horor stage.
  4. Waking up is the first thing I don't want to do.
  5. You are right. Topic moved.
  6. If you tried to sell the "Hello world" program, you probebly didn't earn alot. Every proram that worth something uses variables. Variables are places for you to put values : numbers, text, world domination plans ect. The simplest kind of variable is the integer. You define (make) an integer like this: int a; Now a is an integer. You can define more then one interger in the same command like this: int a,b; You can define how many variables you want anywhere in the program. There are few rules: 1. A variables name can contain only english letters, nubmers, and _s (I don't know how this line called in english). 2. A variables name can not begin with a number. 3. A variable can not have a name already taken by other variable, or preserved words (like void, int). This is not allowed: int a,a; int int; However, C++ is cse sensetive, so this is allowed: int a,A; int iNt; 4. A variable can not be used before it is defined. Now there are some commands for variables. If you want to put a value in a variable, you do it like this: a=7; now the value of a is 7. You can print it to the screen like this: cout<<a; Note that the a is not inside inverted commas. a is not a text. Of course you can print other stuff with your a: cout<<"a="<<a<<",got it?"; you can use +,-,* and / with variables and numbers like this: int a,b,c; a=a+1; b=c-a; c=1/a; a=b*c; You can get input into a variable like this: cin>>a; cin>>b>>c; For output use <<. For input use >>. If you are having hard time to remember, use this trick: Output: you give the text to the screen, so the arrows are in the direction of the screen (cout is the screen). Input: You take the text from the keyboard, so the arrows are in the direction of the variable (cin is the screen). Now lets combine everything we learned: #include<iostream.h> void main() { int a,b,c; cout<<"give me two numbers"; cin>>a>>b; c=a+b; cout<<a<<"+"<<b<<"="<<c; } That will be all for today. Class dismissed
  7. I somethimes play Alien vs Predator 2 online.
  8. Microsoft's advertisements where too strong for them...
  9. Are you talking to me or Disoblige? If you are talking to me, why doesn't that question make sense? The question doesn't make sense, because it's a tricky question.
  10. 1/8 You can't just change the question because it doesn't make sense.
  11. In C++, you can add comments in two ways: code // single line comment code code /*multiline comment */ code Every C++ look like this: //Headers //Declerations void main() { //The programs code } Headers: collections of functions (commands) Declerations: your own functions, global variables and classes. I will get in to this later, since this is more advanced stuff. The programs code: The commands you want the program to execute when it starts. So what this program does? well, nothing actualy. We need to put some commands so this program will work. Type this in your compiler: #include<iostream.h> void main() { cout<<"Hello world"; } Now press Ctrl+F9. If the program report that it's "Unable to open include file 'iostream.h', press options/directories and change the "include directories" to the right path. you can allso change the "library directories" if you want. The screen go black and... nothing appens. Actualy, something did appened, but it was so fast you couldn't see it. Just press Alt+F5 to see the screen. Now I will explain: #inlucde<iostream.h> This command tells the program that you need the library "iostream.h". This library contain's the basic input and output commands. cout<<"Hello world"; this command shows the text "Hello world" on the screen. Text in C++ must be inside inverted commas. The ; in the end is the end of the command. You can put more than one pice of text in one command like this: cout<<"Hello"<<"world"; This will display "Helloworld", since there is no space. You must have noticed that some of the code is not starting in the begining of the line. This is not necessary for the program to work, but it makes the program easier to read, so I recommand it. That will be all for today. Class dismissed
  12. I know, I know, I have done it before... two times... but that was before I knew how to make games... o.k. o.k. ascii games. This time I have a goal. After you will finish this class, you will be able to create ascii games, like the ascii snake you can download from the attachment (better play it in fullscreen). You can download Turbo C++ from here. Don't use Visual C++ or anyother windows based C++ compiler, because it won't support the console functions and objects. Feel free to ask questions. SNAKE.zip
  13. Then the moon
  14. that it will
  15. That small yellow
  16. http://www.newgrounds.com/portal/view/184865 Pretty lame, but who cares?
  17. And eat that
  18. Where are you?
  19. Unless you want faster download speed.
  20. My Controls -> edit signature (on the side menu)
  21. FTP=File Transfer Protocoll I don't use a program. I just using the FTP server like a regular folder.
  22. on pink bannanas
  23. I didn't think it was that bad. Wasn't very good either. But not something I'd destroy. Not that bad? That game is like RPG, only the walking around is done for you, and the fighting is done for you. It's like Pokemon Stadium without the fights.
  24. Worst game ever. Make Superman64 look like Halo.
  25. Stupid people can take serious every game. Some day, someone will walk in the street and eat coins while escaping people dressed like ghosts (It will happen on Hallewin)
×
×
  • Create New...