Show off some of your coding projects

Digital

New member
So this is for some of our programmers, such as @PaulSonny, or @Nate, or really any of our other programmers, I know we have a few others here as well. Show off a little of what you have done in the past, either in screenshots, code samples, or other neat things you have done, whether it is projects you have helped with, open source repo's you have participated in, etc!

 
mirror_spot_by_phelixas-d3kt3vj.jpg.c5b626d52b8500c0ef0d6dda0c1fb9b2.jpg


810ef22a529f76ba17c90f48ff6fd1d8.png.0747be571f1b0bc3d934417538e20a79.png
rabbit.php


I don't know much about programming, but have a lot of fun working on the layering system for a rabbit SIM in Imagemagick. It combines Mendelian genetics with hidden modifiers. So you have your genes and alleles, and then you have subtle changes in brightness, saturation, etc.

The English Spot breed has a distinctive pattern, but there's also endless variation in it. 

View attachment 484

This is just a snippet of code. I coded a whited out copy of the base layer that goes over any potential color layers. Then the markings are in layers with DSTOUT, causing the pattern to be cut out of the white layer. 

There are 5 integer columns in the database for each rabbit that determine color patterns. I use a modulus to cycle through them (if there's 3 possible nose markings, it goes through 0, 1, 2 then cycles).

I also use the modulus so I can reuse the same column data without making certain combinations impossible. If I want to use the same data for spine marking and side markings, I just have to make sure to use different prime numbers for the modulus'.

When I did the math, it was something like 20,000 possible marking combinations with the English Spot pattern, only using about 130 KB of image files. I'm really happy with that. It's not including all of the color possibilities for the non-white parts.

rabbit.php
rabbit.php


You can get totally different things with the genes and alleles, too. Like rainbow and inverse. The inverse is shown in the code above, it just uses DSTIN instead of DSTOUT on all the markings. The rainbows have a hue modifier too so it cycles through loads of different colors (there's about 5 rainbow 'patterns.'  

There's a lot of cool things I've also learned about rabbit colors in the process of using imagemagick. Now every time I see bunnies, I think of them in terms of layering... 

summer_face_by_phelixas.jpg.f7fe01e5b0714bcbaf9cad46476724f3.jpg


Hello orange bunny.

japanese_2010_con_by_phelixas-d3kt70j.jpg.10fbc2a4840a0a08b52b2902ac840276.jpg


Hello DSTOUT orange bunny.

2010_magpie_by_phelixas-d3kt6o8.jpg.e049ecde91699f527e429b956a945ade.jpg


And hello to you too, #ffffff version of DSTOUT orange bunny.

 
Also wanted to add this little editor. I wanted a faster way of editing rabbits, something where you don't have to click submit on every rabbit.

With this, players can give different names to a bunch of rabbits, and also set different notes, sales prices, and stud prices. All they have to do is click the submit once and it all gets done. 

View attachment 495

Any fields you don't edit will be unchanged since they are all value=$whatevers_already_in_database. 

Not the full code but it's just arrays and a foreach loop. Very basic I'm sure, I'm just stupidly happy because it's faster than phpmyadmin and sequel pro and I've found so many uses for editing multiple columns and rows all at once. 

View attachment 497

One odd quirk I found is that it won't update the prices properly when I use number inputs, I had to use text inputs (which seems to work fine since the data types are INT). That's why those ones sanitized.

I don't consider myself a real programmer, I apologize for my stupid exciteability over basic things. =D 

I'd love to see some people who know what they're doing post some projects =D

 
Last edited by a moderator:
Also wanted to add this little editor. I wanted a faster way of editing rabbits, something where you don't have to click submit on every rabbit.

With this, players can give different names to a bunch of rabbits, and also set different notes, sales prices, and stud prices. All they have to do is click the submit once and it all gets done. 

View attachment 495

Any fields you don't edit will be unchanged since they are all value=$whatevers_already_in_database. 

Not the full code but it's just arrays and a foreach loop. Very basic I'm sure, I'm just stupidly happy because it's faster than phpmyadmin and sequel pro and I've found so many uses for editing multiple columns and rows all at once. 

View attachment 497

One odd quirk I found is that it won't update the prices properly when I use number inputs, I had to use text inputs (which seems to work fine since the data types are INT). That's why those ones sanitized.

I don't consider myself a real programmer, I apologize for my stupid exciteability over basic things. =D 

I'd love to see some people who know what they're doing post some projects =D
@Hare: Well for someone who is not much of a programmer this is pretty interesting though. :) Does isset mean check to see if edit is being used and if so edit the name, the sales, the stud point, and is notes a fancy way of saying description? Say hare is it okay for me to show off some of my code? If so which would you like to see first ruby on rails or C++?

 
@Hare: Well for someone who is not much of a programmer this is pretty interesting though. :) Does isset mean check to see if edit is being used and if so edit the name, the sales, the stud point, and is notes a fancy way of saying description? Say hare is it okay for me to show off some of my code? If so which would you like to see first ruby on rails or C++?
Thanks! yeah, the isset is if the 'Apply Changes' button that edits everything' gets clicked.

