Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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]
1  Game Development / Newbie & Debugging Questions / Re: LWJGL and Rendering Objects based on co-ordinates on: 2012-12-12 13:59:41
Did I ask for code, I came to this forum because it is a forum that is both a combination of experienced java game developers and newbies, if your telling me to not bother Java-gaming.org with my questions then in all honesty why has anyone come to this forum.

As such, any program is a multi step piece of application, you build class after class and then at the end you join them all together, as as you go through you can learn how things work and ask questions along the way.

A MMORPG is not a big task and as such I wouldnt expect something sellable after my 5 YEARS of developing it.
Did Mark Zuckerberg get told to just make a messaging app as making a whole social network is too hard... NO so really why are you putting your claws in my back saying its not possible.

Anything is possible and those that think otherwise will get left behind.

"If you really are capable of making an MMORPG, you would not have asked for help here."

So tell me, are people who develop such things as MMORPG's shouldn't come here because they know too much.
No one in this world who has created a MMORPG as none have been perfect and they all have flaws.

I think you should change your attitude if you want someone to help you at all.

As any software developer will tell you, writing an application is not a case of writing a few classes and joining them together. A well written application will have been in planning for weeks (sometimes months) before a line of code is written. There is so many things to worry about, such as software architecture, implementation issues, target hardware, etc, etc. The list goes on. If you don't get all this right the first time round you're going to run into problems which ultimately is going to result in your scrapping your work.

Mark Zuckerberg you say? Actually, the first recorded piece of software I can find written by him is a messaging app Smiley.
Quote from: Wiki
Zuckerberg began using computers and writing software as a child in middle school. His father taught him Atari BASIC Programming in the 1990s, and later hired software developer David Newman to tutor him privately. Newman calls him a "prodigy", adding that it was "tough to stay ahead of him". Zuckerberg also took a graduate course in the subject at Mercy College near his home while he was still in high school. He enjoyed developing computer programs, especially communication tools and games. In one such program, since his father's dental practice was operated from their home, he built a software program he called "ZuckNet", which allowed all the computers between the house and dental office to communicate by pinging each other. It is considered a "primitive" version of AOL's Instant Messenger, which came out the following year.[2]
Not to mention Mark Zuckerberg had years of private tutoring, I'm not sure why you seen that as a fit comparison.

Time after time I see newbies jump head first into game development with their dream of creating a fine-tuned unique MMORPGFPSRTS, it just won't work. If you are really set on writing a massively online game I'd advise that you build a portfolio over the years and build a team of developers and content producers.

