Thread: feeling codey
View Single Post
Old 08-23-2007, 11:17 AM   #1
SpoOkyMagician
Forum User
FFR Veteran
 
Join Date: May 2004
Posts: 378
Default feeling codey

I was bored and i was thinking about coding. I did this really nice code along time ago. Took me about a day to complete. =\ Tell me what ya think. btw, this was done in game maker language. i might decode this in C++ sometime just for fun. lol anyway, take a look.

Code:
if (global.start = 0) // start values only once.
{
global.hunger_thirst = 50;
global.bladder = 50;
global.hygene = 50;
global.energy = 50;
global.fun = 50;
global.social = 50;
global.emotion = "normal";
global.age = 18;
global.task = "Nothing";
global.s = 0;
global.m = 0;
global.h = 0;
global.d = 1;
global.mth = 1;
global.yr = 2000;
global.results = global.social + global.fun + global.energy;
global.avg = global.results / 3;
global.cash = 1000;
global.pay = 100; // just making a random value for now.
global.start = 1;
}

// looping time code

if (global.s <= 99) // seconds
    {
    global.s += 1;
    }
else
    {
    global.s = 0;
    global.m += 1;

        if (global.m = 60) // minutes
        {
        global.m = 0;
        global.h += 1;
        }
        
        if (global.h = 25) // hours
        {
        global.h = 0;
        global.d += 1;
        }
        
        if (global.d = 32) // days
        {
        global.d = 1;
        global.mth += 1;
        }
        
        if (global.mth = 13) // months-years-age
        {
        global.mth = 1;
        global.yr += 1;
        global.age += 1;
        }
        
    }
    
    
// drain stats every 10 minutes

if (global.s = 0) // 0 minutes
{
if (global.m = 0)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

if (global.s = 0) // 10 minutes
{
if (global.m = 10)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

if (global.s = 0) // 20 minutes
{
if (global.m = 20)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

if (global.s = 0) // 30 minutes
{
if (global.m = 30)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

if (global.s = 0) // 40 minutes
{
if (global.m = 40)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

if (global.s = 0) // 50 minutes
{
if (global.m = 50)
{
global.hunger_thirst -= 1;
global.bladder -= 1;
global.hygene -= 1;
global.energy -= 1;
global.fun -= 1;
global.social -= 1;
}
}

// emotion change

global.results = global.social + global.fun + global.energy;
global.avg = global.results / 3;

if (global.avg <= 15)
{
global.emotion = "Depressed";
}

if (global.avg <= 30)
{
global.emotion = "Sad";
}

if (global.avg <= 50)
{
global.emotion = "Normal";
}

if (global.avg <= 75)
{
global.emotion = "Happy";
}

if (global.avg > 75)
{
global.emotion = "Very Happy";
}

// need food/water

if (global.task = "Eating/Drinking")
{
if (global.hunger_thirst < 100)
{
global.hunger_thirst += 0.01;
global.bladder -= 0.005;
global.energy += 0.001
exit
}
if (global.hunger_thirst >= 100)
{
global.task = "Nothing";
}
}

// need restroom

if (global.task = "Restroom")
{
if (global.bladder < 100)
{
global.bladder += 0.05;
global.hygene -= 0.01;
exit
}
if (global.bladder >= 100)
{
global.task = "Nothing";
}
}

// need shower/bath

if (global.task = "Shower/Bath")
{
if (global.hygene < 100)
{
global.hygene += 0.03;
exit
}
if (global.hygene >= 100)
{
global.task = "Nothing";
}
}

// need sleep

if (global.task = "Sleeping")
{
if (global.energy < 100)
{
global.energy += 0.003;
exit
}
if (global.energy >= 100)
{
global.task = "Nothing";
}
}

// need entertainment

if (global.task = "Entertaining Self")
{
if (global.fun < 100)
{
global.energy -= 0.001;
global.hygene -= 0.001;
global.hunger_thirst -= 0.001;
global.fun += 0.02;
exit
}
if (global.fun >= 100)
{
global.task = "Nothing";
}
}

// need chit chat

if (global.task = "Socializing")
{
if (global.social < 100)
{
global.social += 0.02;
exit
}
if (global.social >= 100)
{
global.task = "Nothing";
}
}

// bad stats...

if (global.hunger_thirst <= 0)
{
show_message("You have died of hunger/thirst...");
game_restart();
}

if (global.bladder <= 0)
{
if (global.task != "Shower/Bath")
{
show_message("Eww... You wet yourself... And something smells funny...");
global.bladder = 100;
global.hygene -= 50;
global.task = "Shower/Bath";
}
}

if (global.hygene <= 0)
{
if (global.task != "Shower/Bath")
{
show_message("Something stinks... Oh... Its you... You take a shower/bath.");
global.task = "Shower/Bath";
global.hygene += 5;
}
}

if (global.energy <= 0)
{
if (global.task != "Sleep")
{
show_message("You fall on the floor because lack of sleep...");
global.task = "Sleep";
global.energy += 5;
}
}

if (global.fun <= 0)
{
if (global.task != "Entertain Self")
{
show_message("You are so bored that you stop what you are doing and entertain yourself.");
global.task = "Entertain Self";
global.fun += 5;
}
}

if (global.social <= 0)
{
if (global.task != "Socializing")
{
show_message("You have been away from friends so long. You decide to suddenly go see them.");
global.task = "Socializing";
global.social += 5;
}
}

// go to work

if (global.s = 5)
{
if (global.m = 0)
{
if (global.h = 12)
{
obj_4.visible = false;
obj_5.visible = false;
obj_6.visible = false;
obj_7.visible = false;
obj_8.visible = false;
obj_9.visible = false;
obj_10.visible = false;
global.task = "Working";
show_message("Time to go to work! Depending on your emotion is depending on your pay for the day!")

if (global.emotion = "Very Happy")
{
global.pay = 100;
}
if (global.emotion = "Happy")
{
global.pay = 85;
}
if (global.emotion = "Normal")
{
global.pay = 75;
}
if (global.emotion = "Sad")
{
global.pay = 60;
}
if (global.emotion = "Depressed")
{
global.pay = 50;
}

}
}
}

// come home from work

if (global.s = 5)
{
if (global.m = 0)
{
if (global.h = 18)
{
obj_4.visible = true;
obj_5.visible = true;
obj_6.visible = true;
obj_7.visible = true;
obj_8.visible = true;
obj_9.visible = true;
obj_10.visible = true;
global.task = "Nothing";
global.cash += global.pay
global.pay = 0;
show_message("You get home from a hard days work.")

}
}
}

// the annoying BILLS every month

if (global.h = 0) // first month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 1)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // second month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 2)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // third month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 3)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // forth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 4)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // fifth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 5)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // sixth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 6)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // seventh month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 7)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // eighth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 8)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // ninth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 9)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // tenth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 10)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // eleventh month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 11)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

if (global.h = 0) // twelth month
{
if (global.m = 0)
{
if (global.s = 5)
{
if (global.mth = 12)
{
show_message("The monthly bill is here... $500 is taken away from you.");
if (global.cash < 500)
{
show_message("Oh dear... You do not have the money to pay off the bill... You lose your home...");
game_restart();
}
else
{
show_message("The bill was payed off.");
global.cash -= 500;
}

}
}
}
}

// check age for too old.

if (global.age >= 100)
{
show_message("Wow! You lived a full life! Unfortunally, you die at age 100. Thanks for playing.");
}
here is what this all this does. =P

Download life simulator example program.zip

Last edited by SpoOkyMagician; 08-23-2007 at 12:28 PM..
SpoOkyMagician is offline   Reply With Quote