Tamagotchi emulator: Difference between revisions

m
opening dialogs
m (typo in markup)
m (opening dialogs)
Line 658:
end
 
introduce(pet) = "Hello! My name is $(pet.name) and I am your pet, a $(pet.age ÷ 12365)-year-old $(pet.species)!"
wellbeing(pet) = "My weight is $(pet.weight), I have $(pet.health) health points and $(pet.happiness) happy points."
request(pet) = "Please look after me..."
Line 664:
decrease_health(pet::Pet) = (pet.health -= (pet.health > 2) ? 1 : 0)
increase_weight(pet) = (pet.weight += (pet.weight < 8) ? 1 : 0)
decrease_weight(pet) = (pet.weight -=< (pet.weight3 >? 2decrease_health(pet) ?: 1pet.weight :-= 01)
decrease_hunger(pet) = (pet.hunger -= (pet.hunger > 2) ? 1 : 0)
increase_hunger(pet) = (pet.hunger += (pet.hunger < 8) ? 1 : 0)
increase_happiness(pet) = (pet.happiness += (pet.happiness < 8) ? 1 : 0)
decrease_happiness(pet) = (pet.happiness -=< (pet.happiness3 >? 2 decrease_health(pet) ?: 1pet.happiness :-= 01)
 
const pet_default_image = load("/users/wherr/documents/Julia Programs/pet_default.png")
const pet_cuddle_image = load("/users/wherr/documents/Julia Programs/pet_cuddle.png")
const pet_feeding_image = load("/users/wherr/documents/julia programs/pet_feeding.png")
const pet_catch_stick_image = load("/users/wherr/documents/julia programs/pet_catch_stick.png")
const pet_sleeping_image = load("/users/wherr/documents/julia programs/pet_sleeping.png")
const pet_tailchase_image = load("/users/wherr/documents/julia programs/pet_tailchase.png")
const pet_poop_image = load("/users/wherr/documents/julia programs/pet_poop.png")
const pet_walk_image = load("/users/wherr/documents/julia programs/pet_walk.png")
const pet_vet_image = load("/users/wherr/documents/julia programs/pet_vet.png")
const pet_sick_image = load("/users/wherr/documents/julia programs/pet_sick.png")
const pet_death_image = load("/users/wherr/documents/julia programs/pet_death.png")
 
function TamagotchiApp()
Line 705:
current_image = pet_default_image
showall(win)
info_dialog(introduce(pet))
info_dialog(wellbeing(pet))
 
@guarded draw(canvas) do widget
Line 714 ⟶ 716:
 
function update_status()
str = " Age " * rpad(pet.age ÷ 365, 5) * "Weight " * rpad(pet.weight, 5) * "Hunger " *
rpad(pet.hunger, 5) * "Happiness " * rpad(pet.happiness, 3)
GAccessor.text(status, str)
Line 904 ⟶ 906:
elseif pet.health < 4 && rand() < 0.3
vet()
elseif rand() < poop_chance && pet.hunger < 6
poop()
elseif rand() < 0.32 * (pet.hunger - 42)
hungry()
else
Line 912 ⟶ 914:
end
if (pet.weight < 3 || pet.happiness < 3) && pet.health > 4
warn_dialog(request(pet))
pet.health -= 1
end
Line 935 ⟶ 938:
TamagotchiApp()
</lang>
 
 
 
=={{header|Objeck}}==
4,102

edits