The notes are like a description on this game, we also have special 'note codes' players can put on their rabbits. You can put 'nosell' in the notes for example, and the selling option will not show up. That helps people avoid accidentally selling the rabbits they want to keep. 

I don't know anything about ruby on rails or C++ and would love to see anything you have. 

 
Last edited by a moderator:
Say hare is it okay for me to show off some of my code?
Feel free to post your code, it's one of the reasons this wonderful forum exists :P

Does isset mean check to see if edit is being used and if so edit the name, the sales, the stud point, and is notes a fancy way of saying description?
For a little more techy background:

In PHP, the isset() function checks to see if a variable is initialized and is not NULL. In simple terms, that it exists and has a value. See http://php.net/isset for the docs on the function. It is used in @Hare's code sample to verify that a value from the form was submitted. If the user just visited the page without submitting any form, there would be no $_POST array - or that array would not have a key with 'edit' as the key in it, thus the isset() would return FALSE.

 
@Hare Wonderful work on your bunny genetic stuff as well as your multiple edit. Those concepts are usually harder concepts for many a programmer to grasp, but it seems you have them down pat. Great job!

 
Thanks! yeah, the isset is if the 'Apply Changes' button that edits everything' gets clicked.

The notes are like a description on this game, we also have special 'note codes' players can put on their rabbits. You can put 'nosell' in the notes for example, and the selling option will not show up. That helps people avoid accidentally selling the rabbits they want to keep. 

I don't know anything about ruby on rails or C++ and would love to see anything you have. 
@Hare: Now this code right down here is the pm controller of my website. The controller in this setup acts as a type of switch. Each one only utilizes one line of code per action.

View attachment 505

Feel free to post your code, it's one of the reasons this wonderful forum exists :P

For a little more techy background:

In PHP, the isset() function checks to see if a variable is initialized and is not NULL. In simple terms, that it exists and has a value. See http://php.net/isset for the docs on the function. It is used in @Hare's code sample to verify that a value from the form was submitted. If the user just visited the page without submitting any form, there would be no $_POST array - or that array would not have a key with 'edit' as the key in it, thus the isset() would return FALSE.
@Digital: So that is what it does. :)

 
Love the variability in your genetics script @Hare more realistic, and I would imagine more fun. The standard, will just make a bunch of colors and then set it to that image with no variability is one of the reason I don't enjoy breeding in most sim games. I think your system would be a lot more fun, and actual surprises/differences among the babies.

 
Thank you, Anoua, Nate and Digital! And for your formal explanation of the isset. 

Am also interested in knowing what yout code does, Boltgreywing!

 
I made a Halloween game for a contest on VPL. Was a one week project which had the requirements of being able to run from a zip file and being Halloween themed. We were able to use past assets and libraries. So I pulled in some Zorvic plushies coloring them for Halloween (and now able to found in Eliyo as well in limited quantities) and @MoonDust did all the music and sound effects which I think turned out great. 

munchies1_zpswglqrojb.jpg.209be370083c2ff9a8424e2951689158.jpg


But as for the programming it's all javascript. Jquery and foundation were also utilized instead of starting from scratch. The main point is to collect all the different plushie colorings and all the medals which there are four categories and three levels. Essentially every time you feed a piece of candy to the Zorvic plushie it changes colors. This also increases the plushies stats which there are 6 stat levels. Better stats are how you win the contests which nets you medals. 

