Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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 3 4
1  Game Development / Newbie & Debugging Questions / Re: Map generation performance improves with every new map on: 2018-01-13 20:07:45
Ahh I see. So it might even be worth running the map generation a few times in the background, before the user generates a map, to improve performance slightly.
2  Game Development / Newbie & Debugging Questions / Map generation performance improves with every new map on: 2018-01-13 15:28:49
I have a tiled map generator which generates a 41x41 dungeon map with caves, corridors, doors and rooms. I added a timer to see how long it took which looked like:

1  
2  
3  
4  
5  
6  
7  
8  
double start;
do{
    start = System.nanoTime();

    // Map generation code here

    System.out.println("Map generated in " + ((System.nanoTime() - start) / 1000000) + "ms");
}while(!ValidMap());


Also I made the space bar generate a new map for debugging. Here's an example console log after generating the map a few times:

Quote
Map generated in 53.11551ms
Map generated in 20.609848ms
Map generated in 9.712823ms
Map not valid, not enough valid tiles. (19.452705%)
Map generated in 7.532394ms
Map generated in 6.474681ms
Map not valid, not enough valid tiles. (31.290897%)
Map generated in 7.520545ms
Map generated in 6.564025ms
Map not valid, not enough valid tiles. (34.324806%)
Map generated in 7.090159ms
Map generated in 6.431771ms
Map generated in 5.260059ms
Map generated in 4.560361ms
Map generated in 4.998753ms
Map generated in 3.736096ms
Map not valid, not enough valid tiles. (30.041641%)
Map generated in 3.703112ms
Map generated in 3.57406ms
Map not valid, not enough valid tiles. (34.503273%)
Map generated in 14.549861ms
Map generated in 3.725848ms
Map generated in 3.484076ms
Map generated in 3.808787ms

I noticed that the time taken to generate each map reduced each time (with the occasion spike to 14ms).

Here's a gif showing it in action.
Click to Play


Any idea why the first few generations take between 10-50ms and the rest take < 10ms?
3  Game Development / Newbie & Debugging Questions / Re: Hosting your game on: 2017-11-18 09:11:42
You can host your game's where-ever and on as many platforms as you like. Steam is probably a no-no for very small projects due to the cost of submissions. I've used Itch, GameJolt and IndieDB, though I prefer using Itch.
4  Game Development / Newbie & Debugging Questions / Re: Saving a "map" into a single file on: 2017-10-24 08:37:06
If I don't save these resources (images, level structure, etc.) then how is the program meant to "remember" how it looks like after the program is shut down?


Are you referring to bundling all your game assets into one file to distribute along side your jar file? You can put all your game assets inside the final .jar file, so the only thing you will send to players is a single jar file.

If you mean saving all the game assets when the player saves the game, then that's a bad idea. Say your game is 10mb, with the .jar file and all assets. If you save the player's progress you'll end up with a save file that's 10mb, there's no need to duplicate all the game assets.
5  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-10-19 11:01:46
I've managed to get myself a software developer apprenticeship! Its not Java though, its C#; but learning Java in my spare time has helped me with the basics of C# as they are fairly similar.
6  Games Center / Showcase / Re: Forest Roguelike on: 2017-10-16 14:23:59
Thanks for the feedback. This was my first proper go at making a Roguelike, I had a week (sometimes two) to work on a certain aspect of the game; so I feel like is isn't as polished and fleshed out as it could be. I did rely on randomness a bit much. But it was great learning experience and hopefully I can improve on future projects.
7  Game Development / Networking & Multiplayer / Re: [Kryonet] Runescape style movement on: 2017-10-11 07:04:15
Yeah good point, I was thinking a better method might be to let clients do the pathfinding and have the server validate each move to a new tile before sending the move order to other clients.
8  Game Development / Networking & Multiplayer / Re: [Kryonet] Runescape style movement on: 2017-10-10 07:54:13
So the client would find the path, ask the server can I walk this path, the server checks if the path collides and tells the client yes or no.

