Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 / Artificial Intelligence / Initial steps on navigation meshes on: 2014-02-20 09:08:30

Hello. I've been reading about navigation meshes because grid-based pathfind doesn't suit the game I'm making because it creates unreal paths.

I know how to implement a simple A* algorithm for a grid base game with nodes, but for navigation meshes I'm a little lost.

Consider this map from my game with the following navigation meshes (they are done poorly, I know, but it's just for the example):



How i use the polygons for the AI to walk?

Are usually just the center and vertices used for navigation and a straight line to go inside them?

Do you usually use center-to-center or how do you discern which point to use?

What if I want to modify the meshes with dynamic obstacles? How can I do that in real time?

Consider that I want to make the map and it's meshes just once and at the beginning of each round place random objects through the map, so the fixed navigation mesh should now take into account those newly generated objects...
2  Game Development / Newbie & Debugging Questions / Re: Main loop for rendering and updating logic or spawn new threads on: 2013-11-23 11:40:54
Unless you're making some kind of super large AAA game, you should be fine with 1 thread.

There is just no way that your game needs more than 1 thread. Besides, rendering happens on the GPU, not CPU. Unless you're going through all the pixels on the screen.

The only time you should be having a second thread, is if your game has a lot of stuff to load. Than you could add another thread to load stuff and nothing more. That would make user experience better, because they wouldn't have to wait for stuff to load.

Thanks.

I'm using Java2D to make the game. I know how to draw 2D with LWJGL basically. I have to understand it better for me to be comfortable to make a game.

I'm using BufferedImages with createCompatibleImage so I guess I should be fine... Maybe if I get stuck at some point with the performance i'd switch to OpenGL.
3  Game Development / Newbie & Debugging Questions / Re: Main loop for rendering and updating logic or spawn new threads on: 2013-11-23 11:38:13
Using seperate Threats shure can give you a boost in performance.
BUT, dont digg into that unless you create some very complex and demanding game simulation (using physics for example).

The effort to get it working right and flawless might not be worth it, when just developing a small indy game.
Suggesting: Stick to a single Thread for logic and rendering.

Thanks for the replies.

Anyway, I'm just doing this to get a better understanding of threads and concurrency while learning how to develop games.

I'll stick to one thread for now then.
4  Game Development / Newbie & Debugging Questions / Main loop for rendering and updating logic or spawn new threads on: 2013-11-23 10:12:48
Hi!

I want to know if this approach is correct:

I have the main thread, as always, and currently it does all the work. I want to try and use the 2 cores my computer has (i always relied on one core only for simplicity) so I'm thinking to use the main loop for the calculations and other stuff not related to rendering graphics and spawn a new thread for this.

My Display class (JFrame) uses different states (JPanels) to change levels and menus, so my first idea is to make the state's superclass extend Thread and every new state I create will spawn a new thread that would run concurrently with the main loop, since there can be only 1 state present, no more than 2 threads would be present at all times.

Do you think this is a good approach?

Another question: If I have two threads, one for each core, do I need to put a sleep in the second thread? I have a sleeping timer for the rendering (main loop) to adjusting the frames so this are constant, but do I need to put the logic thread to sleep even for 1 ms or not?
5  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-18 06:47:54
Generally you would use WAV files for short sounds (Special FX) and Mp3 or other compressed format for music and large sounds.
I've heard that, but I always wonder, why? Is it loading times? I have several theories on this, but I want to know other people's opinions on this, as I am wondering if I am doing something genuinely 'wrong.'

For size purpouses seems the best option.

Wav are default. You don't need extra libraries to use them, so they are easy to access and control.

Mp3 size are very small, but you need to go a little further to use them.

Just an advice that was very useful to me: "wathever works". If it works and it has good performance, go with it.
6  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-18 05:53:27
Generally you would use WAV files for short sounds (Special FX) and Mp3 or other compressed format for music and large sounds.

7  Game Development / Performance Tuning / Re: repaint vs custom draw method performance in ms on: 2013-06-15 06:41:40
If you are concerned with performance you should really not be using Java2D. Roll Eyes Look into LibGDX or any other OpenGL-based renderer instead.

Yeah, I know that, but I'm currently fine with the speed of the game. I'm trying to master this first to go to OpenGL and such... The main question was why i was getting a higher delay with my custom paint method using the same code in paint(Graphics g).

Anyway, i'm having good timing now and going to proceed to other things now.

I'm trying to correct what Kerai said about the array having instance of every tile.
8  Game Development / Performance Tuning / Re: repaint vs custom draw method performance in ms on: 2013-06-14 12:33:25
What are you trying to accomplish here? This looks kinda stupid.

Strategy is used with active rendring, paint (and repaint) is used with passive rendering.

In paint() method you should NOT use buffer strategy - it already gives you Graphics object.

And you should not use passive rendering for game, use active rendering. Draw on canvas, don't even touch the window/frame.

Quote
1  
2  
         for(Tile t : tiles)
            g.drawImage(t.img.getImage(), t.x+trackX, t.y+trackY, null);
This is going to be slow if you render every tile with separate render call. Also, you shouldn't have an instance of class per every tile, that's memory inefficinent. You should hold tile types in array.

Okey, I'll have to check the code and change things accordingly.

The Tile.Class holds data of every tile in the grid with their own bounding box, so whenever I pass the mouse I know above wich tile I am. This was the simplest solution for me, instead of doing calculations.

I'll try to come up with something like you said, but if you can give me a hint about how to make the Tile array would be much appreciated.

Thanks for the advice.
9  Game Development / Performance Tuning / repaint vs custom draw method performance in ms on: 2013-06-14 09:04:49

Okey, so I'm messing around trying to get the best draw method timing out of my gameloop and I found something that I don't quite understand.

Keep in mind this is only a test, not the final code. I'm trying to tweak what I can before starting a real project, so maybe some things are kind of sloppy right now.

This is my main gameloop in Start.class:

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  
@Override
   public void run(){
       final int SKIP_TICKS = 1000000000 / FPS;
       final int MAX_FRAMESKIP = 5;

       int loops = 0;
       
       double before =  System.nanoTime();
       
       while(isRunning){
         
         loops = 0;
         ScreenState state = window.getCurrentState();  
         
         double now = System.nanoTime();
         
           while( now - before > SKIP_TICKS && loops < MAX_FRAMESKIP) {              
               state.run();
               before += SKIP_TICKS;
               loops++;              
           }

           //window.render();
          window.repaint();
           
           double lastRenderTime = now;
           
           while ( now - lastRenderTime < SKIP_TICKS && now - before < SKIP_TICKS)
            {
               Thread.yield();
               try {Thread.sleep(1);} catch(Exception e) {}            
               now = System.nanoTime();
            }
      }
   }


This is the render and paint method in my Screen.class:

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  
@Override
   public void paint(Graphics g) {
      do {
            // The following loop ensures that the contents of the drawing buffer
           // are consistent in case the underlying surface was recreated
           do {
                // Get a new graphics context every time through the loop
               // to make sure the strategy is validated
               Graphics g2 = strategy.getDrawGraphics();

                // Render to graphics
              // currentstate.paintComponents(g);
               currentstate.draw(g2);
                // Dispose the graphics
               g2.dispose();

                // Repeat the rendering if the drawing buffer contents
               // were restored
           } while (strategy.contentsRestored());

            // Display the buffer
           strategy.show();

            // Repeat the rendering if the drawing buffer was lost
       } while (strategy.contentsLost());  
   }
   
   public void render(){
        do {
            // The following loop ensures that the contents of the drawing buffer
           // are consistent in case the underlying surface was recreated
           do {
                // Get a new graphics context every time through the loop
               // to make sure the strategy is validated
               Graphics g = strategy.getDrawGraphics();

                // Render to graphics
              // currentstate.paintComponents(g);
               currentstate.draw(g);
                // Dispose the graphics
               g.dispose();

                // Repeat the rendering if the drawing buffer contents
               // were restored
           } while (strategy.contentsRestored());

            // Display the buffer
           strategy.show();

            // Repeat the rendering if the drawing buffer was lost
       } while (strategy.contentsLost());          
   }


So I execute this in either:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public void draw(Graphics g){
      if(!genDone) return;
     
         start = System.currentTimeMillis();  
   
         g.setColor(Color.red);
         g.fillRect(0, 0, Screen.getInstance().getWidth(), Screen.getInstance().getHeight());
         
         for(Tile t : tiles)
            g.drawImage(t.img.getImage(), t.x+trackX, t.y+trackY, null);
         

         System.out.println("Draw: " + (System.currentTimeMillis() - start));

   }


if i run the code from paint(Graphics g) i get:

1  
2  
3  
20 iterations: 121
20 iterations: 298
20 iterations: 131


Now, if I run the sme code from render(Graphics g):

1  
2  
3  
20 iterations: 296
20 iterations: 297
20 iterations: 280


Why is there that kind of difference?
10  Game Development / Newbie & Debugging Questions / Re: Terraria world generation on: 2013-06-04 07:09:23
Can you show some of the code you use for rendering and stuff?

11  Game Development / Game Mechanics / Re: Isometric Grid - Tiles as objects on: 2013-05-31 06:44:49
There's no "usual" way. There are just ways that work and don't work. What's key is how you separate logic, data and graphics. And two of those three have nothing to do with isometric projections at all.

I just got curious because I didn't see this simpler approach done in the many tutorials I've seen on the internet.
12  Game Development / Game Mechanics / Re: Isometric Grid - Tiles as objects on: 2013-05-30 08:10:29
As an aside, I like the idea of the volume of the tile being highlighted as you hover over it (maybe as a colored translucent cube borderless cube).

That's how X-COM: UFO Defense does it, hehe. Not my idea.

Thanks for the input. It's too early to tell what you asked, since I'm first trying to master everything I need to do for my game before actually doing it.

About the zoom: with AffineTransform i can easilly zoom in and out and everything keeps in place. I was messing around with it yesterday and it's awesome. I'll have to check it out with an actual game running.

I'll make a similar game as UFO Defense, just for the sake of practice. It's an awesome game.
13  Game Development / Game Mechanics / Isometric Grid - Tiles as objects on: 2013-05-30 07:43:01
Hi!

I'm trying to learn about Isometric projection and so far I understand the concept, but the mathematics I saw are a little confusing. Seems like everybody has it's own way of doing them: some are complex, some are simple...

I came up with my own way of drawing into a isometric grid, but the real challenge is mapping the mouse coords to the individual cells in the grid.

I never saw this done (don't know why), but I made every tile on my grid an object with a polygon surrounding it's boundaries and I think is pretty simple and straightforward, because I only need to check if mouseX & mouseY are inside them.

Don't know about a full game using this method, but so far it's fast and reliable.

What do you think about this? Any recommendation?

I'm still trying to learn the "usual" way to do it, anyway...



14  Game Development / Game Play & Game Design / Re: Pixel art? on: 2013-01-27 00:18:19
Paint from Windows 7 it's pretty awesome.

Simple, fast and delivers.

There are people who create awesome graphics with Paint.
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.

ctomni231 (34 views)
2014-07-18 06:55:21

Zero Volt (30 views)
2014-07-17 23:47:54

danieldean (25 views)
2014-07-17 23:41:23

MustardPeter (27 views)
2014-07-16 23:30:00

Cero (42 views)
2014-07-16 00:42:17

Riven (44 views)
2014-07-14 18:02:53

OpenGLShaders (33 views)
2014-07-14 16:23:47

Riven (34 views)
2014-07-14 11:51:35

quew8 (30 views)
2014-07-13 13:57:52

SHC (66 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!