Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-12 06:47:57
Yes inside your entity class, that's normally what we do for continuous movement. If, in your case you want "blocky" move then yours is right. Just I can't imagine if it'll flicking.
Well I think it must of been that as it is now perfect Smiley
2  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-12 06:35:08
Thanks, This seems to have stopped the flicker"! Smiley
3  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-12 06:29:45
Looking on your moving code inside KeyAdapter class, I guess you move hardly, one tile per keypress. If you want a smooth one, you should use delta to calculate the movement little by little each frame.
Like ?
1  
Planetoids.xOffs += Player.moveSpeed * delta
4  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-12 01:48:16
I load them statically in a Tile class?
1  
private static Image TILE_DIRT_IMG = new ImageIcon("res/grass.png").getImage();

Does this load them every time I call it??
5  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-11 18:31:17
What kind of flickering are you talking about? Flickering means that it disappears for a frame or two then reappears. Maybe you mean it stutters, where it doesn't move smoothly?
When I move quite often white rectangles appear instead of the tiles.
6  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-11 18:30:06
It's unique that you use int for delta. Show us your class code that moving.
This is the movement code
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public void keyPressed(KeyEvent key) {
      switch (key.getKeyCode()) {
      case KeyEvent.VK_ESCAPE:
         System.exit(0);
         break;
      case KeyEvent.VK_W:
         Planetoids.yOffs += Player.moveSpeed;
         break;
      case KeyEvent.VK_S:
         Planetoids.yOffs -= Player.moveSpeed;
         break;
      case KeyEvent.VK_A:
         Planetoids.xOffs += Player.moveSpeed;
         break;
      case KeyEvent.VK_D:
         Planetoids.xOffs -= Player.moveSpeed;
         break;
      }
7  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-10 20:57:07
Strangely now I only get flicker when moving up?
8  Game Development / Game Mechanics / Re: Using BufferStrategy But Still Got Flicker on: 2012-05-10 20:25:51
When I move about, up and left it flickers
9  Game Development / Game Mechanics / Using BufferStrategy But Still Got Flicker on: 2012-05-10 18:32:14
Hi,

I am using the game loop in the tutorial basic game, which uses BufferStrategy,  but when I render my world I still get flicker.
If any one could help I would appreciate it. Loop source code:
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  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
public class Planetoids implements Runnable {

   public static int xOffs = 0, yOffs = 0;

   public final int WIDTH = 800;
   public final int HEIGHT = 600;

   private PlanetEarth earth;

   private JFrame frame;
   private Canvas canvas;
   private BufferStrategy bufferStrategy;

   public Planetoids() {
      frame = new JFrame("Planetoids Pre-Alpha 0.0.1");

      JPanel panel = (JPanel) frame.getContentPane();
      panel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
      panel.setLayout(null);

      canvas = new Canvas();
      canvas.setBounds(0, 0, WIDTH, HEIGHT);
      canvas.setIgnoreRepaint(true);

      panel.add(canvas);

      canvas.addKeyListener(new InputManager());

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setResizable(false);
      frame.setVisible(true);
      frame.setLocationRelativeTo(null);

      canvas.createBufferStrategy(2);
      bufferStrategy = canvas.getBufferStrategy();

      canvas.requestFocus();
      init();
   }

   private void init() {
      earth = new PlanetEarth(30,30);
      earth.map = PlanetGenerator.loadMap(30, 30);
   }

   long desiredFPS = 60;
   long desiredDeltaLoop = (1000 * 1000 * 1000) / desiredFPS;

   boolean running = true;

   public void run() {

      long beginLoopTime;
      long endLoopTime;
      long currentUpdateTime = System.nanoTime();
      long lastUpdateTime;
      long deltaLoop;

      while (running) {
         beginLoopTime = System.nanoTime();

         render();

         lastUpdateTime = currentUpdateTime;
         currentUpdateTime = System.nanoTime();
         update((int) ((currentUpdateTime - lastUpdateTime) / (1000 * 1000)));

         endLoopTime = System.nanoTime();
         deltaLoop = endLoopTime - beginLoopTime;

         if (deltaLoop > desiredDeltaLoop) {
            // Do nothing. We are already late.
        } else {
            try {
               Thread.sleep((desiredDeltaLoop - deltaLoop) / (1000 * 1000));
            } catch (InterruptedException e) {
               // Do nothing
           }
         }
      }
   }

   private void render() {
      Graphics g =  bufferStrategy.getDrawGraphics();
      g.clearRect(0, 0, WIDTH, HEIGHT);
      render(g);
      g.dispose();
      bufferStrategy.show();
   }

   protected void update(int deltaTime) {

   }

   protected void render(Graphics g) {
      earth.render(g);
   }

   public static void main(String[] args) {
      Planetoids ex = new Planetoids();
      new Thread(ex).start();
   }

}

The world render code:
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  
public void render(Graphics g) {
      super.render(g);
      int x = 0, y = 0;
      for (int i = 0; i < map.length; i++) {
         if (x == width) {
            x = 0;
            y += 1;
         }
         switch (map[i]) {
         case Tile.TILE_EARTH_DIRT:
            g.drawImage(Tile.TILE_EARTH_DIRT_IMG, x * 32 + Planetoids.xOffs, y * 32 + Planetoids.yOffs, 32, 32, null);
            break;
         case Tile.TILE_EARTH_GRASS:
            g.drawImage(Tile.TILE_EARTH_GRASS_IMG, x * 32 + Planetoids.xOffs, y * 32 + Planetoids.yOffs, 32, 32, null);
            break;
         case Tile.TILE_EARTH_STONE:
            g.drawImage(Tile.TILE_EARTH_STONE_IMG, x * 32 + Planetoids.xOffs, y * 32 + Planetoids.yOffs, 32, 32, null);
            break;
         case Tile.TILE_EARTH_SAND:
            g.drawImage(Tile.TILE_EARTH_SAND_IMG, x * 32 + Planetoids.xOffs, y * 32 + Planetoids.yOffs, 32, 32, null);
            break;
         }
         x++;
      }
   }


Max
10  Game Development / Game Mechanics / Re: JFrame KeyListener Problem on: 2012-04-21 13:45:24
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
package uk.co.maxkingstudios.ld23;

import javax.swing.JFrame;

public class Display extends JFrame {

   private static final long serialVersionUID = 1L;

   public Display() {
      setSize(640, 480);
      setTitle("Ludum Dare 23: ");
      setVisible(true);
      setResizable(false);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      createBufferStrategy(2);
      Game game = new Game(this.getBufferStrategy());
      add(game);
   }

   public static void main(String[] args) {
      new Display();
   }
}

This is the JFrame class
11  Game Development / Game Mechanics / Re: JFrame KeyListener Problem on: 2012-04-21 13:22:33
My JFrame Doesnt extends canvas?
Is that what you mean?
12  Game Development / Game Mechanics / Re: JFrame KeyListener Problem on: 2012-04-21 13:09:00
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public class InputManager extends KeyAdapter{

   public void keyPressed(KeyEvent key) {
      System.out.println(key.getKeyChar());
   }

   public void keyReleased(KeyEvent key) {
      System.out.println(key.getKeyChar());
     
   }

   public void keyTyped(KeyEvent key) {
      System.out.println(key.getKeyChar());
     
   }
}

This is just to test it
13  Game Development / Game Mechanics / Re: JFrame KeyListener Problem on: 2012-04-21 11:28:29
Anyone? (Please note this is for the Ludum Dare! so I kind of need it fast! Smiley )
Also I tried adding Mouse listener and it didnt work?
14  Game Development / Game Mechanics / JFrame KeyListener Problem on: 2012-04-21 08:38:06
Hi, My KeyListner is not working for my JFrame and JPanel and I can't work out why.
I am using the exact code that has worked for me before
Please help!
Here is the JFrame
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public Display() {
      setSize(640, 480);
      setTitle("Ludum Dare 23: ");
      setVisible(true);
      setResizable(false);
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      createBufferStrategy(2);
      Game game = new Game(this.getBufferStrategy());
      setFocusable(true);
      addKeyListener(new InputManager());
      add(game);
   }

Max
15  Game Development / Game Mechanics / Re: [Help] Perlin Noise for 2d tile game on: 2012-04-17 18:51:40
Thanks Cheesy
16  Game Development / Newbie & Debugging Questions / Re: I don't understand why this stutters? on: 2012-04-12 22:34:00
Hello there Smiley
I'm not sure if it's legal to post that code... I mean, it has copyrights, right?

I think Notch released it as open source
17  Game Development / Game Mechanics / Re: [Help] What engine for a 2D Game on: 2012-04-12 22:10:40
LibGDX is nice.  You can target desktop, android, and html5 with it.

Thanks
18  Game Development / Game Mechanics / [Help] What engine for a 2D Game on: 2012-04-12 21:48:31
Hi,

Recently I started developing a 2D topdown rpg. I at the moment am using slick, but wondered if there are any better engines out there.
I need it to do all the normal stuff: render tiles, play sounds etc.

Max
19  Games Center / WIP games, tools & toy projects / Re: WIP AppleBean - looking for general input on: 2012-04-11 17:18:12
Thanks. I like the crops especially! Smiley
20  Games Center / WIP games, tools & toy projects / Re: WIP AppleBean - looking for general input on: 2012-04-11 09:33:26
Did you make the graphics yourself? There great!

Yeah, I did. They're silly placeholders  Cheesy

Can't tell sarcasm, though  Clueless


No sarcasm. They just look perfect for my game so I wondered if you got them of a website, where I could use them Smiley
21  Games Center / WIP games, tools & toy projects / Re: WIP AppleBean - looking for general input on: 2012-04-10 22:01:54
Did you make the graphics yourself? There great!
22  Game Development / Game Mechanics / Re: [Help] Perlin Noise for 2d tile game on: 2012-04-10 21:23:56
I can generate noise now well , but I still can't work out how to interpret it to generate biomes and terrain? Any ideas?
23  Game Development / Game Mechanics / Re: [Help] Perlin Noise for 2d tile game on: 2012-04-10 21:18:22
You're welcome Smiley

By the way, please share your progress, I'd like to know how you implement it Smiley

Will do. Trying it out now Smiley
24  Game Development / Game Mechanics / Re: [Help] Perlin Noise for 2d tile game on: 2012-04-10 21:15:57
Thanks so much Smiley
25  Game Development / Game Mechanics / Re: 2D Tile Generation on: 2012-04-10 21:07:15
Maybe you should change the title to:
[Help] Perlin Noise for 2d tile game

Done that Cheesy
26  Game Development / Game Mechanics / Re: 2D Tile Generation on: 2012-04-10 21:06:22
Thanks, I have done this but could not find how to actually apply it to generating tiles

On the http://mrl.nyu.edu/~perlin/noise/ source, when you run the method noise what do you do with the double it returns?
27  Game Development / Game Mechanics / Re: 2D Tile Generation on: 2012-04-10 20:56:00
Anyone?
28  Games Center / Archived Projects / Re: Build & Defend -- A Tale of Survival on: 2012-04-10 16:52:54
Looks great! Can't wait to try it!
29  Game Development / Game Mechanics / [Help] Perlin Noise for 2d tile game on: 2012-04-08 14:18:23
Hello all,
I am at the moment building a top-down 2d tile rpg like game. I am currently rendering from a set map defined in a seperate file. I would like to be able to generate a world so it looks realistic but generates fast and is easy to add to later (e.g. add more tiles later to generate in subsequent updates). I have heard of perlin noise generation, but would to know your advice and how i can use it

Max
30  Game Development / Game Mechanics / Re: 2D Map Formats on: 2012-03-15 16:29:53
thanks guys Cheesy
This format is for the game reading the file from an external folder and rendering it
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.

BurntPizza (25 views)
2014-09-21 02:42:18

BurntPizza (16 views)
2014-09-21 01:30:30

moogie (19 views)
2014-09-21 00:26:15

UprightPath (26 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (44 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (100 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56

mitcheeb (71 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59: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!