08-23-2007, 11:17 AM | #1 |
Forum User
Join Date: May 2004
Posts: 378
|
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."); } Download life simulator example program.zip Last edited by SpoOkyMagician; 08-23-2007 at 12:28 PM.. |
08-23-2007, 11:21 AM | #2 |
FFR Underseer
Join Date: Jul 2003
Location: Hinterlands, NC
Posts: 2,643
|
Re: feeling codey
Thats more like it! I like seeing users that are into code
What ya gonna use it for? |
08-23-2007, 11:25 AM | #3 |
FFR Player
Join Date: Jan 2007
Location: CNY
Age: 31
Posts: 2,339
|
Re: feeling codey
Code is a foreign language to me. Care to put that into terms that a code n00b what understand?
__________________
|
08-23-2007, 11:25 AM | #4 |
Forum User
Join Date: May 2004
Posts: 378
|
Re: feeling codey
^_^ i made it as a example code for game maker along time ago. i made a simple game but it was really for people who were going to make a life simulator. perhaps u wanna see the game? not great thou. it was just made simply as an example. But ill upload the exe of it. =P
edit: lol... ok ill do that in a min. (explaining the code.) im gonna upload the exe first. Be warned, the game is really bad. but like i said its just an example. the code is the main part of it. edit: oh yea... this is the one without graphics... the other one had graphics but wasnt as good as this one. lol but anyway, its still playable if u like to read. =P Last edited by SpoOkyMagician; 08-23-2007 at 12:31 PM.. |
08-23-2007, 11:27 AM | #5 |
FFR Underseer
Join Date: Jul 2003
Location: Hinterlands, NC
Posts: 2,643
|
Re: feeling codey
No worries man .. no need to go out of the way, just curious
|
08-23-2007, 11:30 AM | #6 |
Forum User
Join Date: May 2004
Posts: 378
|
Re: feeling codey
i dont care. lol i got nothing better to do today. =P
edit: here ya all go. enjoy this really bad example. lol Download life simulator example program.zip now ill sum up what the code says... the global.start pretty much sets up variables for the game. bills/time/stats/etc... That is only done once since its set to 1 at the end. (cuz this code is ran continulessly.) Next is of course the timing. s=sec, m=min, d=day, etc... it checks to see if time is running correctly. like a normal watch/clock. its kinda seld explainitory from here if u read the comments. (// something here.) But pretty much it drains the players stats every 10 minutes. Well, read the rest from here. you can understand it if u read the comment lines. Last edited by SpoOkyMagician; 08-23-2007 at 12:32 PM.. |
08-23-2007, 11:34 AM | #7 |
FFR Player
Join Date: Apr 2007
Location: New York
Posts: 27
|
Re: feeling codey
I never knew how much Gamemaker code looks like Java :P
I mean...it looks like it basically IS Java.
__________________
http://spzc.net/ |
08-23-2007, 11:40 AM | #8 |
Forum User
Join Date: May 2004
Posts: 378
|
Re: feeling codey
actually... all coding is extremely similar. =\ They just have small diffrences. =\ like vb is like
VISUAL BASIC dim something as integer = 5 C++ int something = 5; once you know one language, you pretty much know them all. =s btw i am taking java next quarter at itt tech. ^_^ cant wait to take this class. =) but as for game maker, all i know it was programmed in delphi. (which i never used) which reminds me... I wonder how GM is doing... Ever since they used Yo-Yo Games, i just kinda left from it. I dont like yyg... They messed the GMS up... >.< edit: oh lol... just realised that this topic was moved. forgot there was a programming section. =P well anyway, lets see how this would look if i put it in C++. =P EDITING IN PROGRESS... Code:
#include <iostream> using std::cout; using std::cin; #include <string> using std::string; int main() { float hunger_thirst = 50; float bladder = 50; float hygene = 50; float energy = 50; float fun = 50; float social = 50; string emotion = "normal"; int age = 18; string task = "Nothing"; int s = 0; int m = 0; int h = 0; int d = 1; int mth = 1; int yr = 2000; int results = global.social + global.fun + global.energy; int avg = global.results / 3; int cash = 1000; int pay = 100; // just making a random value for now. if(s <= 99) // seconds { s += 1; } else { s = 0; m += 1; if(m == 60) // minutes { m = 0; h += 1; } if(h == 25) // hours { h = 0; d += 1; } if(d == 32) // days { d = 1; mth += 1; } if(mth == 13) // months-years-age { mth = 1; yr += 1; age += 1; } } if(s == 0) // 0 minutes { if(m == 0) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } if(s == 0) // 10 minutes { if (m == 10) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } if(s == 0) // 20 minutes { if(m == 20) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } if(s == 0) // 30 minutes { if(m == 30) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } if(s == 0) // 40 minutes { if(m == 40) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } if(s == 0) // 50 minutes { if(m == 50) { hunger_thirst -= 1; bladder -= 1; hygene -= 1; energy -= 1; fun -= 1; social -= 1; } } results = social + fun + energy; avg = results / 3; if(avg <= 15) { emotion = "Depressed"; } if(avg <= 30) { emotion = "Sad"; } if(avg <= 50) { emotion = "Normal"; } if(avg <= 75) { emotion = "Happy"; } if(avg > 75) { emotion = "Very Happy"; } if(task == "Eating/Drinking") { if(hunger_thirst < 100) { hunger_thirst += 0.01; bladder -= 0.005; energy += 0.001 } if(hunger_thirst >= 100) { task = "Nothing"; } } if(task == "Restroom") { if(bladder < 100) { bladder += 0.05; hygene -= 0.01; } if(bladder >= 100) { task = "Nothing"; } } if(task == "Shower/Bath") { if(hygene < 100) { hygene += 0.03; } if(hygene >= 100) { task = "Nothing"; } } if(task == "Sleeping") { if(energy < 100) { energy += 0.003; } if(energy >= 100) { task = "Nothing"; } } if(task == "Entertaining Self") { if(fun < 100) { energy -= 0.001; hygene -= 0.001; hunger_thirst -= 0.001; fun += 0.02; } if(fun >= 100) { task = "Nothing"; } } if(task == "Socializing") { if(social < 100) { social += 0.02; } if(social >= 100) { task = "Nothing"; } } if(hunger_thirst <= 0) { show_message("You have died of hunger/thirst..."); // hmm... Ill come back to all of this. game_restart(); } if(bladder <= 0) { if(task != "Shower/Bath") { show_message("Eww... You wet yourself... And something smells funny..."); bladder = 100; hygene -= 50; task = "Shower/Bath"; } } if(hygene <= 0) { if(task != "Shower/Bath") { show_message("Something stinks... Oh... Its you... You take a shower/bath."); task = "Shower/Bath"; hygene += 5; } } if(energy <= 0) { if(task != "Sleep") { show_message("You fall on the floor because lack of sleep..."); task = "Sleep"; energy += 5; } } if(fun <= 0) { if(task != "Entertain Self") { show_message("You are so bored that you stop what you are doing and entertain yourself."); task = "Entertain Self"; fun += 5; } } if(social <= 0) { if(task != "Socializing") { show_message("You have been away from friends so long. You decide to suddenly go see them."); task = "Socializing"; social += 5; } } if(s = 5) { if(m = 0) { if(h = 12) { task = "Working"; show_message("Time to go to work! Depending on your emotion is depending on your pay for the day!") if(emotion == "Very Happy") { pay = 100; } if(emotion == "Happy") { pay = 85; } if(emotion == "Normal") { pay = 75; } if(emotion == "Sad") { pay = 60; } if(emotion == "Depressed") { pay = 50; } } } } if(s = 5) { if(m = 0) { if(h = 18) { task = "Nothing"; cash += pay pay = 0; show_message("You get home from a hard days work.") } } } if(h == 0) // first month { if(m == 0) { if(s == 5) { if(mth == 1) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // second month { if(m == 0) { if(s == 5) { if(mth == 2) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // third month { if(m == 0) { if(s == 5) { if(mth == 3) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // forth month { if(m == 0) { if(s == 5) { if(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."); cash -= 500; } } } } } if(h == 0) // fifth month { if(m == 0) { if(s == 5) { if(mth == 5) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // sixth month { if(m == 0) { if(s == 5) { if(mth == 6) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // seventh month { if(m == 0) { if(s == 5) { if(mth == 7) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // eighth month { if(m == 0) { if(s == 5) { if(mth == 8) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // ninth month { if(m == 0) { if(s == 5) { if(mth == 9) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h = 0) // tenth month { if(m = 0) { if(s = 5) { if(mth = 10) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // eleventh month { if(m == 0) { if(s == 5) { if(mth == 11) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(h == 0) // twelth month { if(m == 0) { if(s == 5) { if(mth == 12) { show_message("The monthly bill is here... $500 is taken away from you."); if(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."); cash -= 500; } } } } } if(age >= 100) { show_message("Wow! You lived a full life! Unfortunally, you die at age 100. Thanks for playing."); } return 0; } Last edited by SpoOkyMagician; 08-23-2007 at 01:16 PM.. |
08-23-2007, 02:42 PM | #9 |
Seen your member
Join Date: Dec 2003
Location: noitacoL
Posts: 2,873
|
Re: feeling codey
Looks like the foundation of what "The Sims" is built on.
This style of time elapsing stats coding will likely be what future development of the profile pets program uses. |
08-23-2007, 02:45 PM | #10 |
<<Insert Title Here>>
Join Date: Sep 2004
Location: Regina, SK, Canada
Age: 34
Posts: 1,436
|
Re: feeling codey
People must have too much time on their hands to make all of those codes. I can't stand coding. <_<
|
08-23-2007, 09:18 PM | #11 |
Forum User
Join Date: May 2004
Posts: 378
|
Re: feeling codey
^^ Yea, in the example program itself, i mentioned that this is based apon the sims. I gave credit to them in the game information. But yea, its pretty much what the sims looks like in code. =P and yea probably.
^LOL... yea i know. Programmers have way too much time on their hands. But eh, its worth the money. lol =P edit: btw, ill try finishing the C++ convert thing later. Busy atm. =\ Last edited by SpoOkyMagician; 08-23-2007 at 09:21 PM.. |
08-23-2007, 09:25 PM | #12 |
FFR Player
|
Re: feeling codey
I remember the game maker coding days. It was unecessarily tedious and the algorithims they required were ridiculous imo. I'd much rather just code the game in something a bit more practical and universal, like C++, and integrate a pre-made graphics engine into if it need.
Still, you did a good job with what you had to work with. It looks good. Also, while most coding languages are similar and you can trace their roots back to a common ancestor, knowing one does not mean you more or less know them all. I'm pretty sure if you had learned C# and tried to code in basic or pascal(god knows why you would) you'd be pretty lost, as you are trying to code uncompiled text into a foreign machine language based system. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|