Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ - RPG

Name: Anonymous 2010-10-29 15:44

Lets program a roleplaying game together. Each post must contain either a new function or an edited version of an old function in psudocode. I will start:

int dealDamage(int hp, int damage){
    return hp - damage;
}

Name: Anonymous 2010-10-29 15:48

>>1
Now rewrite that function to return 0 if its negative without using an if statement!

Name: Anonymous 2010-10-29 15:50

Easy.

int dealDamage(int hp, int damage){
    hp -= damage;
    while(hp > 0)
        return hp;
    return 0;
}

Name: Anonymous 2010-10-29 16:07

return ((hp-damage) + (abs(hp-damage)) / 2)

Name: Anonymous 2010-10-29 16:09

float randomize(float x, float m = 0.9){
    float n = random(m, 1/m);
    return x*n;
}

Name: Anonymous 2010-10-29 16:10


int dealDamage(int hp, int damage) {
    return (damage > hp) ? 0 : (hp - damage);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List