Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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: Please check my *very* simple 3D physics code - its not working! on: 2012-07-17 04:24:07
bump.
still waitin'...   Emo
2  Game Development / Newbie & Debugging Questions / Please check my *very* simple 3D physics code - its not working! on: 2012-07-04 06:14:21
So I'm not exactly a whiz with physics. I did once write a 2D physics engine which, while being very messy, worked to my needs.
And when I say physics engine, I mean getting a player to jump, fall down with gravity, and land on a surface that was below it's feet.
It would've been extremely easier if I had that 2D 'physics' engine to refer to, but due to severe, irreversable stupidity, that small set of code is sitting at a computer desk about 600 kilometers away.

So here is what I have so far. I can move about on an x and z axis, detecting collisions with a cuboid. I can jump on a spot, loose upwards momentum with gravity, fall, and land. I can jump ontop of the cuboid. Observations say that my Y position stops as soon as I am above the cuboid, however, my yBottom variable does change to the correct height when atop the cuboid. I cannot jump from the cuboid, because the Y position is not the same as the yBottom. yBottom is the highest point of geometry at my x/z coordinates.

The code

If you can point out my obvious errors amongst my poorly(?) structured code and help fix my little problem, that would be great!

Thanks
3  Game Development / Newbie & Debugging Questions / Re: LWJGL - Made my first 3D world! Running into texture problems! on: 2012-04-18 04:49:30
Can you show any more code? I'd like to run it and have a stab at fixing

Oh please, stab away!

You'll need LWJGL 2.8.3 (lwjgl.jar and lwjgl_util.jar) and slick-utils.
Thanks!
4  Game Development / Newbie & Debugging Questions / Re: LWJGL - Made my first 3D world! Running into texture problems! on: 2012-04-18 01:33:10
Call floorTex.bind() before rendering the floor geometry, and wallTex.bind() before rendering the wall geometry. etc.

Textures are right on each quad, but are still skewed!

5  Game Development / Newbie & Debugging Questions / Re: LWJGL - Made my first 3D world! Running into texture problems! on: 2012-04-18 00:40:32
Slick converts textures to a power-of-two (POT) size.

Ideally you should convert your assets to a power-of-two size.

Alternatively, you could use Texture.getWidth/getHeight to determine the normalized width/height, e.g.
1  
glTextCoord2f(tex.getWidth(), tex.getHeight());


I like your thinking! Thanks for this.
I think I made it even better!
1  
GL11.glTexCoord2f(World.textureFloor.getWidth()*repeats, World.textureFloor.getHeight()*repeats);


int repeats = 1;


int repeats = 8;


While all this is great, it still doesn't solve my texture pre-binding themselves!
6  Game Development / Newbie & Debugging Questions / Re: LWJGL - Made my first 3D world! Running into texture problems! on: 2012-04-18 00:24:57
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      GL11.glVertex3f(width,0, length);
      GL11.glTexCoord2f(width, length);
     
      GL11.glVertex3f(-width,0, length);
      GL11.glTexCoord2f(-width, length);
     
      GL11.glVertex3f(-width,0,-length);
      GL11.glTexCoord2f(-width, -length);
     
      GL11.glVertex3f(width,0,-length);
      GL11.glTexCoord2f(width, -length);


texcoords are normalized, so you typically use the range 0.0 .. 1.0


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
      GL11.glVertex3f(width,0, length);
      GL11.glTexCoord2f(1.0, 1.0);
     
      GL11.glVertex3f(-width,0, length);
      GL11.glTexCoord2f(0.0, 1.0);
     
      GL11.glVertex3f(-width,0,-length);
      GL11.glTexCoord2f(0.0, 0.0);
     
      GL11.glVertex3f(width,0,-length);
      GL11.glTexCoord2f(1.0, 0.0);


(This is all done without rendering the box)

Before:


After:


I don't really know what normalized texcoords are, but from context I think it means they rangle from 0-1 (possibly -1 too).
What ever it means, it seems to just stretch the texture out over the whole quad, rather than repeating it. I think the later looks nicer.
7  Game Development / Newbie & Debugging Questions / LWJGL - Made my first 3D world! Running into texture problems! on: 2012-04-18 00:16:03
So I wrote my first 3D world in LWJGL (YEAH!), which I am very proud of, and I've just started adding textures to my lifeless world. I've had to rewrite this about 6 times now as i discover many new things/bugs about my problem. After a long analysis, it seems that my textures are binding themselves after being loaded.

1  
2  
3  
4  
5  
6  
try {
         textureFloor = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("img/floor.png"));
         textureWall = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("img/tileWall.jpg"));
      } catch (IOException e) {
         e.printStackTrace();
      }


So when the floor is rendered, textureWall is already being drawn onto it! If I comment out textureWall, and load only textureFloor, then the floor texture is drawn onto the floor. This isn't right at all! Nothing is happening to these texture objects, other than being loaded from the above code.

