Tag Info

New answers tagged

0

The way I am doing it with my game is as follows: I have a very generic abstract Item class that is the basis for all types of items. This is what it looks like: public abstract class Item { public enum Type { weapon; } public abstract Type getItemType(); public abstract String getName(); public abstract String ...


0

Well honestly, in a personal project, whatever works for your needs is good enough. In a professional game, if you were working with a team of other programmers and designers you'd want it to be data driven so designers could tweak numbers and such. There's no clear cut answer though, it really is kind of a personal preference of the people involved, and to ...


0

The most straight forward and simplest way is a pretty good design: have a data type that is a list of cards (could be a vector, linked list, or other things) and move cards between card groups as gameplay dictates. Unless you have a reason to go in a different direction, simple is good and will make for less bugs. Even if you need super high performance ...


0

Ive returned to answer my own question now. I ended up using the resources found in this answer: Creating a frozen bubble clone I converted my 2D grid array into a hex array. I still used a 2D array to index into the hexes, but I made sure to make sure my hex grid function in a odd-r layout, and that I indexed my array properly based on that layout. All ...


0

I have programmed a 2-player-local-network-pong game a few weeks ago, here's how I did it: -One side opens a server, the other one connects automatically -they are both spamming their paddles x position towards each other @ 60fps or less [UDP] -if one side hits the ball they decide about the balls new velocity and position and send that to the other one ...


2

A slight variant to jzx's implementation would be to use an update method similar to how you did your draw. It's not uncommon in architectural design to have some context object that often holds a plethora of state information. public interface GameEntity { void update(GameContext ctx); void draw(RenderContext ctx); } Therefore, inside a ...


2

As you've noticed, there are pros and cons to each architecture scheme. Each pattern has its own implications for how objects will interact, and when. First, I'd recommend a quick refresher on SOLID design. Now, what we strive to accomplish with good architecture is enough abstraction that we aren't hampered by the system when we want to add a feature. If ...


2

Because of type erasure you lose the compile time type information of generics when transmitting data over network. If you need it on the receiving side again, you have to put the type information back yourself somehow. It's impossible to say how you should do this, but typically it involves either enums or class names and some type casting.



Top 50 recent answers are included