I tried to keep it simple and basic because of the time constraints, but quite a bit of work went into things really including coming up with the concept and how to get candy etc... But there are some intricacies too. For example earned stats for candies. On load everything is set, and the amount earned for each candy is then set for the entire game. This means that the Rainbow candy will give different stats per game, but for the entire game the same stats are earned. Doesn't end up playing much of a role since you can't just buy a chosen candy type though but could be built on if this was ever extended more fully. 

As well candies have a rarity. I just did this in a simple way that works, but would be a pain to maintain. And that is I made a list of all the candies, and then for ones that should appear more often, they are in the list more often like shown below.

var candiesRarityList = [
0, 0, 0,
1, 1, 1, 1, 1,
2, 2, 2, 2,
3, 3,
4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5,
6, 6, 6, 6, 6,
7, 7, 7,
8, 8, 8, 8,
9, 9,
10, 10, 10, 10, 10,
11, 11, 11, 11, 11,
12, 12, 12,
13, 13
];

Code:
    // Setup Game skins
    skins = [];
    skins.push(new Skin(1, 'Black Cat', 'cat.png', 'Plain black cat with yellow eyes.'));
    skins.push(new Skin(2, 'Chocolate Peanut Cup', 'chocolatepeanut.png', 'Chocolaty brown with a tan peanut colored finish and suspiciously familiar orange eyes.'));
    skins.push(new Skin(3, 'Zikzang Flower', 'frangi.png', 'The colors of the zikzang flower, pinks and a yellow belly.'));
    skins.push(new Skin(4, 'Cursed Apple', 'apple.png', 'Purple with glowing eyes, they might have ate a cursed apple.'));
    skins.push(new Skin(5, 'Halloween', 'pumpkin.png', 'Orange color of a pumpkin with green eyes.'));
    skins.push(new Skin(6, 'Candy Corn', 'candycorn.png', 'White, orange, and yellow, who would of thought candy corn could have such an affect.'));
    skins.push(new Skin(7, 'Eyeball', 'eyeball.png', 'This one almost looks like an eyeball, red veins on the tail.'));
    skins.push(new Skin(8, 'Frankensteins Monster', 'frank.png', 'Frankenstein created a monster.'));
    skins.push(new Skin(9, 'Ghost', 'ghost.png', 'Ghastly white fur with pink red eyes.'));
    skins.push(new Skin(10, 'Ice', 'ice.png', 'Sparkly blue ice with sparkling stars.'));
    skins.push(new Skin(11, 'Pumpkin', 'pumpkin-vine.png', 'Pumpkin coloring with green vines.'));
    skins.push(new Skin(12, 'Rainbow', 'rainbow.png', 'Familiar red coloring with orange, yellow, green and purple.'));
    skins.push(new Skin(13, 'Brown Werewolf', 'werewolf.png', 'Brown werewolf with silver eyes.'));
    skins.push(new Skin(14, 'Silver Werewolf', 'wolf.png', 'Silver werewolf with yellow eyes.'));
    this.skins = skins;

This does mean candy rarity is set per game which is actually what I wanted in this case. 

But anyway the full code is actually all accessible for anyone interested and can be found here, 

http://munchies.eliyo.net/common.js

Here is the contest page,

munchies2_zpskxpawm0b.jpg.1e06f849547bd956f5b8ac13aba3521d.jpg


Each contest has 3 stats that they use to judge winners. So when a contest is entered, it generates a couple contestants that are within a certain range based on the contest level. Then each one including yours is checked for the winner adding up the 3 stats and adding in some random points to add some variability as well (so if you win once that doesn't mean you will win every time). This all happens really, really fast. So, to make it feel a bit more like something is happening I added a delay with sound and spinner to signify the contest being on going. Simple, but really makes all the difference in it feeling more eventful.

munchies3_zpsmndqdjmp.jpg.a366fd05f97df199fa4e402a668ed01b.jpg


The game is still playable if anyone wants to check it out,

http://munchies.eliyo.net/

This post is long enough but if there are questions I can elaborate.

 
Could you go into more detail on this? What happens once this has been called?
@Nate: When it is called it looks through the list and calls the show page for example in the helper method which then calls the show view page.

Thank you, Anoua, Nate and Digital! And for your formal explanation of the isset. 

Am also interested in knowing what yout code does, Boltgreywing!
@Hare: I think I need to add a bit more code.

 
Back
Top