Look at this relatively simple MMO, WurmOnline (http://www.wurmonline.com/). It has been in development since 2003 and is still under development.
2  Game Development / Game Mechanics / Re: Possible to make an enum of anonymous inner classes? on: 2012-12-06 23:44:06
I'm going to make one last attempt to get my point across in case anyone is still confused. I wrote a prototype Weapon class similar to what I was looking for. Instead of using an enum, I made a class called "WeaponType" with public members containing the anonymous inner class objects. Note that what the fire() method does in this example is irrelevant. It's to demonstrate what I meant.

Main Class: http://pastebin.com/MYewSQgv
Weapon Class: http://pastebin.com/kAJrpVGL
Weapon Interface: http://pastebin.com/MQyv1nzC
Weapon Type Class (Contains anonymous inner classes): http://pastebin.com/QbFuLyMy

I hope I got the point across this time.

You can do this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
enum WeaponType {

    FLAMETHROWER(...) {
        void fire(Point2D target) {}
    },
   
    PISTOL(...) {
        void fire(Point2D target) {}
    };

    private WeaponType(...) {}
   
    abstract void fire(Point2D target);
}
3  Game Development / Game Mechanics / Re: Possible to make an enum of anonymous inner classes? on: 2012-12-06 16:51:58
If I understand correctly, you want to be able to define various types of weapons and new behaviors for them at runtime? If so you could do something like below.
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  
interface Weapon {
    void fire(...);
 
    void reload(...);
}

class DefaultWeapon implements Weapon {
   
    private final WeaponMetaData meta;

    public DefaultWeapon(WeaponMetaData data /* type specific data such as bullet style, speed, etc. */) { this.meta = data; }

    void fire(...) {
    } // fire off a single bullet for default behavior

    void reload(...) {
    }
}

class FlamethrowerWeaponImpl extends DefaultWeapon {
 
    public FlamethrowerWeaponImpl(WeaponMetaData meta) {
        super(meta);
    }  

    @Override
    void fire(...) {
    } //do what has to be done for a specialized implementation.
}

This way you can create specialized implementations for weapons that don't follow the standard "spawn an accelerated particle" behavior.
1  
2  
3  
static Weapon PISTOL = new DefaultWeapon(pistolMetaData);
static Weapon RIFLE = new DefaultWeapon(rifleMetaData);
static Weapon FLAMETHROWER = new FlamethrowerWeaponImpl(flamethrowerMetaData);


Well at least you get it... but the whole point of this was I don't want to have to create 20 different classes for 20 different weapon types. Meanwhile, everyone else still thinks I mean I want different parameters to define damage, speed, etc...

The only cases which you would need to define a different class is if you need a weapon which implements non-standard behavior (standard defined as whatever is in DefaultWeapon.) What the others were saying is that if you feed the default implementation enough data then you won't need to create specialized implementations. For example, I have a class named DefaultWeapon which fires a single shot and a specialized implementation named SpreadShotWeapon. I can eliminate the need for SpreadShotWeapon type if I introduce three new parameters: angle, particle count and shot type.
4  Game Development / Game Mechanics / Re: Possible to make an enum of anonymous inner classes? on: 2012-12-06 16:12:44
If I understand correctly, you want to be able to define various types of weapons and new behaviors for them at runtime? If so you could do something like below.
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  
interface Weapon {
    void fire(...);
 
    void reload(...);
}

class DefaultWeapon implements Weapon {
   
    private final WeaponMetaData meta;

    public DefaultWeapon(WeaponMetaData data /* type specific data such as bullet style, speed, etc. */) { this.meta = data; }

    void fire(...) {
    } // fire off a single bullet for default behavior

    void reload(...) {
    }
}

class FlamethrowerWeaponImpl extends DefaultWeapon {
 
    public FlamethrowerWeaponImpl(WeaponMetaData meta) {
        super(meta);
    }  

    @Override
    void fire(...) {
    } //do what has to be done for a specialized implementation.
}

This way you can create specialized implementations for weapons that don't follow the standard "spawn an accelerated particle" behavior.
1  
2  
3  
static Weapon PISTOL = new DefaultWeapon(pistolMetaData);
static Weapon RIFLE = new DefaultWeapon(rifleMetaData);
static Weapon FLAMETHROWER = new FlamethrowerWeaponImpl(flamethrowerMetaData);
5  Java Game APIs & Engines / Java 2D / Re: Scan if unit is visible to an other unit on: 2012-12-06 00:11:45
Thanks for the code saifix. I will try to understand the code instead of just copy and paste.
Could you please give a more detailed explanation of the code? For instance, what is Vec2? The arg to direction, is that X Y coordinates to an object?

Also, your code just check a straight line, right?

Vec2 is a vector made up of 2 components, x & y. The arguments are the direction which the casted ray is traveling in, if it were (-1, 0) it'd test a straight line starting going to the left of the unit and if it were (0, 1) it'd test a line traveling up from the unit.

Yes, it only checks a straight line.
6  Java Game APIs & Engines / Java 2D / Re: Scan if unit is visible to an other unit on: 2012-12-05 12:46:22
There are several examples of how to do this on: http://roguebasin.roguelikedevelopment.org/index.php?title=Field_of_Vision

You can use this code to check if a wall is in a units line of sight.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
Unit u = ...;
Vec2 direction = new Vec2(1, 0); // whatever direction the unit is facing, 1,0 = along the X axis
Vec2 searchPosition = u.position().clone();
for(int i = 0; i < u.searchDistance /* how far should we cast a ray*/; i++) {
     if(map[searchPosition.x][searchPosition.y] == 0) {
         return true;
     }
     searchPosition.add(direction);
}
return false;


If a wall is in the way this code will return true, if not it will return the opposite. With a few modifications you can make it check for another unit.
7  Game Development / Newbie & Debugging Questions / Re: Gameserver performance on: 2012-12-04 10:56:45
I understand your concerns, but, the client isn't handling anything on its own! The idea is that the position is kept server-side, here's pseudo-code for it:
1  
2  
3  
4  
5  
oldPosition = player.position;
player.position = get_new_position(player, input);
relativePosition = player.position - oldPosition;
updatePositionPacket.position = relativePosition;
player.send(updatePositionPacket);


The server is telling the client where to move to, not the other way around! You just feed the client data.
8  Game Development / Newbie & Debugging Questions / Re: Gameserver performance on: 2012-12-04 10:11:02
I haven't seen your code, but judging from your other thread I'm going to assume you are still updating every player on each broadcast? Serialization is very costly and isn't exactly something you should be doing on a List of objects twice a second. Something you could consider is to have the client maintain a list of local players and have 2 packets for adding and removing players from this list. For example:

1  
2  
3  
4  
5  
public class RegisterLocalPlayerPacket {
    protected Player player;

    protected int identifier;
}

1  
2  
3  
public class DeregisterLocalPlayerPacket {
    protected int identifier;
}


Then when you want to update something such as a players position you could have yet another packet!
1  
2  
3  
4  
5  
public class UpdatePlayerPositionPacket {
    protected int identifier;
   
    protected float relativeX, relativeY;
}


Note: identifier is just a unique ID for an online player.

However, this means on the server end you need to update players separately from one another. What I'd do is create event listeners (I'm not exactly sure how your server works so this may not apply!) for players entering a new area. Upon entering that region I'd broadcast a RegisterLocalPlayerPacket to everyone in that area. When the player leaves the area you then just broadcast the opposite packet to everyone in that area.