Would that involve the server also finding the path to check if its valid, or would the client send the path to the server to check, so the server never does any pathfinding.
9  Game Development / Networking & Multiplayer / [Kryonet] Runescape style movement on: 2017-10-08 17:05:54
I've been wondering how to implement a movement system similar to that in Runescape. Basically the world is a grid, a player can click on a grid tile to find a path towards it. Up, down, left, right and diagonal movement would be allowed.

I've thought of a few options.

1. Player client clicks on tile > sends move request to server > server does checks (can walk on tile, distance to tile is short enough, etc) > send move player packet to clients (packet contains destination tile and player id for example) > client receives packet > client finds path towards tile and moves towards it.
2. Player client clicks on tile > sends move request to server > server finds path to destination > sends list of points that make up the path to clients > clients use path data to move player.
3. Player client clicks on tile > sends move request to server > server finds path to destination > player moves on server > server sends packet to client every time the player changes tile (or every x times a second) > client receives packet and moves player by 1 tile.

Number 1 seems like a bad idea, letting the clients find the path towards a location. Number 2 seems better but sending path data to clients seems a bit expensive. Number 3 seems good but might be tricky to implement and might not feel that stable.
10  Game Development / Networking & Multiplayer / Re: [Kryonet] Register and login with username/password on: 2017-09-29 06:10:58
Okay, that seems to work fine! Yeah it's not SSL, I'm not sure how to implement SSL with kryonet, and the testing server I bought can't do Https as it's an IP I connect to, not a domain name.

Thanks for your help!
11  Game Development / Networking & Multiplayer / Re: [Kryonet] Register and login with username/password on: 2017-09-28 19:25:41
Ah so you'd recommend hashing on the client. I'm guessing the hashing of the password + salt would happen before then encryption?

Would it be wise to send the client their salt? The salt is generated by the client the first time they register, when the player wants to login again they will need the same salt to hash their password. Would I need to send the player the salt, to hash the login password, to send to the server, to compare to the stored hashed password?
12  Game Development / Networking & Multiplayer / Re: [Kryonet] Register and login with username/password on: 2017-09-28 17:29:46
Thanks for your help! I think I've figured a system out.

When a player connects, the server generates a public private key for that user. When the player enters a password it is encrypted with the public key and sent to the server. The server then decrypts the password and hashes it with a salt, then stores the hashed password + salt in the database.

When a player wants to login, the server hashes the password sent from the login request with the users salt and compares it to the original hashed password.

Hopefully this is decent enough.
13  Game Development / Networking & Multiplayer / Re: [Kryonet] Register and login with username/password on: 2017-09-27 10:42:37
Thanks! Just so I understand this, will the server generate the public/private keypair, send the public key to clients, clients use the public key to encrypt the data and send it to the server, the server then decrypts the data?
14  Game Development / Networking & Multiplayer / [solved] [Kryonet] Register and login with username/password on: 2017-09-26 18:39:46
I'm working on a small multiplayer game with Kryonet that would require a login with a username and password. I'm wondering what a safe way to handle this would be.

Obviously I won't be storing plain text passwords on the server database, most likely they will be encrypted with a salt (this article seems useful). If I let the server do the encryption it means I'm sending plain text passwords over the network. Would letting the client encrypt passwords be better? Are they any issues with this method?
15  Games Center / Showcase / Forest Roguelike on: 2017-08-26 08:49:19
Hi all,

Over the past 10 weeks, /r/roguelikedev have been doing a dev-along following a Python Roguelike tutorial. Each week, those following do a part of the tutorial. I used the dev-along to make my own Roguelike, written in Java, using each week's topic as a goal to work towards.

The dev-along finished on Tuesday and after some final polish and bug fixes I think its ready!

Download on itch.io
Source code on Github Note: I'm a hobbyist, and I code for fun. I haven't had any programming education or training so don't expect great code. Feel free to poke around the source code at your own peril.

Click to Play




Current Features
  • Procedurally generated forest levels.
  • Monsters and bosses to fight.
  • Items to enchant with spellbooks.
  • Melee and ranged combat.
  • Day / night cycle.
  • Saving / Loading
  • Permadeath!

Classic Roguelikes usually use Ascii characters to represent tiles, monsters and items. I decided to use sprites and after some searching around discovered this forum post which is where I found the artwork for ForestRL.

The only library used is Kryo for saving and loading. I'm using Java Graphics for rendering.

