For my computer engineering class I decided that for my culminating assignment I wanted to build a tamagotchi from scratch and Tonight I finished the first fully functional proto type. It’s meant to be a more short term casual style Virtual pet it will likely only stay alive for around ten minutes ( this choice was made because I don’t know how to save to the eeprom) I’ll release the code tomorrow but for now enjoy this video of the prototype in action https://youtu.be/u63W-3Sl8rM
PS. This was my first time ATTEMPTING to use protoboard and yes it is held together with tape
Got the case 3d printed hopefully I can finish this up today!
Looks cool! Here’s the reference site for EEPROM https://www.arduino.cc/en/Reference/EEPROM
it’s generally best to use ‘update’ to write data since it will only write to EEPROM if the value to write is different saving it from unnecessary writes.
Personally I think a better approach is to write a class/struct and then use get
or put
.
(put
uses update
under the hood.)
// Very simple implementation
// Real thing will probably be more complex
class Tamagotchi
{
private:
int8_t hunger;
int8_t happiness;
// etc...
public:
bool isHungry(void) const
{
return (this->hunger < 0);
}
int8_t getHunger(void) const
{
return this->hunger;
}
bool isHappy(void) const
{
return (this->happiness >= 0);
}
int8_t getHappiness(void) const
{
return this->happiness;
}
void feed(uint8_t amount)
{
this->hunger += amount;
this->happiness += amount / 4;
}
void playWith(uint8_t amount)
{
this->happiness += amount / 2;
}
// etc...
};
class Game
{
private:
Arduboy2 arduboy;
Tamagotchi tamagotchi;
// etc...
public:
void setup(void)
{
arduboy.begin();
// etc...
}
void loop(void)
{
// etc...
}
private:
void save(void)
{
// etc...
EEPROM.put(address, tamagotchi);
// etc...
}
void load(void)
{
// etc...
EEPROM.get(address, tamagotchi);
// etc...
}
};
That’s right, I forgot ‘put’ used update. That’s definitely the most straightforward approach then.
Long overdue update!
1st I lost the code…
2nd I never finished this
3rd I don’t really have any interest in finishing this…
That’s why lots of people use GitHub - hard to lose code if it’s backed up on a server.
Lol, honest update. Curious how come no interest to finish?
Just had enough fun with building it?
Fair point. Maybe I’ll look into it for backing up my work cause I have been doing a lot more coding recently. I’m sure I could find the code if I checked the school computers
I’ve grown a bit of a distaste for soldering (at least for now) and the game itself was rushed because it was for a school assignment. Part of what I wanted was to do it the actual size of a tamagotchi but I couldn’t do that in time cause the small screen I ordered took to long to ship so I had to scale it up alot