I make sims like a game, and now I'm trying to figure out how I will structure my objects.
Now I'm going to create a class called GameObject, psuedo below
public class GameObject {
name:String
width:int
height:int
}
In this way, I could create objects such as bushes, trees and buildings. But then I started to think. What if I wanted to create several buildings and trees of the same type? I would have to make GameObject instances and give it a new name, height and width. The properties must be the same so that I can duplicate one object. It seems a little tedious. Then I think maybe this is not the right way. So I thought: I will have to extend GameObject, as shown below
public class Tree extends GameObject{
birdHouse:Boolean
}
public class Building extends GameObject{
packingGarage:Boolean
stories:Number
}
public class House extends GameObject{
garage:Boolean
stories:Number
}
, , . , , , .
, . - . , - . . , , ,
public class GameObject implement IGameObject {
name:String
width:int
height:int
}
, , , GameObject.
Selector.loadObject(gObject:IGameObject);
, (, , , ), case, , , .
Tile, loadObject. GameOject. case , Tile, , .
, , , - , IGameObject. .
, , .
, , !