Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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 ... 13
1  Discussions / Miscellaneous Topics / Re: Quad core + 2gb of ram on: 2014-05-30 13:32:42
I would not recommend having less than 4 gigs of memory. If you want to do a lot of multitasking, then you will be hitting that 2 gig limit all the time.

Seconding this. I use at least 6GB of RAM at all times while programming & working on side projects.
2  Game Development / Newbie & Debugging Questions / Re: Background image on: 2014-05-27 19:04:10
"Fit in memory" means that the map is small enough to be loaded all at once without much, if any, culling. For large maps you need to use culling to make sure that the game doesn't end up hogging all of the system resources.

Just think about how to make the map and all that work. If you draw it out and that then you'll figure it out eventually. That's how I ended up getting it at least.
3  Game Development / Newbie & Debugging Questions / Re: [solved] How to have multiple tiles a player can't go through? on: 2014-05-19 00:30:10
In response to Rayvolution's post... You don't need to do any libGDX or slick2d specific collision detection classes. Just use the Rectangle class that already exists in Java and work with it. Saves you from having to learn a lot more and it'll work well enough for most purposes.
4  Game Development / Newbie & Debugging Questions / Re: How to have multiple tiles a player can't go through? on: 2014-05-18 11:15:13
Just use Rectangles and check for intersection.
5  Discussions / General Discussions / Re: Is it just me, or does everyone's GUI code look like spaghetti? on: 2014-05-15 18:49:27
For checking if the mouse is hovering over something. Why not just use Rectangles and detect intersection? That's what I do to make my custom buttons work.
6  Game Development / Newbie & Debugging Questions / Re: How do you load and setup your levels/menus? on: 2014-05-15 04:58:10
well menus are hardcoded - what do you load ?

as for maps I just developed a map editor which serializes using kryo the map and can load it again.
Never that simple but yeah. short answer is write a parser or use serialization.

what exactly are you saving/loading ?

I wrote a simple framework for custom interface components. As a simple example... When creating a button I need to load the X/Y coordinates of the button along with three sprites for the default, clicked, and hovered states of the button. The same thing applies to all tiles, NPCs, etc... in the game. To make it really simple. Almost nothing is hard-coded with the way I have it set up. A few things will probably have to be hard-coded eventually, but everything is just "load-n-go" atm.

Your serialization idea sounds like a simple solution even though it would require a fair bit of extra work to setup at first. Thanks, I'll look into it.
7  Discussions / General Discussions / Re: New Personal Virtual Reality Headset System – ANTVR KIT on: 2014-05-15 03:20:28
Why isn't wireless energy transmission mainstream yet? This is exactly the type of thing to use it for.

Don't quote me on this, but from what I remember... The further the energy needs to be transmitted the higher the loss of energy. So it's pretty much only useful for short-distance transmission which cuts out a lot of the customer base (businesses and stuff like that) and so there is less demand for the technology. This causes the cost of production to go up and make using wireless energy more expensive which then stops people from using it.

Hopefully that makes some sense. I tried to remember what I read about this from a thread on Reddit a while back.
8  Game Development / Newbie & Debugging Questions / How do you load and setup your levels/menus? on: 2014-05-15 03:14:35
Hey,

I've been trying to think of a good, and simple, way to load all the information (data  in text files, sprites, etc...) and setup levels/menus for my game. So-far I've managed to write up a few different methods for to load all of the files and then convert those files into Entities, interface pieces, etc... Although all of the ways I've tried do end up working to some degree, the code is an utter train-wreck compared to how nice and neat the rest of my code is. It'd probably be easier if I wanted to code more of the data and that in, but I'm trying to set it up so that you just need to have the right folder structure and files to load anything into the game.

Since it wont hurt to ask, how do you load your levels, menus, and whatever else?

9  Game Development / Newbie & Debugging Questions / Re: save game-- how to on: 2014-05-14 02:30:09
Serialization seems the easiest route to me. It's prettyeasy to figure out and not too tough to implement if you code with it in mind.
10  Game Development / Newbie & Debugging Questions / [Java2D] Need some explanation on an old tutorial. on: 2014-05-12 19:52:26
Hey,