Now you have the task of updating player positions. That's easy, you just take the players current position and subtract their last position. You can now do:
1  
player.setPosition(x - diffX, y - diffY);


Hope that helped.
9  Game Development / Newbie & Debugging Questions / Re: Kryonet - Passing players on: 2012-12-03 14:50:35
I'm not very familiar with "Kryonet" but it seems like it assumes a no args constructor exists since there's no way for the library itself to distinguish parameters from each other (x, y, etc., conflicting types with no runtime information other than their order in the constructor.) You should add a default constructor to the class and see if that solves your problem.

1  
2  
3  
public Player() {
    this("name", 0, 0, "img.png");
}
10  Game Development / Newbie & Debugging Questions / Re: Updating positions from MySQL database on: 2012-12-02 15:19:42
Ughh, well, polling the database can be relatively costly and you're doing this once every second. You're bound to encounter some lag, especially since it looks like you're not only deserializing the players updated position but the entire structure stored for them. Are you sure you have no alternative way you can go about this? It looks like you all you're doing is synchronizing server state with your clients. How about creating a central server which keeps track of player state and updates the client at a set interval?

edit: I think it's worth adding that you quoted that block of code from your Render method. You should separate game logic from rendering, as far as game logic is concerned rendering should be a read only operation.

Doesn't the Update method only run when there's a player input? :-)

Maybe I should have put that a little differently, when I said update what I meant was synchronize state with the clients. My bad :-)

