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

Started by CortezV, 07-11-2009

0 Members and 1 Guest are viewing this topic.

CortezV

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

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.


#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.


#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]


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

Midnight

Cortez!? I thought you left, never to be seen again. Well welcome back, that is if you are staying.

CortezV

Quote from: Midnight on 07-11-2009
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.


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