I'm trying to rewrite the game loop that I've been using for every single project I've made recently, but some information in the tutorial isn't very clear to me. Could someone explain why, in the variable timestep game-loop, the number 1000000000 is used and whether or not delta actually matters at all.

Throughout everything I've made with the variable timestep game-loop, I've never used delta and everything has worked just as it should. The one time where I did do a quick experiment by using delta in my particle system, everything went haywire and the particle movement bugged out. This leads me to believe that the delta variable doesn't need to be used.

Oh, one additional question. Is there a simpler game-loop that can be used which performs the same as the variable timestep game-loop in this tutorial?

The variable timestep game-loop was taken from this tutorial: http://www.java-gaming.org/index.php?topic=24220.0


Thanks for any help.
11  Discussions / Miscellaneous Topics / Re: What do you develop your games on? on: 2014-05-11 04:16:08
Laptop with:

  • 2x Nvidia GeForce GT 650m
  • 16GB RAM
  • Intel i7 CPU
  • Two monitors (1920x1080)
  • About 6TB HDD space, soon to be 8 or 10. (Mostly always-attached external HDDs)
  • Windows 8.1 x64
12  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 21:27:27
Thanks for the help Phil. I have the code looking similar to what you put, but I kept it closer to my original way so that the transition looks better.

1  
2  
3  
4  
5  
6  
if(counter == 10) {
         for(int i=0;i<RANDOM.nextInt(1800) + 120;i++) { newParticle(new Color(red/255f, green/255f, blue/255f, 1.0f), RANDOM.nextInt(8) + 2, 40); }
         counter = 0;
      } else {
         counter++;
      }



Working for up to 200k particles, when I hit 300k it slows down to a snails crawl.
13  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 21:03:59
You should have between 120 to 1920 particles every time the counter hits 10. They all use the same color object so 1 color.

Annnd after a second I thought that since they were all referring to the same color object then I just changed it to create a new color object for every single particle and it was fixed. Never had this bug with the non-libGDX version.
14  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:54:00
I have the code modified to test with a single snowflake on the screen. The numbers just reduce down to almost 0.0, and before it can get to 0.0 it's removed just as it should be.

http://pastebin.com/WsGXAp4K

I assume that you're testing with the unmodified code which would have a ton of snowflakes falling at once and not show the numbers going straight down.
15  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:47:45
Had it slightly different. Yeah, the values are always the same when I change it to how you've written it. Still looks like it's working properly.

16  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:37:06
No idea what a quad is, just started with libGDX a few hours ago.

May I direct you to the recent OGL tut by SHC outlining the basics of what goes on 'under the covers' of libGDX:
http://www.java-gaming.org/topics/lwjgl-tutorial-series-the-opengl-rendering-pipeline/32661/view.html

Thanks, I'll check it out in a few minutes.
17  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:28:56
It took me 1.3 hours to find it, I love debugging. Indeed I just hate to not know the solution  Roll Eyes
So I will go for a quizz  Grin
(No that's not because I am evil, that's just how some other guy helped me and you learn most)
First hint:
You create an object but you don't use it every time you create it.


The Color object in the update() method of the RainbowSnow class? Moving that within the if statement gives no change.
18  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:23:44
What do you think that rectangle is? A quad perhaps? Hmm...

A point combined with a width and height that's sent somewhere as an instruction for which pixels on the screen to color. No idea what a quad is, just started with libGDX a few hours ago.
19  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 20:15:40
Disable all texturing and coloring and see if the actual geometry disappears. That way you can rule out a lot of stuff.

