Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (582)
games submitted by our members
Games in WIP (503)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Discussions / General Discussions / Re: JDK: upcoming features on: 2013-02-22 00:00:31
could be a nice way to intergate jacascript libs in java clients.
Same javascript libs are not that bad.
javafx + webview(webkit) + nashorn

javascript on serverside would be terribble indeed. Shocked

If you want to share code than go for a java client with javafx. I cant understand why people think a browser(designed to render static content) is a better plaftform than a vm(designed to execute code). But strangely "no deployment" is a killer phrase.

Imho the best new feature in java8 will be javafx8.
2  Games Center / WIP games, tools & toy projects / Re: Greenspace, a park or landscape design toy on: 2013-01-17 19:37:16
I am not sure if you if you really locked at xtext.
Basically it given you an eclipse plugin with code completion, Syntax highligting and so far.
That alone is far more beginner friendly.
And you get an abstract ecore meta model which you can transform with the elipse M2M tools like xtend. That can help for upgrading.

No offensive but for me creating a dsl without a tool (xtext) is like parsing xml with string methods.

btw. you should use javafx for your gui its far better than swing. Maybe the canvas node for you renderer.
3  Games Center / WIP games, tools & toy projects / Re: Greenspace, a park or landscape design toy on: 2013-01-15 19:11:22
you know xtext?
http://www.eclipse.org/Xtext/7languagesDoc.html#tortoise
4  Game Development / Newbie & Debugging Questions / Re: creating classes based on enum on: 2012-12-27 02:43:58
I think it would be useful.
i doubt that actually it sound like a terrible idee.

Sounds like you try to reinvent a dependency injection framework.
http://code.google.com/p/google-guice/

A warrier have a deppendency to weapon and head.
You can make that clear with using those dependeny as constuctor parameter:

1  
2  
3  
4  
5  
6  
7  
8  
9  
class Unit{
  private final Weapon weapon ;
  private final Head head

  public Unit(Weapon weapon , Head head) {
    this.weapon = weapon;
    this.head = head;
  }
}


1  
2  
3  
4  
5  
class WarriorFactory {
  public Unit createWarrior(int level) {
    return new Unit(new WarriorWeapon(level),new WarriorHead(level));
  }
}

you can google for more information ( "manuel dependency injection" )


btw.:
Dont use a namingconvention for classname (you will lose the IDE tooling, eg renaming) instead use annotations.
createInstanceOf() = class.newInstance()
http://stackoverflow.com/questions/4865153/loading-a-class-from-a-string

5  Game Development / Newbie & Debugging Questions / Re: "Universal" file loading and saving system? on: 2012-12-27 01:23:08
you could use the java Preferences API:
http://docs.oracle.com/javase/1.4.2/docs/guide/lang/preferences.html
6  Game Development / Newbie & Debugging Questions / Re: Whats stopping people from changing code in the client application on: 2012-12-17 01:44:46
you cant. "never trust the client"
7  Game Development / Newbie & Debugging Questions / Re: Tips for controlling large game code on: 2012-11-12 22:38:27
-create unit test
-write testable code
http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf
http://misko.hevery.com/code-reviewers-guide/
8  Game Development / Shared Code / Re: KryoNet: TCP and UDP client/server NIO library on: 2012-10-06 20:45:00
indeed it was easy just in case anybody else need it:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public class HashUtil {

   private static final ThreadLocal<Kryo> kryo = new ThreadLocal<Kryo>(){
      protected Kryo initialValue() {
         Kryo kryo = new Kryo();
         return kryo;
      };
   };
   
   public static int hash(Object object){
      Output output = new Output(1000);
      kryo.get().writeObject(output, object);
      int hashCode = Arrays.hashCode(output.toBytes());
      output.close();
      return hashCode;
   }

}
9  Game Development / Shared Code / Re: KryoNet: TCP and UDP client/server NIO library on: 2012-09-23 12:52:39
Is there a way to get hashcode from kryo? (for manual Delta Compression)
10  Discussions / General Discussions / Re: Reinventing the wheel? on: 2012-08-31 22:25:51
you know xtext?
11  Game Development / Newbie & Debugging Questions / Re: (instanceof) Is it EVER ok? on: 2012-08-30 20:09:27
most instanceofs can replaceced with polymorphism.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
class Interactable{
   ...
   public void  addToSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables);
   public void  removeFromSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables);
}

