New answers tagged

1

First option is much better for all the reasons manlio stated. Additionally, in that case you could also use Observer pattern so that when you call fruit->ChangeCoordinates(); you can increase the score from within that method. Just a thought...


1

The first option is probably faster. With the second one you have, at least, the additional memory allocation task. Anyway this is a good example of premature optimization: performance shouldn't be a concern for this kind of operation. The snake eats a fruit just occasionally. Between two meals there are a lot of other (complex) events that take place and ...


0

I think you should use directives for the DOM elements and controllers for interaction between these directives. DOM manipulation should only be done inside a directive. Fetching a text file could be done inside the controller, but it would be better if you did that through a service. Services can be used for reusable business logic/fetching data. You ...


8

Whenever two or more threads need to change the same object and potentially at the same time, you need to ensure that the object remains in a consistent state making it synchronized. Apparently, it's not only about the object, but also its containing object, because you mention "if the user made a change to an object while the tick was deleting it". ...


1

Design patterns don't have much to do with with languages you use. They attempt to separate an application to different elements in an effort to facilitate loose coupling and portability to different platforms to mention a couple. I don't see why using MVC wouldn't be feasible in game development. The nature of the application very rarely defines the ...


1

That's a very confusing specification. "The composition of the item class is a shield,a weapon, an engine, and a ship" : what does it means? An item is composed by a shield, a weapon, an engine and a ship or an item can be a shield, a weapon, an engine and a ship? A ship is an item (that's counterintuitive but it could be, explain how)? Moreover the most ...


3

Generally you need to split your cats logic from its animations. Now first you need to write cats logic. One good approach I have found is to split logic into layers. Needs Cat can have some state with some motives/needs (eat, sleep, etc.) that slowly grow over time and reduce when doing them (think Sims). You can pick current task that fulfills biggest ...


1

If you like to keep the rich possibilities of behaviour trees, you can add a new kind of composite selector node: the Markov selector node. You would have to implement the Markov selector node yourself. It will select one of its child nodes at random, depending on the (child) node that previously succeeded (or failed).


1

You can use tagging: There may be movement tags like "laying", "sitting", "standing", "walking", and "running". Then, you may eliminate unrealistic combinations of tags, e.g. "laying" -> "running" (there must be "standing up" in between). Other tags may describe activities: "sleeping", "eating", "hunting", etc. Again, "sleeping" -> "hunting" is impossible ...


2

I think what you are looking for is the finite state machine or FSM. In short it's a way of change the behaviour of NPC:s according to their current state. EDIT: It's like a behaviour tree but condensed down to some groups "states" that the NPC returns to. A behaviour tree allows much more flexibility of the behaviour but also needs more data for the ...



Top 50 recent answers are included