My Floor's class is available here

I've got another problem aswell. When I add a box (and the textures still aren't bound), it renders really weird, and makes the floor render weird aswell!



In this picture, we see the floor, and a box. As you can see, they have textures on them, that are extremely off.

Will add code if requested.

Thanks!!
8  Game Development / Newbie & Debugging Questions / Re: Viewpoint theory - Moving a small screen in a big room on: 2011-12-25 06:03:21
How about nothing "moves" at all, but rather you modify X and Y offset variables that you use when rendering.

Yea I would do that if i knew what all that meant. :3
9  Game Development / Newbie & Debugging Questions / Viewpoint theory - Moving a small screen in a big room on: 2011-12-25 05:14:05
So i've been pondering how I would go about implementing a viewport big room small screen kind of concept, and came up with a litte 'theory'.

So everything in the game will have 2 x/y variables, a "render X/Y" position, and a "real X/Y" position. When receiving input (key strokes), the object the viewport is following will be affected by having the realX/Y position changed. The renderX/Y will stay the same to keep the player in the center of the screen. It is vice versa for the 'static' objects, whose real position stays the same, but and input is received, its render position is kept.

In theory (maybe) this means that the screen will look like the player is moving around a world, when really the world is moving according to the input, but in the background, with the realX/Y coordinates, the physics is being run.

So i hope that makes sense.
:/
10  Game Development / Newbie & Debugging Questions / Re: Using threads to wake me up - Check my code please on: 2011-12-23 13:31:47
...so, did you get up on time?

Lol, sure did!
Will be using this forevar!
11  Game Development / Networking & Multiplayer / Re: Socket Programming - Not responding to multiple clients on: 2011-12-21 05:12:53
1  
            new ThreadClient(client).run();


That should be .start(), not .run() ... really common mistake with Threads, I do it all the time too.


I love you.
12  Game Development / Networking & Multiplayer / Socket Programming - Not responding to multiple clients on: 2011-12-21 02:26:54
So I was reading up on the java socket tutorials, and created a small system where a client connects to a server, then can send and receive to/from the server, using a PrintStream/BufferedReader, and a message ID system.
For example, If i wanted to say something, printStreamObject.println(5), would notify the server to expect the client to send something, so that it will receive. This can happen both ways.

It works perfectly with just one client, but with 2 clients on the same server there are problems. The second client can connect, but the server is not responding to it! Please help, this is my first time playing with networking.

Server Main class
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public class Server {

   ServerSocket server;
   
   public static void main(String[] args){
      new Server();
   }
   
   public Server(){
      try {
         server = new ServerSocket(5556);
         System.out.println("Server started");
         System.out.println("Awaiting clients");
         while(true){
            Socket client = server.accept();
            System.out.println("Client Received :: "+client);
            new ThreadClient(client).run();
         }
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
}


ThreadClient class
Full Client Side

Shot.
13  Game Development / Newbie & Debugging Questions / Re: Using threads to wake me up - Check my code please on: 2011-12-20 12:27:45
I'd do it like this :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
long startTime = System.currentTimeMillis();
long timeToWake = hours*60*60*1000 ;

while(true)
{
try
  {
  Thread.sleep(1000);
  if (System.currentTimeMillis()-startTime > timeToWake)
    break;
  }
catch (Exception e)
  {}
 
}

runtime.exec("firefox http://www.youtube.com/watch?v=CS9OO0S5w2k&ob=av3e");



It looks like it will work!
I havent really had the chance to use System.currentTimeMillis(), so can u guarantee that at some point it will just reset and return 0 later on?

Better safe than sorry.
14  Game Development / Newbie & Debugging Questions / Using threads to wake me up - Check my code please on: 2011-12-20 11:43:41
So I need to get up early tomorrow, and my alarm clock is broken, and my phone isn't too reliable. Ive turned to java for the solution. I've created a little script which i hope will get me up. I do plan to have my computer on overnight, and I plan to do so with max volume on speakers, but im still not sure if Thread can handle such a long time. Which, according to python, is up to 28800000 milliseconds (if my math is correct). The Runtime.exec() will work, i've tested that.

Please check this.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public class Wake extends Thread {

   int hours = 6;
   
   public static void main(String[] args){
      new Wake().start();
   }
   
   public void run(){
      try{
         System.out.println("Starting...");
         Thread.sleep(hours*60*60*1000);
         Runtime runtime = Runtime.getRuntime();
         runtime.exec("firefox http://www.youtube.com/watch?v=y7tI1E6kp0o");
      }catch(Exception e){
         e.printStackTrace();
      }
   }
}


Thanks.
15  Game Development / Newbie & Debugging Questions / Move from point A to point B on: 2011-12-16 19:24:57
A few things first. I've been up all night (literally) trying to figure this out. Being a 14 year old kid, this is just enraging, and I vow to not sleep until i nail this, or else leave programming for a long time. Second, I request you only give me code, if you intend to respond, do it with something that will advance my current situation.

The Problem:
How to move an object from point a to point b, bullet style.

I heard all about this atan2 magic, and if you plan to respond, do so with some explanation of this function.

Please and thank you.

edit: if no useful replys come up, i will assume that this is all impossible, and every other game does it hard coded through if statements, or pure magic.
16  Game Development / Newbie & Debugging Questions / NullPointer - cant find where its coming from!! on: 2011-12-14 06:29:48
Well, I guess the phrase "cant find where its coming from" isn't exactly right, but I just dont know why im getting this error.

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  
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
   at net.sauce.block.BlockStone.renderBlock(BlockStone.java:23)
   at net.sauce.game.Chunk.renderChunk(Chunk.java:57)
   at net.sauce.game.World.render(World.java:21)
   at net.sauce.game.GameCanvas.paint(GameCanvas.java:33)
   at javax.swing.JComponent.paintToOffscreen(JComponent.java:5124)
   at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:278)
   at javax.swing.RepaintManager.paint(RepaintManager.java:1224)
   at javax.swing.JComponent._paintImmediately(JComponent.java:5072)
   at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
   at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:785)
   at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
   at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
   at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
   at java.awt.EventQueue.access$000(EventQueue.java:84)
   at java.awt.EventQueue$1.run(EventQueue.java:602)
   at java.awt.EventQueue$1.run(EventQueue.java:600)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


