Learning How to Code (Part 2)
7 years ago
Part 1 here
Just wanted to take a moment and thank everybody for your support and kind words! I really didn’t expect anybody to read my babbles. I mostly just throw stuff into the void that is the internet and never think to hear from it again. Sort of like yelling into a cave and hearing your voice echo~ is that another view? nope, just me again.
Without further ado, here’s part two! (holy sheet, does that rhythm?)
So I last left off with an animal program that handled two genders, 55 colors, and like 4 or 5 genes. Now that’s all well and good, but the problem is how I’m TALKING to the program. If you aren’t familiar with coding, you sort of build your code in a like… a word-ish document (specifically I used notepad++). Then run it, which then pops open another window. In this case, this ‘other window’ prompts the user to type in the parameters. It says: “What gender?” You type in male or female. Then it asks for the colors, genes, and whatever else it needs to generate the animal image. After you hit enter a few times, BAM- animal image created. However, that gets annoying after a few times. (Trust me, I’ve been working on it for two weeks.) So what I need is a GUI (Graphical User Interface). It’s basically a thingy that allows the user to interact with your program without doing all the stuff I described above.
So what are my options? Apparently python has a lot of gui packages you can code with. I ended up picking Tkinter because it seemed easy enough to use.
IMAGE LINK
TA-DAAAA~ Isn’t it glorious!? I’ve got check boxes for the genders (which at this point don’t work btw, but at least they’re there), entry boxes for all the goodies and a quit button that’ll actually close the window (took like a hour to get it to work for whatever stupid reason), plus the important generate button which will create the animal image. I have to mention that I spent another day re-writing my code. At this point I’ve re-written my code at least four times. Each time I have to sort of get it to be more flexible which means re-working how it operates. Though that’s what happens when you’re learning on the fly. I find it easier just to fix the whole thing than to patch stuff up and hope for the best. Anyway~ so I got everything hooked up to the right parameters with the right entry boxes.
IMAGE LINK
I was worried that the data would start getting crossed and instead of making the primary color white like it says in the entry box, it would make the secondary color white, or whatever. You gotta stay organized! But it works and I managed to fix the check boxes so the right gender would get colorized.
Next step, lets see if we can put the animal image into the gui. It’s a pain in the butt to have to go into your folders and open the image manually.
IMAGE LINK
BOOM, with some bits of extra code, I was able to get the image to display in the gui. Though you know what it doesn’t do? Automatically display the image after you hit the generate button. So what happens is it’ll save a new image, but you have to close and open the program for the new image to load… took me like, three hours to figure out how to get it to update.
IMAGE LINK
Fixed it! So now if you hit “Generate” it will update the displayed image to current parameters typed in. However, that’s what I’m trying to avoid! I’m tired of typing in “cupid”, “basic”, or whatever. Seriously, and if I miss type something I have to shut the whole thing down. So lets figure out how to add dropboxes.
IMAGE LINK
Oooo, look how it drops. Get low, gurl. Get low.
IMAGE LINK
So it took me like half a day to figure out a way to add that scroll bar in the dropbox you see there. At first, you clicked on the little arrow and it would open ALL the options you could pick. I’ve got 55 colors. That dropbox took up the whole screen. So scrolling was vital.
IMAGE LINK
It was at this point that I thought adding a save button would be useful. The generate button would create a new animal image, which would save a new file to a folder, but each time you hit ‘generate’ it would override the existing file. So if you click “save” a new animal image would be created and the name of the file has the name of the parameters which make up the animal. This is important for the next step of my master plan: baby makin’.
Now, how am I going to get the program to accept a set of parameters, create a range of options with those parameters, and then randomly select a new parameter list all so it can generate a child image based off of the parents? I basically made a new program just for selecting the options for children.
IMAGE LINK
So the parents (up top) have created two children (below). The dad is white with tiger and the mom is silver with cloud. The program gave them two girls that take after mom’s primary markings, but with dad’s wing color. Woo! so I got the program to pick gene and color options that make sense based on the parents. Lets see if it’ll work again.
IMAGE LINK
Yep, still working and I got it to randomly pick the gender! You can also set the litter size. Right now it’s set to 2-4 cubs. But you know what’s missing? Actual cub images.
IMAGE LINK
There! Now we got some cute babies to go with the adults.
The latest gui actually has a “Generate Children” button.
IMAGE LINK
Which will open up this box.
IMAGE LINK
This is where you just copy and paste the parents’ file names into the entry box, click “Create Children” and the program will start popping out babies along with their adult images. So when it’s time for them to get a job, you don’t have to re-create the images for their adult form.
I’ve finally done it! So where do I go from here? It’s time to take this show on the road. Next stop: the interwebs. I need to figure out how to re-create this program online. See if I can get this sucker on the web for other people to interact with. Nobody wants to install another program. They’d rather have everything in front of them all ready to go. However, I have no idea how to do this. If anybody with web experience could point me in the right direction, I would be forever grateful. I looked up MySQL and php stuff, but I’m not sure if that’s the right answer. Maybe it is? I don’t know. My ultimate goal? Create a website where people can upload their OWN pet templates and start their own pet generating community. I feel like I figured out the hard part, making a program that can do it. Now I just gotta figure out how to easily share it.
Anyways, thanks for reading and joining me on this frustrating fun ride! If you have any ideas or suggestions, please let me know! I plan on adding more genes and species. Hopefully you’ll see this soon online.
Peace~
Just wanted to take a moment and thank everybody for your support and kind words! I really didn’t expect anybody to read my babbles. I mostly just throw stuff into the void that is the internet and never think to hear from it again. Sort of like yelling into a cave and hearing your voice echo~ is that another view? nope, just me again.
Without further ado, here’s part two! (holy sheet, does that rhythm?)
So I last left off with an animal program that handled two genders, 55 colors, and like 4 or 5 genes. Now that’s all well and good, but the problem is how I’m TALKING to the program. If you aren’t familiar with coding, you sort of build your code in a like… a word-ish document (specifically I used notepad++). Then run it, which then pops open another window. In this case, this ‘other window’ prompts the user to type in the parameters. It says: “What gender?” You type in male or female. Then it asks for the colors, genes, and whatever else it needs to generate the animal image. After you hit enter a few times, BAM- animal image created. However, that gets annoying after a few times. (Trust me, I’ve been working on it for two weeks.) So what I need is a GUI (Graphical User Interface). It’s basically a thingy that allows the user to interact with your program without doing all the stuff I described above.
So what are my options? Apparently python has a lot of gui packages you can code with. I ended up picking Tkinter because it seemed easy enough to use.
IMAGE LINK
TA-DAAAA~ Isn’t it glorious!? I’ve got check boxes for the genders (which at this point don’t work btw, but at least they’re there), entry boxes for all the goodies and a quit button that’ll actually close the window (took like a hour to get it to work for whatever stupid reason), plus the important generate button which will create the animal image. I have to mention that I spent another day re-writing my code. At this point I’ve re-written my code at least four times. Each time I have to sort of get it to be more flexible which means re-working how it operates. Though that’s what happens when you’re learning on the fly. I find it easier just to fix the whole thing than to patch stuff up and hope for the best. Anyway~ so I got everything hooked up to the right parameters with the right entry boxes.
IMAGE LINK
I was worried that the data would start getting crossed and instead of making the primary color white like it says in the entry box, it would make the secondary color white, or whatever. You gotta stay organized! But it works and I managed to fix the check boxes so the right gender would get colorized.
Next step, lets see if we can put the animal image into the gui. It’s a pain in the butt to have to go into your folders and open the image manually.
IMAGE LINK
BOOM, with some bits of extra code, I was able to get the image to display in the gui. Though you know what it doesn’t do? Automatically display the image after you hit the generate button. So what happens is it’ll save a new image, but you have to close and open the program for the new image to load… took me like, three hours to figure out how to get it to update.
IMAGE LINK
Fixed it! So now if you hit “Generate” it will update the displayed image to current parameters typed in. However, that’s what I’m trying to avoid! I’m tired of typing in “cupid”, “basic”, or whatever. Seriously, and if I miss type something I have to shut the whole thing down. So lets figure out how to add dropboxes.
IMAGE LINK
Oooo, look how it drops. Get low, gurl. Get low.
IMAGE LINK
So it took me like half a day to figure out a way to add that scroll bar in the dropbox you see there. At first, you clicked on the little arrow and it would open ALL the options you could pick. I’ve got 55 colors. That dropbox took up the whole screen. So scrolling was vital.
IMAGE LINK
It was at this point that I thought adding a save button would be useful. The generate button would create a new animal image, which would save a new file to a folder, but each time you hit ‘generate’ it would override the existing file. So if you click “save” a new animal image would be created and the name of the file has the name of the parameters which make up the animal. This is important for the next step of my master plan: baby makin’.
Now, how am I going to get the program to accept a set of parameters, create a range of options with those parameters, and then randomly select a new parameter list all so it can generate a child image based off of the parents? I basically made a new program just for selecting the options for children.
IMAGE LINK
So the parents (up top) have created two children (below). The dad is white with tiger and the mom is silver with cloud. The program gave them two girls that take after mom’s primary markings, but with dad’s wing color. Woo! so I got the program to pick gene and color options that make sense based on the parents. Lets see if it’ll work again.
IMAGE LINK
Yep, still working and I got it to randomly pick the gender! You can also set the litter size. Right now it’s set to 2-4 cubs. But you know what’s missing? Actual cub images.
IMAGE LINK
There! Now we got some cute babies to go with the adults.
The latest gui actually has a “Generate Children” button.
IMAGE LINK
Which will open up this box.
IMAGE LINK
This is where you just copy and paste the parents’ file names into the entry box, click “Create Children” and the program will start popping out babies along with their adult images. So when it’s time for them to get a job, you don’t have to re-create the images for their adult form.
I’ve finally done it! So where do I go from here? It’s time to take this show on the road. Next stop: the interwebs. I need to figure out how to re-create this program online. See if I can get this sucker on the web for other people to interact with. Nobody wants to install another program. They’d rather have everything in front of them all ready to go. However, I have no idea how to do this. If anybody with web experience could point me in the right direction, I would be forever grateful. I looked up MySQL and php stuff, but I’m not sure if that’s the right answer. Maybe it is? I don’t know. My ultimate goal? Create a website where people can upload their OWN pet templates and start their own pet generating community. I feel like I figured out the hard part, making a program that can do it. Now I just gotta figure out how to easily share it.
Anyways, thanks for reading and joining me on this frustrating fun ride! If you have any ideas or suggestions, please let me know! I plan on adding more genes and species. Hopefully you’ll see this soon online.
Peace~