Jeran

Howdy! I make things!

Cohost is goign to be my one stop shot for just dumping all my current hyperfixations, and the random things I make as a result of them!

posts from @Jeran tagged #programming

also: #software development, #coding

# Define a function to generate and show a random number
def swing():
    result=0
    tempDamage=0;
    defenseAmount=0;
    #decide if we hit the enemy
    if(random.randint(0,accuracy.get())  >=  random.randint(0,enemy_evasion.get())):
        #decide if the hit has magic embued damage
        if(random.randint(0,max_value)  <=  weapon_elemental_chance.get()):
            print("the weapon sparkles with magics!")
            playsound(magicHitSound)
            elementalHit=1;
        else:
            playsound(hitSound)
            elementalHit=0;
        #decide if it is a critical hit or not
        if(random.randint(0,max_value)  <=  critical_chance.get()):
            print("crit!")
            criticalHit=2;
        else:
            criticalHit=1;
        #calculate the regular damage.
        tempDamage=1+Fuzz(attack.get()*((1+(2*weapon_level.get()/max_value)))) ##damage
        #print("attack damage is ",tempDamage)
        defenseAmount=tempDamage-(max(tempDamage-enemy_armor.get(),0)*max(.01,(1-(enemy_defense.get()/max_value)))) 
        result=max(tempDamage-enemy_armor.get(),0)*max(.01,(1-(enemy_defense.get()/max_value))) ##resistances
        
        result=result+(elementalHit*Fuzz(weapon_elemental_power.get()) * (1-(enemy_elemental_type_resistances.get()/max_value)))#elemental damage and resistance
        result=int(result*criticalHit) #crit bonus

    else:
        playsound(missSound)
        result="Miss!"
    


    #process results.
    if(result!="Miss!"):
        enemy_hp.set(enemy_hp.get()-result);
    if(enemy_hp.get()<=0):
        print("BAAAAAUGH. you killed it!");
        playsound("death.wav")
        #add experience, and level up if needed.
        experience.set(experience.get()+enemy_level.get());
        if(experience.get()>=level.get()):
            playsound("levelup.wav")
            experience.set(experience.get()-level.get());#it takes as much exp to level up as your current level.
            level.set(level.get()+1)#incriment by one (i know that if you manage to level up more than once, then it would take another kill to flush the banked levels)
        ###reset the enemy by picking a new level of difficulty, a new health amount, and setting its max, and current HP.    
        enemy_level.set(random.randrange(1,10))
        enemy_max_HP.set(random.randrange(1,10*enemy_level.get()));
        enemy_hp.set(enemy_max_HP.get())
    testHealth=int(healthBarSize*(enemy_hp.get()/enemy_max_HP.get()))
    pb1['value']=testHealth#update the health bar, by getting the health percentage, and multiplying it by the bar size to get progress
    print(result, "attack:", tempDamage, " defended:",defenseAmount,"health"+str(testHealth));

the nice thing about this tho, is that i have been actually learning how to use Tkinter, and it seems.... fun? im horrible at front end, so this is a revelation for me.



this post is my tag list and might be a living document, but it will serve as both a way of knowing a bit about me and what i will likely post, and as a place to click around and see my posts by topic. Enjoy your stay!

#blender3d

#neopets (especially bori!)

#writing

#programming

#programming as art

#gamedev

#drawing

#DnD

#eggbug

#furry

#maker

#museums



Here's an old script I wrote, and some results.

The idea here is that you take an input image, and you load all of the pixels into a big ol list. Then, you place a number of random seed pixels. The algorithm then will kind of wander thought he list looking for close matches in color to any pixel with an open space around it. If it cant find a close enough match, it loosens its requirements.

This is a naïve way of pixel sorting, because it leaves some gaps at the end where non matching pixels will inevitably be shoved, but still, it works nicely!

One of the fun things to do with this script is participate in the ALLRGB challenge.

For that, you simply load a list of all the colors you want to use instead of an input image, and then go to town.

this one makes the randomly placed leftovers a little more obvious

If you apply it to impressionist paintings, you get equally impressionist results! Claude Monet’s Poppies, Near Argenteuil.

And can also do great work with 2 color linear gradients.

There's only one problem with the code.... I can't find it! ¯_(ツ)_/¯ can't share it until i find it. but I can assure you, that it's not fun to look at code.