If you find any bugs or issues, leave a comment on the itch.io page, send me a message on Reddit or post it here.
16  Game Development / Game Mechanics / Re: Isometric Mouse Collision? on: 2017-05-29 08:08:24
I'm not doing any screen offset just yet.

This is the sprite I've been using, its 30x15. (Its part of a 64x64 spritesheet, I cut it out at runtime)


When I switch to this sprite, which is 32x32 with the tile on the bottom half, strange things happen.




Edit: I fixed the weird tiles in the last image by changing this line in the rendering code from
1  
int ya = (x + y) * (s.height / 2);

to
1  
int ya = (x + y) * (s.height / 2) / 2;

The mouse collision is still very broken.

Here's a bigger gif. It seems to break on the right half of each tile.
Click to Play
17  Game Development / Game Mechanics / Isometric Mouse Collision? on: 2017-05-28 17:05:52
I've been messing around with drawing isometric tiles and I'm a bit stuck on mouse collisions. I found this article on isometric tiles: http://clintbellanger.net/articles/isometric_math/

Here's my rendering code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
 for(int x = 0; x < map.width(); x++){
   for(int y = map.height(); y >= 0; y--){
      Sprite s = map.getSpriteAt(x, y);

        int xa = (x - y) * (s.width / 2);
        int ya = (x + y) * (s.height / 2);

        Point p = mouseToIsoTile(mx, my, s.width, s.height);
        if(p.x != x || p.y != y) screen.renderSprite(s, xa, ya);
    }
}


The onTile() methods takes in the mouse x,y coords as well as the sprite width and height.

Here's the onTile() method:
1  
2  
3  
4  
5  
public Point onTile(int xa, int ya, int width, int height){
   int x = (xa / (width / 2) + ya / (height / 2)) / 2;
   int y = (ya / (height / 2) - (xa / (width/ 2))) / 2;
   return new Point(x, y);
}


When I run the code to hide the tile below the mouse I get this:
Click to Play

You can see the hidden tile is somewhat accurate, but it seems off and I cant seem to figure out why.
18  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-05-19 07:37:55
Attempted to duplicate this tweet: link

Results were meh but it was a fun little day project.
Click to Play


(made in Java2D btw)

Daaaaaaamn, how did you pull that off in Java2D?
19  Game Development / Game Mechanics / Re: Random weighted number between two numbers? on: 2017-04-14 10:11:47
Thanks for those, I'll give them both a go.

Quick question, where did you get the 'val' value from?  Would that be the 'center' value of 1.165 I mentioned above?
1  
double value = (val + 1.0) * (b - a) / 2.0 + a; // <- interval mapping from [-1, +1] -> [a, b]

20  Game Development / Game Mechanics / Random weighted number between two numbers? on: 2017-04-14 08:12:20
Here's my problem.

I have two numbers: 1.1501344 & 1.1816746. I'd like to generate a random number between these two numbers, but weighted to the 'center' of the number: 1.1659045. So there is a higher chance of the random number being closer to the 1.16 value, rather than the 1.15 & 1.18 values.

I've tried using random.nextGaussian() but that creates values < -1 and > +1.

Any ideas?
21  Games Center / WIP games, tools & toy projects / Re: Spaceship Roguelike on: 2017-03-17 19:55:38
Have a look at these links, got lots of useful resources on making roguelikes. RogueBasin Articles & /r/roguelikedev
22  Java Game APIs & Engines / Engines, Libraries and Tools / Advantages of Ant? on: 2017-01-25 08:44:28
While browsing this forum I've come across users mentioning the build tool Apache Ant. I'm wondering what the advantages are of using Ant in Eclipse over the default setup of pressing the 'Run As' button the default export..

Apologies if this is the wrong board.

