Jump to content

Show off some of your coding projects


Digital

Recommended Posts

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!

Link to comment
Share on other sites

 

mirror_spot_by_phelixas-d3kt3vj.jpg

rabbit.php?abre=es&%20%20style=1&%20%20brabbit.php?abre=es&%20%20style=1&%20%20b

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. 

592739957802a_ScreenShot2017-05-26at1_07_25AM.thumb.png.159e4e6e2bc75f5cf6853972dd93c998.png

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?abre=es&%20%20style=1&%20%20brabbit.php?abre=es&%20%20style=1&%20%20b

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

Hello orange bunny.

japanese_2010_con_by_phelixas-d3kt70j.jp

Hello DSTOUT orange bunny.

2010_magpie_by_phelixas-d3kt6o8.jpg

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

 

  • Thanks 2
Link to comment
Share on other sites

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. 

59275058a17ce_ScreenShot2017-05-26at1_01_38AM.thumb.png.64712f818e10c23a7501066a286ff029.png

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. 

592754d41b3a0_ScreenShot2017-05-26at3_03_23AM.thumb.png.76c4927fdfb97f210067668bc88b03a3.png

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

 

Edited by Hare
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

12 minutes ago, Hare said:

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. 

59275058a17ce_ScreenShot2017-05-26at1_01_38AM.thumb.png.64712f818e10c23a7501066a286ff029.png

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. 

592754d41b3a0_ScreenShot2017-05-26at3_03_23AM.thumb.png.76c4927fdfb97f210067668bc88b03a3.png

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++?

  • Thanks 1
Link to comment
Share on other sites

12 minutes ago, Boltgreywing said:

@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. 

Edited by Hare
  • Thanks 1
Link to comment
Share on other sites

5 hours ago, Boltgreywing said:

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

5 hours ago, Boltgreywing said:

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.

Link to comment
Share on other sites

23 hours ago, Hare said:

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.

5928a1e79076d_Pmssample.thumb.png.88c10c79e4281294e739b052114dfac1.png

 

17 hours ago, Digital said:

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. :)

Link to comment
Share on other sites

44 minutes ago, Boltgreywing said:

@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.

5928a1e79076d_Pmssample.thumb.png.88c10c79e4281294e739b052114dfac1.png

 

Could you go into more detail on this? What happens once this has been called?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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
];
    // 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

 

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

 

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.

  • Thanks 1
Link to comment
Share on other sites

On 5/26/2017 at 3:34 PM, Nate said:

 

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.

On 5/31/2017 at 7:31 AM, Hare said:

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.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...