Huh? There are no textures or geometry. I'm just drawing rectangles on the screen using rgba colors and a ShapeRenderer object.
20  Discussions / General Discussions / Re: [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 18:48:12
Fading out and them removing I guess?

If the rgb color values go < 0, they reset to 1.

This could be it.

The rgb colors should never go below 0 with the way I have it set up. I'll double check that though.

Edit:
It doesn't seem to be related to the rgb values as far as I've seen in my tests.
21  Discussions / General Discussions / [LIBGDX] Particles disappearing and then reappearing on: 2014-04-05 18:13:09
Hey,

I've just, hopefully, finished converting my particle system from pure Java to libGDX. Everything seems to be working properly, except for the 'death' of the particles. The particles die and then reappear, or so it seems, for some reason unknown to me.

Each particle starts with a certain lifetime, and each update to the particle decreases the remaining lifetime. The alpha of the particle is calculated using (float)(remainingLife/totalLife). When the lifeTime reaches 0 then the particle is deleted because it's alpha is 0.

Here's the compiled project, you can see how the particles disappear and reappear. Exit with Alt+F4.
https://mega.co.nz/#!IstGjR6b!VZCkZ9ClDBUedZLHIPnchx9thb4Gs_asFvnlZpX7qo8



I'm thinking that the error is in how I setup libGDX in the Driver/Main classes, but it could also be with how I set the color/alpha in the RainbowSnow/Particle classes. Normally I'd be able to figure this kind of thing out pretty quickly, but I barely know how to use libGDX atm. Thanks for any ideas.

Driver:
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 core.desktop;

import java.awt.Dimension;
import java.awt.Toolkit;

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

import core.Main;

public class DesktopLauncher {
   public static void main (String[] arg) {
      Dimension screenDimensions = Toolkit.getDefaultToolkit().getScreenSize();
     
      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
      config.title = "Particle System";
      config.width = (int)screenDimensions.getWidth();
      config.height = (int)screenDimensions.getHeight();
      config.fullscreen = true;
      config.useGL30 = true;
     
        new LwjglApplication(new Main(), config);
   }
}


Main:
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  
package core;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

import effect.Effect;
import effect.RainbowSnow;

public class Main extends ApplicationAdapter {
   Effect e;
   ShapeRenderer shapeRenderer;

   @Override
   public void create() {
      e = new RainbowSnow(0.0, Gdx.graphics.getHeight() + 50, Gdx.graphics.getWidth());
      shapeRenderer = new ShapeRenderer();
   }

   @Override
   public void render() {
      ((RainbowSnow)e).update();
     
      Gdx.gl.glClearColor(0, 0, 0, 0);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     
      ((RainbowSnow)e).render(shapeRenderer, e.getIsOval());
   }

   @Override
   public void resize(int width, int height) {
   }
   
   @Override
   public void pause() {
   }

   @Override
   public void resume() {
   }

   @Override
   public void dispose() {
   }
}


Effect:
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  
package effect;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import particle.Particle;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;

public class Effect {
   protected final static Random RANDOM = new Random();
   /** A collection of particles that make up the snow.*/
   protected final List<Particle> PARTICLES = new ArrayList<Particle>();
   /** The origin of this snow on the X-axis.*/
   protected final double ORIGIN_X;
   /** The origin of this snow on the Y-axis.*/
   protected final double ORIGIN_Y;
   /** Whether or not to render the particles as ovals. If not then render as squares. Ovals are extremely CPU intensive for large effects*/
   protected final boolean IS_OVAL;
   protected Iterator<Particle> iterator;
   protected int counter = 0;
   
   public Effect(final double ORIGIN_X, final double ORIGIN_Y, final boolean IS_OVAL) {
      this.ORIGIN_X = ORIGIN_X;
      this.ORIGIN_Y = ORIGIN_Y;
      this.IS_OVAL = IS_OVAL;
   }
   
   /**
    * Updates the effect.
    */

   public void Update() {}
   
   /**
    *  Renders the snow to the screen.
    * @param g Graphics object with which to draw.
    */

   public void render(final ShapeRenderer SHAPE_RENDERER, final boolean IS_OVAL) {
      if(counter == 0) { System.out.println(PARTICLES.size()); }
     
      Gdx.gl.glEnable(GL30.GL_BLEND);
      Gdx.gl.glBlendFunc(GL30.GL_SRC_ALPHA, GL30.GL_ONE_MINUS_SRC_ALPHA);
      SHAPE_RENDERER.begin(ShapeType.Filled);
      iterator = PARTICLES.iterator();
      while(iterator.hasNext()) {
         iterator.next().render(SHAPE_RENDERER, IS_OVAL);
      }
      SHAPE_RENDERER.end();
      Gdx.gl.glDisable(GL30.GL_BLEND);
   }
   
   /** @return Whether or not to render the particles as ovals. If not then render as squares. */
   public boolean getIsOval() { return IS_OVAL; }
}


RainbowSnow:
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  
package effect;


import com.badlogic.gdx.graphics.Color;

import particle.Particle;

/**
 * Represents rainbow snow fall.
 * @author Valkryst
 * --- Last Edit 05-Apr-2014
 */

public class RainbowSnow extends Effect {
   /** The length (x-axis) of the screen. */
   private final double SCREEN_LENGTH;
   private final double COLOR_CHANGE_CONSTANT = 0.25;
   private float red = 255, green = 0, blue = 0;
   private boolean isRed = false, isGreen = true, isBlue = false;
   
   /**
    * Constructs a new Snow object.
    */

   public RainbowSnow(final double ORIGIN_X, final double ORIGIN_Y, final double SCREEN_LENGTH) {
      super(ORIGIN_X, ORIGIN_Y - 50, false);
      this.SCREEN_LENGTH = SCREEN_LENGTH;
   }
   
   /**
    * Updates the snow.
    */

   public void update() {
      Color c = new Color();
      c.set(red/255f, green/255f, blue/255f, 1.0f);

      if(counter == 10) {
         for(int i=0;i<RANDOM.nextInt(1800) + 120;i++) { newParticle(c, RANDOM.nextInt(8), 40); }
         counter = 0;
      } else {
         counter++;
      }
     
      if(isRed) {
         if(blue > 0) { blue -= COLOR_CHANGE_CONSTANT; }

         if(red < 255) {
            red += COLOR_CHANGE_CONSTANT;
         } else if(red == 255 && blue == 0) {
            isRed = false;
            isGreen = true;
         }
      } else if(isGreen) {
         if(red > 0) { red -= COLOR_CHANGE_CONSTANT; }
         
         if(green < 255) {
            green += COLOR_CHANGE_CONSTANT;
         } else if(green == 255 && red == 0) {
            isGreen = false;
            isBlue = true;
         }
      } else if(isBlue) {
         if(green > 0) { green -= COLOR_CHANGE_CONSTANT; }
         
         if(blue < 255) {
            blue += COLOR_CHANGE_CONSTANT;
         } else if(blue == 255 && green == 0) {
            isBlue = false;
            isRed = true;
         }
      }

      iterator = PARTICLES.iterator();
      while(iterator.hasNext()) {
         if(iterator.next().update()) {
            iterator.remove();
         }
      }
   }
   
   /**
    * Creates a new Particle object.
    * @param sizeIn The size, in pixels^2, of the new Particle.
    * @param decayTimeIn The number of movements before the new Particle decays.
    */

   public void newParticle(final Color COLOR, int SIZE, int LIFE) {
      PARTICLES.add(new Particle(RANDOM.nextInt((int)SCREEN_LENGTH), super.ORIGIN_Y, RANDOM.nextDouble() * (RANDOM.nextBoolean() ? -2 : 2), RANDOM.nextDouble() * -2.5, 0.0050 *(RANDOM.nextBoolean() ? -1 : 1), 0.0, SIZE + RANDOM.nextInt(8), LIFE + RANDOM.nextInt(800), COLOR));
   }
}


Particle:
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  
package particle;

import java.awt.Dimension;
import java.awt.Toolkit;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

/**
 * Represents a particle in 2D space.
 * @author Valkryst
 * --- Last Edit 05-Apr-2014
 */

public class Particle {
   private final static Dimension SCREEN_DIMENSIONS = Toolkit.getDefaultToolkit().getScreenSize();
   /** The location of the particle on the X-axis. */
   private double x;
   /** The location of the particle on the Y-axis. */
   private double y;
   /** The change in X, per update, of the particle. */
   private double dx;
   /** The change in Y, per update, of the particle. */
   private double dy;
   /** The gravitational pull to the left (negative) and right (positive) acting on this particle. */
   private final double GRAVITY_X;
   /** The gravitational pull to the up (negative) and down (positive) acting on this particle. */
   private final double GRAVITY_Y;
   /** The size in pixels^2 of the particle. */
   private final int SIZE;
   /** The remaining lifetime of the particle. */
   private double currentLife;
   /** The total lifetime of the particle. */
   private final double TOTAL_LIFE;
   /** The color of the particle. */
   private Color color;
   
   /**
    * Constructs a new particle with the specified data.
    * @param X The location of the particle on the X-axis.
    * @param Y The location of the partivcle on the Y-axis.
    * @param DX The change in X, per update, of the particle.
    * @param DY The change in Y, per update, of the particle.
    * @param GRAVITY_X The gravitational pull to the left (negative) and right (positive) acting on this particle.
    * @param GRAVITY_Y The gravitational pull to the up (negative) and down (positive) acting on this particle.
    * @param SIZE The size in pixels^2 of the particle.
    * @param LIFE The remaining lifetime of the particle.
    * @param COLOR The color of the particle.
    */

   public Particle(final double X, final double Y, final double DX, final double DY, final double GRAVITY_X, final double GRAVITY_Y, final int SIZE, final double LIFE, final Color COLOR) {
      x = X;
      y = Y;
      dx = DX;
      dy = DY;
      this.GRAVITY_X = GRAVITY_X;
      this.GRAVITY_Y = GRAVITY_Y;
      this.SIZE = SIZE;
      currentLife = LIFE;
      TOTAL_LIFE = LIFE;
      color = COLOR;
   }
   
   /**
    * Updates the particle's position, change in x, change in y,
    * remaining lifetime, and color.
    * @return Whether the particle is 'dead' or not.
    */

   public boolean update() {
      if(x > SCREEN_DIMENSIONS.width + 32 || x < -32 || y > SCREEN_DIMENSIONS.height + 32) {
         return true;
      } else {
         x += dx;
         y += dy;
         dx += GRAVITY_X;
         dy += GRAVITY_Y;
         currentLife--;
         color.set(color.r, color.g, color.b, (float)(currentLife/TOTAL_LIFE));
         return (currentLife <= 0 ? true : false);
      }
   }
   
   /**
    * Renders the particle to the screen.
    * @param G The shaperenderer object to render with.
    * @param IS_OVAL Whether or not to render the particle as an oval.
    */

   public void render(final ShapeRenderer SHAPE_RENDERER, final boolean IS_OVAL) {
      SHAPE_RENDERER.setColor(color);

      if(IS_OVAL) {
         SHAPE_RENDERER.circle((int)x-(SIZE / 2), (int)y-(SIZE / 2), SIZE, SIZE); //x-(size/2) & y-(size/2) make sure the particle is rendered at (x, y).
     } else {
         SHAPE_RENDERER.rect((int)x-(SIZE / 2), (int)y-(SIZE / 2), SIZE, SIZE); //x-(size/2) & y-(size/2) make sure the particle is rendered at (x, y).
     }
   }
}



Edit:
Ignore the JavaDocs if they don't make sense. I haven't updated them recently.
22  Game Development / Newbie & Debugging Questions / Re: Problem with Writing text to a File on: 2014-03-31 00:28:14
To print to text file:
1  
2  
3  
4  
5  
6  
7  
8  
9  
public static void writeText(String[] text) {
   try {
       PrintWriter out = new PrintWriter((new FileWriter("blahblahblah.txt", false));
       for(String s : text) { out.println(s); }
       out.close();
   } catch (IOException e) {
       e.printStackTrace();
   }
}


There is also a 1 liner to read an entire text file at once into a String array, but I can't seem to find it atm. Something to do with NIO.
23  Game Development / Newbie & Debugging Questions / Re: Troubles Implementing Map Scrolling on: 2014-03-30 14:58:28
=O

I was just messing around with the code while writing a reply about it almost working and it worked. I just combined the ideas in ctomni's code and what Liquid said in his comment and now it works perfectly!
24  Game Development / Newbie & Debugging Questions / Re: Troubles Implementing Map Scrolling on: 2014-03-29 18:57:41
Why do you "set back" player position, if you didn't change it in the first place?

Because it just updates the player's position after figuring out how much to scroll the map so that the player's position won't change on the map when it scrolls to show the next bit of the map. The user controls the player's movement.
25  Game Development / Newbie & Debugging Questions / Re: Troubles Implementing Map Scrolling on: 2014-03-29 18:23:41
I don't.

Whenever the player's x position is greater than half of the screen it does (playerX - halfScreenWidth) to find the difference. Then subtracts that from the xOffset. Next, the player's position is set back to halfScreenWidth so that it lines up with where it was before the map was moved back by the xOffset.

26  Game Development / Newbie & Debugging Questions / Re: Troubles Implementing Map Scrolling on: 2014-03-29 18:09:37
You just said in your post that player gets thrown into tiles and cannot move. I assume you said it, because that didn't happen before you implemented map scrolling. That means your map scroll affects how player moves.

Yes, and that has nothing to do with rendering. The problem is in the map scrolling code in the OP which is part of the updating and not the rendering. If you look at the code it simply moves the player backwards, or at least it should, so that it lines up to it's position from before the scroll.
27  Game Development / Newbie & Debugging Questions / Re: Troubles Implementing Map Scrolling on: 2014-03-29 17:57:10
If a player is thrown into a tile, because of how you're rendering things, you must be doing something wrong.

It has nothing to do with the rendering.
28  Game Development / Newbie & Debugging Questions / [SOLVED] Troubles Implementing Map Scrolling on: 2014-03-29 16:11:57
Hey,

I'm currently attempting to add in map scrolling to a basic platformer I'm working on. I worked out a good idea of how it works, but every time I try to implement map scrolling it never works properly.

The player is 32 pixels wide and 64 pixels tall.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
///////// WIP - Screen scrolling code.
     double playerX = ((Player)ENTITIES.get(0)).getX();
      double halfScreenWidth = (SCREEN_DIMENSIONS.getWidth()/2);

      if(playerX > halfScreenWidth) {
         double distanceFromHalfScreenWidth = playerX - halfScreenWidth;
         offsetX -= distanceFromHalfScreenWidth;
         ((Player)ENTITIES.get(0)).setX(halfScreenWidth - distanceFromHalfScreenWidth); // Rest works, no idea what to set X to atm.
     } else {
         offsetOldX = offsetX;
      }
      /////// End of WIP


This is what I'm currently using. It does scroll the map to the left, but it does this:

Click to Play


I've modified the code above in many ways, but only the current code has resulted in anything close to working properly.  The screen seems to scroll too far and the player is often thrown inside of a tile where it's not allowed to move. If anyone has an idea of what I may have messed up on in the code that would help a lot.
29  Discussions / General Discussions / Re: How to make a JFrame's background transparent? on: 2014-03-23 18:40:50
I've looked into something like this before. There's a way to do it, but it's very buggy and just not worth using at all.
30  Games Center / Contests / Re: Closed Nobody Joined as i know on: 2014-03-22 14:29:20
Done

1  
2  
3  
4  
5  
6  
7  
public class Driver {
    public static void main(String args[]) {
        while(true) {
            System.out.println("You're terrible at this game, quit already.");
        }
    }
}
Pages: [1] 2 3 ... 13
 

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

The first screenshot will be displayed as a thumbnail.

atombrot (21 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (28 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (65 views)
2014-08-03 02:57:17
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!