Thanks!
23  Game Development / Game Play & Game Design / Re: What's the design approach to rogue-likes? on: 2016-10-09 15:42:00
I've been developing a roguelike in Java myself, the Roguebasin Articles page has been a massive help: http://www.roguebasin.com/index.php?title=Articles. Also have a browse on the RoguelikeDev subreddit: https://www.reddit.com/r/roguelikedev/.
24  Game Development / Game Mechanics / Re: Issue porting dart dungeon generator into Java on: 2016-08-04 18:32:05
Paste the error output please.

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  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 70, Size: 70
   at java.util.ArrayList.rangeCheck(Unknown Source)
   at java.util.ArrayList.get(Unknown Source)
   at com.mac.rsrl.core.world.Dungeon.lambda$0(Dungeon.java:37)
   at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
   at java.util.HashMap$KeySpliterator.forEachRemaining(Unknown Source)
   at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
   at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
   at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
   at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
   at java.util.stream.ReferencePipeline.collect(Unknown Source)
   at com.mac.rsrl.core.world.Dungeon.connectRegions(Dungeon.java:167)
   at com.mac.rsrl.core.world.Dungeon.generateDungeon(Dungeon.java:100)
   at com.mac.rsrl.core.world.Dungeon.<init>(Dungeon.java:70)
   at com.mac.rsrl.screen.GameScreen.<init>(GameScreen.java:34)
   at com.mac.rsrl.screen.StartScreen.input(StartScreen.java:25)
   at com.mac.rsrl.ApplicationMain.input(ApplicationMain.java:49)
   at com.mac.rsrl.ApplicationMain$1.keyPressed(ApplicationMain.java:31)
   at java.awt.Component.processKeyEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Window.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
   at java.awt.EventQueue.access$500(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.awt.EventQueue$3.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
   at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue$4.run(Unknown Source)
   at java.awt.EventQueue$4.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)


The line referenced in the error refers to the pastebin link above.
25  Game Development / Game Mechanics / Re: Issue porting dart dungeon generator into Java on: 2016-08-01 19:47:52
Sorry, I meant in my method in the pastebin link. And I meant to say line 48 in my code.
26  Game Development / Game Mechanics / Issue porting dart dungeon generator into Java on: 2016-08-01 06:31:12
Hi all,

Recently I found a dungeon generator written in dart and have attempted to port it into Java. Here's the dart source: https://github.com/munificent/hauberk/blob/db360d9efa714efb6d937c31953ef849c7394a39/lib/src/content/dungeon.dart

So far I've managed to successfully randomly place rooms and grow a maze around them. But I've hit an issue with the connectRegions method. More specifically lines 211 and 229. I'm struggling to interpret them into Java.

Here's my current method: http://pastebin.com/W9WTEkQT

My methods spits out an array index out of bounds error at line 48 of the pastebin link. I'm probably doing something very stupid, another pair of eyes would help.

Any ideas where I'm going wrong?

Edit: Wrote this on mobile, line numbers were wrong. Corrected now.
27  Games Center / WIP games, tools & toy projects / Re: Vangard on: 2016-02-01 19:54:53
This means that logic updates can be done in parallel as long as each cell being updated is separate from other cells being updated concurrently by two intervening cells in all directions.

So have you implemented multithreading with your entity logic?
28  Games Center / WIP games, tools & toy projects / Re: 64 Pixels - A game about capturing worlds on: 2016-01-23 08:15:52
Woah! Great idea! Just tried it and got 165 seconds.
29  Game Development / Newbie & Debugging Questions / Re: Screen not rendering after separating into multiple classes on: 2016-01-21 21:31:59
Did you try implementing the suggestions we gave?
30  Game Development / Newbie & Debugging Questions / Re: Screen not rendering after separating into multiple classes on: 2016-01-20 21:52:16
The Game variable in your InputKey class is null, you aren't declaring it. You need to do the same as you did in the Screen class and declare your Game variable.
Pages: [1] 2 3 4
 
mercenarius (14 views)
2020-06-04 19:26:01

mercenarius (24 views)
2020-06-04 19:13:43

Riven (866 views)
2019-09-04 15:33:17

hadezbladez (5848 views)
2018-11-16 13:46:03

hadezbladez (2657 views)
2018-11-16 13:41:33

hadezbladez (6273 views)
2018-11-16 13:35:35

hadezbladez (1518 views)
2018-11-16 13:32:03

EgonOlsen (4749 views)
2018-06-10 19:43:48

EgonOlsen (5804 views)
2018-06-10 19:43:44

EgonOlsen (3298 views)
2018-06-10 19:43:20
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!