OP: for such a simple game I'd have a server run which handles input and sends off state updates (anything such as a new position) every set period. For example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
long lastUpdate = 0;
while(running) {
    handleInput(); // pop events off of a queue which is populated by the networking thread
   long delta = System.currentTimeMillis() - lastUpdate;
    if(delta >= synchronizationInterval) {
        for(int i = 0; i < connectedPlayers.length; i++) {
            Player player = connectedPlayers[i];
            // send updates to this player
       }
        lastUpdate = System.currentTimeMillis();
    }
}


I can see the sense of having a server to handle the game state and now and then write the current state to the database. I, however, have absolutely no idea how to write such a server. How would you suggest me learning it? :-)

Well -- there's really countless ways to go about implementing a client-server model for a game. However for now I'd suggest you keep it simple and look into the thread per client model.

Quote
It's probably the most popular threading model, because it's reasonably simple to implement, and is the fastest model when the maximum number of ``simultaneous'' (at the time scale of the service completion) requests is in the order of a few tens. The server sits in a loop accepting forthcoming connections, and as soon as they arrive it spawns a thread that is responsible for handling the client for all the duration of the connection. Using a separate thread for each client has the advantage of reducing complexity, because each code path needs to perform only a single operation: the main thread accepts connection, and the child threads service them.

The downside is that this model doesn't scale well with the number of clients, for two reasons: because of the demands of each service thread on system resources, and because the of time the system spends context-switching (or, even worse, process-switching) among threads. With current technologies, this last term significantly impacts the server's performance when there are more then a few tens of threads running. With increasing number of connections, both terms reduce the rate at which each client can be serviced up to a point when accepting new connections becomes impractical.
.
If you don't want to get into the nitty gritty details of networking code right nwo and just want to progress on with your game you could also use a pre-existing third party library which abstracts a lot of the stuff like Netty or Apache MINA.

https://netty.io/
http://mina.apache.org/

edit: http://docs.oracle.com/javase/tutorial/networking/overview/networking.html
11  Game Development / Newbie & Debugging Questions / Re: Updating positions from MySQL database on: 2012-12-02 14:59:31
Ughh, well, polling the database can be relatively costly and you're doing this once every second. You're bound to encounter some lag, especially since it looks like you're not only deserializing the players updated position but the entire structure stored for them. Are you sure you have no alternative way you can go about this? It looks like you all you're doing is synchronizing server state with your clients. How about creating a central server which keeps track of player state and updates the client at a set interval?

edit: I think it's worth adding that you quoted that block of code from your Render method. You should separate game logic from rendering, as far as game logic is concerned rendering should be a read only operation.

Doesn't the Update method only run when there's a player input? :-)

Maybe I should have put that a little differently, when I said update what I meant was synchronize state with the clients. My bad :-)

OP: for such a simple game I'd have a server run which handles input and sends off state updates (anything such as a new position) every set period. For example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
long lastUpdate = 0;
while(running) {
    handleInput(); // pop events off of a queue which is populated by the networking thread
   long delta = System.currentTimeMillis() - lastUpdate;
    if(delta >= synchronizationInterval) {
        for(int i = 0; i < connectedPlayers.length; i++) {
            Player player = connectedPlayers[i];
            // send updates to this player
       }
        lastUpdate = System.currentTimeMillis();
    }
}
12  Game Development / Newbie & Debugging Questions / Re: Updating positions from MySQL database on: 2012-12-02 12:16:02
Ughh, well, polling the database can be relatively costly and you're doing this once every second. You're bound to encounter some lag, especially since it looks like you're not only deserializing the players updated position but the entire structure stored for them. Are you sure you have no alternative way you can go about this? It looks like you all you're doing is synchronizing server state with your clients. How about creating a central server which keeps track of player state and updates the client at a set interval?

edit: I think it's worth adding that you quoted that block of code from your Render method. You should separate game logic from rendering, as far as game logic is concerned rendering should be a read only operation.
Pages: [1]
 

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 (58 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (213 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!