News

   Join the Discussion, click to join the HGN Steam Chat Group.
Click here.
collapse

My mistakes in and my fixes for them.(C++)

CortezV · 1832

0 Members and 1 Guest are viewing this topic.

Offline CortezV

  • Sumarai
  • ***
    • Posts: 165
IF YOUR GOING TO LEARN CODE. THEN LEARN PSEUDO CODE FIRST, ITS NOT A PROGRAMING LANGUAGE BUT AN FORMAT THAT MAKES IT SIMPLER!

Code
Alright, so look that this.

old mistake I've made.

PS. If your in to coding, leave yourself notes.

[code]
#include <iostream>
#include <time.h>
#include <cstdlib>
using namespace std;

int main()


}
// Yet to decide on colors of hair, so I'll just mark them as valid intergers for now.
  char Eyes1 = 100);
  char Eyes2 = 120);
  char Eyes3 = 140);
  char Eyes4 = 180);
  char Eyes5 = 220);
  char Eyes6 = 240);
  char Eyes7 = 280);
  char Eyes8 = 320);
  char Eyes9 = 340);
  char Eyes10 = 380);
  char Eyes11 = 420);
  unsigned short int valid = 65);
  {
cout << "Please select your hair color << endl") <<
  if
char Eye12
cout << "That is an invalid or illegal arguement, please select a valid eye color "<< endl;
 then
return 1;
else
cout >> ( "That is a valid hair color ") << endl << endl;
// Check later to see if this is right.
cin >> (Eyes1 + Eyes2 + Eyes3 + Eyes4 + Eyes5 + Eyes6 + Eyes7 + Eyes8 + Eyes9 + Eyes10 + Eyes11 = valid)

system("PAUSE")
}

// Again come back to this later.

char hair1 = 110);
char hair2 = 120);
char hair3 = 130);
char hair4 = 140);
char hair5 = 150);
char hair6 = 160);
char hair7 = 170);
char hair8 = 180);
char hair9 = 190);
char hair10 = 200);
unsigned short int valid = 65);

{
        
         cout << (" Please select your hair color ") //no hair color to select yet.
         if
         hair11+
         then
         cout << (" That is a invalid hair color, please select a valid one ")
         return 1;
         else
         cin >> ( hair1, hair2, hair3, hair4, hair5, hair6, hair7, hair8, hair9, hair10)
         // Go back to the out Cin and fix the + to ,
         {


1. Where are my breaks?
2. I should have statements.
3. Its messy, I should of added what colors I needed before the integers where added.
4. Its shit. why would I use eye colors and hair styles in a source mod?

next.

I worked on creating a match to fight in, theres nothing wrong in this code, If I ran it, it should complile fine, but I can't do that until I create all my library's.

Code
#include <iostream>
#include <time.h>
#include <cstdlib>
using namespace std;
 
void collision();
void endmatch();
void playerWin();
void opponentWin();
void drawWin();
int damage(int health, int taken);
 
int playerHealth = 100;
int opponentHealth = 100;
 
int main()
{

}

void collision()
{
 
}

void endmatch(int playerHealth, int oppnentHealth)
{
     if(playerHealth> opponentHealth)
     playerWin();
     else if(opponentWin();
     opponentWin()
     else
     drawWin();
     }
    
     int damage(int health, int taken)
     {
         health=health-taken;
         return health;
         }
        
 

See how much cleaner that is?  
Now see, You would have a selection of characters to choice from.
so, let the coder handle how the matches and weaponry will be, and let the modeler handle how your characters will look, and let your mapping handle the environment.
    
This is my most recent bit of code, (This wont work unless you have all the library's loaded.)
so don't even try to compile it.

Code
#include <iostream> // load all files.
void collision // noclip on players.
void playerhealth // void the playerhealth as in ignore it.
void playerrun // do not allow player to run.
void playerdmg // ignore any damage.
void suicide // ignore suicide.
void playerwepon // ignore weaponry.


int playerhealth = 100; // player health starts at 100.
int playerspeed = 5.8; // Speed, walking speed.
int playerdmg = 0; // take Zero damage.
int main() // starts the code.


{
  // write a singleplayer script.
  
  playerdmg = 0; // no damage.
  if dmg(void) // void player damage.
  if else (suicide) // suicide disablement.
  cout << ("You have no weapon, you cannot kill yourself!") // console out, this should come up when you type suicide in console.
  endl; // character term.
  break; // breaks the code so it doesn't run everything over.
  }
  {
  playerwepon(void) // Can't use weaponry so if weapon then void.
  if playerwepon = cout( "You can't use that yet.") // Obviously if it voids int playerwepon then that means he can't use a weapon.
  else playerwepon = (void) // this completes it stating that he will just walk over the weapon.
  break; // breaks the code off so it doesn't run everything over.
  }
 return 0; // returns the code to the beginning.
 

Everything is explained out to the side.[/code]
« Last Edit: 08-11-2009 by CortezV »
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions



Thom's Law
"Nothing can not produce something. If there was ever a time when there was nothing, there would STILL be nothing."


Offline Midnight

  • Compsognathus
  • **
    • Posts: 75
Cortez!? I thought you left, never to be seen again. Well welcome back, that is if you are staying.
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions



Offline CortezV

  • Sumarai
  • ***
    • Posts: 165
Cortez!? I thought you left, never to be seen again. Well welcome back, that is if you are staying.

I'm not back. Just felt like sharing.
friendly
0
funny
0
informative
0
agree
0
disagree
0
pwnt
0
like
0
dislike
0
late
0
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions
No reactions



Thom's Law
"Nothing can not produce something. If there was ever a time when there was nothing, there would STILL be nothing."


Tags:
     

    * Hello there Guest

    Welcome to the HyperGaming Network forums! We are a large gaming and mod community. Please signup to gain access to other sections of the forum.




    If you are having problems navigating the forums, please see this topic.

    Forum News

       Join the Discussion, click to join the HGN Steam Chat Group.
    Click here.

    * Users Online


    Dot Guests: 274 | Dot Users
    SimplePortal 2.3.7 © 2008-2022, SimplePortal