Reputation: 315
So I've been messing with Ruby trying to make a sort of chicken simulator. I have all these instances of class Chicken
with @x
and @y
variables which represent their position. They have methods like step(direction,steps)
, distance_from(object)
, take_shortest_path_to(object)
, etc.
There is a class Nest
which places instances of itself on the grid and generates a group of Chickens
, setting their starting positions to the Nest
's @x
and @y
values.
I plan to give the Chicken
s the desire to go out into the "world", maybe in search of grain, with which they'll return to the Nest
to stockpile. That actually sounds like SimAnt with chickens. Point is, I feel like a visual interface, even a very, very crude one, would be incredibly helpful at this point.*
But I'm not sure of the simplest way to do that. I feel like there's a lot more work I could do just on the logic before I really worry about how I'm going to actually render everything to the screen (if I even do; I'm really just doing this to learn the general vibe of OOP).
Any suggestions would be greatly appreciated! Thanks.
Upvotes: 2
Views: 446
Reputation: 13574
Shoes seems to be a pretty popular (and easy to learn) GUI framework.
A sample oval in a (apart from the oval) empty window would look like that:
Shoes.app {
oval(left: 10,
top: 10,
radius: 40)
}
You could then draw your nest with an oval (your chicken with images, etc.)
Inserting images is simple too:
Shoes.app {
image "https://upload.wikimedia.org/wikipedia/commons/5/5e/Chicken_suit1.jpg"
}
Have a look at their tutorials for details.
Upvotes: 2