My render block method:
(Line 23 is the if(e.getType...) )
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public void renderBlock(Graphics2D g) {
      if(willRender()){
         if(!getAdjacentBlocks().isEmpty()){
            for(Block e: getAdjacentBlocks()){
               if(e.getType().equals(Material.AIR)){
                  g.setColor(Color.gray);
                  g.fillRect(getRenderX(), getRenderY(), 32, 32);
               }
            }
         }
      }
   }


getAdjacentBlocks() method:
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  
public List<Block> getAdjacentBlocks(){
      List<Block> ret = new ArrayList<Block>();
      Block[][] blocks = getChunk().getBlocks();
      //UP-LEFT
      if(getGridX() != 0 && getGridY() != 0)
         ret.add(blocks[getGridX()-1][getGridY()-1]);
      //UP
      if(getGridY() != 0)
         ret.add(blocks[getGridX()][getGridY()-1]);
      //UP-RIGHT
      if(getGridY() != 0 && getGridX() != getChunk().width)
         ret.add(blocks[getGridX()+1][getGridY()-1]);
     
      //DOWN-LEFT
      if(getGridY() != getChunk().height && getGridX() != 0)
         ret.add(blocks[getGridX()-1][getGridY()+1]);
      //DOWN
      if(getGridY() != getChunk().height)
         ret.add(blocks[getGridX()][getGridY()+1]);
      //DOWN-RIGHT
      if(getGridX() != getChunk().width && getGridY() != getChunk().height)
         ret.add(blocks[getGridX()+1][getGridY()+1]);
     
      //LEFT
      if(getGridX() != 0)
         ret.add(blocks[getGridX()-1][getGridY()]);
      //RIGHT
      if(getGridX() != getChunk().width)
         ret.add(blocks[getGridX()+1][getGridY()]);
     
      return ret;
   }


From this code, I dont see how I can get this error.
17  Java Game APIs & Engines / Java 2D / Pseudo 3D...? How does it work? on: 2011-10-12 11:56:42
If you dont know, Pseudo 3D games are basically a game that looks 3d, but isnt, like Doom, or Prelude of the chambered, by Notch. s3.amazonaws.com/ld48/index.html

So im just wondering, how does it all work? Is there like a special sauce that one must understand, that is the core of fake 3d games. Im assuming that there will be ALOT of maths. Im willing to learn all this math, but there must be more than just hard math.

tl;dr:
How does pseudo (fake) 3d work, what kind of maths is involved, and how complex is the system for doing this?

shot.

edit: I just noticed how ridiculous the title "Pseudo 3D" looks in the Java2D subforum. But from viewing the code from "Prelude of the Chambered" (A pseudo 3d java game) it seems that it uses core java2d. No special API's.
18  Game Development / Game Mechanics / Re: Movement on a line on a 2D plane Help! on: 2011-10-11 15:00:09
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
   private static final void moveLine(int x1, int y1, int x2, int y2) {
      int dist = Math.max(Math.abs(x2-x1),Math.abs(y2-y1));
      float dx = (float)(x2-x1)/dist;
      float dy = (float)(y2-y1)/dist;
      float x = x1;
      float y = y1;
      for (int d = 1; d <= dist; d++) {
         x += dx;
         y += dy;
         move( (int) Math.round(x), (int)Math.round(y) );
      }
   }


Im having the same problem too. All this code works but where did the move() method come from?
Id much rather ask here than start a new thread.
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.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!