Moveable extends Interactable{
  public void  addToSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables){
    moveables.add(this);
  }

  public void  removeFromSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables){
    moveables.remove(this);
  }
}

Controllable extends Interactable{
  public void  addToSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables){
    controllables.add(this);
  }

  public void  removeFromSpezialCollection(Collection moveables, Collection controllables, Collection colliders, Collection collidables){
    controllables.remove(this);
  }
}

1  
2  
3  
4  
5  
public void addInteractable(Interactable inter){
    interactables.add(inter);

    inter.addToSpezialCollection(moveables,controllables,colliders,collidables);
}
12  Discussions / Miscellaneous Topics / Re: Riven? :D on: 2012-08-27 20:50:57
I feel stupid
me too and i really thought: There ain't no such thing as a free lunch.
13  Game Development / Newbie & Debugging Questions / Re: Type mismatch: cannot convert from List on: 2012-08-26 03:02:47
Quote
I don't think wildcards work like that. Try changing it to
dont work: The return type is incompatible with Entity.getForeignEntities()
Thats also confusing since that should be a case of covariant return type.

btw.: the folowing works:
1  
2  
3  
4  
5  
6  
7  
public class GameStatistik implements Entity{
        private List<EntityRef<PlayerData>> players;
   @Override
   public List<EntityRef<?>> getForeignEntities() {
      return new ArrayList<EntityRef<?>>(players);
   }
}
14  Game Development / Newbie & Debugging Questions / Type mismatch: cannot convert from List on: 2012-08-26 00:42:22
1  
2  
3  
public class EntityRef<T extends Entity> {
...
}

1  
2  
3  
4  
public interface Entity{
   public List<EntityRef<?>> getForeignEntities();
...
}


so why type mismatch?
1  
2  
3  
4  
5  
6  
7  
8  
public class GameStatistik implements Entity{
   private List<EntityRef<PlayerData>> players;
   
   @Override
   public List<EntityRef<?>> getForeignEntities() {
      return players;  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   }
}
15  Game Development / Networking & Multiplayer / Re: [KryoNet] Sending an int[][] over KryoNet on: 2012-08-22 13:15:40
why?
16  Game Development / Networking & Multiplayer / Re: [KryoNet] Sending an int[][] over KryoNet on: 2012-08-20 00:35:03
so any of Launcher.level.getMap() is null. Set a breakpoint at that line to figure out which one.

I dont know if kryo have default support for arrays at the worst you have to write a custom Serializer.
 http://code.google.com/p/kryo/#KryoSerializable
probably you just need something like this:
1  
2  
...
kryo.register(int[].class);

17  Game Development / Shared Code / Re: YUNPM - a Java Media Player on: 2012-08-17 11:57:12
what about javafx for video playback?
https://blogs.oracle.com/javafx/entry/mpeg_4_multimedia_support_in
18  Game Development / Networking & Multiplayer / Re: Extra world in an MMORPG. on: 2012-08-01 20:05:12
You want to make a MMORPG?
STOP! read why:
http://www.gamedev.net/blog/355/entry-2250155-why-you-shouldnt-be-making-an-mmo/
19  Discussions / Java Gaming Wiki / Re: Java Data structures on: 2012-07-31 23:28:57
Collections.synchronizedList(new ArrayList())
20  Game Development / Newbie & Debugging Questions / Re: Save data & Inventory System... Best practice! on: 2012-07-20 23:55:22
i would use xsd and than generate the code with  jaxb. Than i can also easy determine the version of the savedata  by validating against the xsd.
21  Game Development / Game Play & Game Design / Re: Snake movement on: 2012-07-18 21:52:07
Pseudocode:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
     class SnakeHead{
       Vector2 direction;
       Vector2 position;
       double angelspeed;
       ArrayList<Vector2> pastPositions;
    }
   
     class SnakePart{
       Vector2 position;
       double distanceToHead;
    }
     
     class Snake{
        SnakeHead head;
        ArrayList<SnakePart> parts;
    }
     
    void gameloop(long passedtime){
      snake.head.pastPositions.add(snakeHead.position)
      rotateSnakeDirection();
      moveSnakeHead();
     
      double distancetohead=0;
      for (int i=pastPositions.size-1;i>0;i--){
         nextdistancetohead=distancetohead +pastPositions.get(i).distance(pastPositions.get(i-1));
         
         for (SnakePart snakePart: snake.parts){
            if (nextdistancetohead< snakePart.distancetohead <nextdistancetohead){
               snakePart.position.setXY(pastPositions.get(i));
            }
         }
         distancetohead=nextdistancetohead;
      }
     
      if (pastPositions.size>10000){
         pastPositions.delete(0);
      }
    }

22  Game Development / Game Play & Game Design / Re: Snake movement on: 2012-07-18 21:15:48
store the past positions from the head. sum the distances to get the position for the rest.

eg.
past position
(1,2),(1,3),(1,4),(1,5)
distance to folwing parts is 2
so you summ up :
(1,2)+(1,3)+(1,4)==>2 so the next position in 1.3 and so on.


Or
Bind the commands to positions on the map. If a snake segment mass that position the command is executed. Probably hard to kepp it deterministic.
23  Game Development / Shared Code / Re: Simple no-nonsense persistence library on: 2012-06-17 22:49:54
how do you handle the n+1 select problem?
24  Game Development / Newbie & Debugging Questions / Re: Switching TableModel on a JTable. on: 2012-06-03 13:08:58
call fireTableDataChanged()
25  Game Development / Newbie & Debugging Questions / Re: cannot find symbol constructor ImageEntity(PassTheKetchup) on: 2012-05-28 02:42:15
I'm trying to compile my code and and get the following message:
you use a ide right? (eclipse,netbeans,idea)
26  Games Center / Showcase / Re: BlockWars - Multiplayer FPS for PC on: 2012-05-23 18:30:33
Block (aka Winter) is Coming
27  Game Development / Networking & Multiplayer / Re: What do Java game developers use for Database persistence? on: 2012-05-18 01:11:41
sounds like mybatis could be the right tool for you.
28  Discussions / Miscellaneous Topics / Re: Generalized Rant Thread on: 2012-05-13 01:39:08
Well i guess Law Of Demeter is just another myth successfully promoted by computer science professors.  Roll Eyes
Imho pracmatism is fine but if you start defending goto its really gets rediculous.
29  Game Development / Game Play & Game Design / Re: Alternate game modes on: 2012-05-01 22:57:05
Although its no puzzle game, I set up something similiar called WinRule for my game.

It's an interface with different implementations, very simple.
The main method isFulfilled() is called every once a while from the game loop:

boolean isFulfilled(List<Actor> actors, List<Actor> players, Set<Actor> winners);

There is one additional abstract class which got shared code for finding the winners, used by two rules.

Variations are so far: Infinity, Timespan, Highscore, Last-Man, Escape
just an addition thats the strategy pattern http://en.wikipedia.org/wiki/Strategy_pattern

imho there are not much real world usecases for inheritance and the main reason to use inheritance is polymorphism . To avoid
dublicate code use composition. (http://en.wikipedia.org/wiki/Composition_over_inheritance)

But keep in mind there is no perfect code. If you can make the game you want dont worry about the "perfect" design or you will end up over-engineering the game instead of finishing it.
30  Game Development / Game Play & Game Design / Re: The base of an entity system on: 2012-04-24 21:05:14
I dont use an entity sytem cause:
-only a few hundred entities
-dont need to change the game at runtime cause i am the only one involved and i have the debugger anyway
-dont need scipting support cause nobody willl write mods for the game and java compile time is irrelevant
-dont want to learn or create another engine wich is maybe fun but also stop me from coding the game

So instead i do composition over inheritance and avoid deep inheritance hierarchy wich is imho best practise.

i think the points are valid for most projects in this forum.
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (72 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!