Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Tank physics  (Read 3927 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Posted 2011-02-28 16:22:52 »

I'm working on this little game, where the player controls a tank in a top-down view.

First, maybe you can try what I have already, I'm using Slick + Phys2D:
http://gamadu.com/games/tankz/webstart/tankzgame.jnlp

You see how strangely it behaves, sliding etc.

The tank has two front tracks for turning, and they should have the same effect on the tanks movement like regular "wheels". Also, notice how the tank slides to the sides to the sides, not normal. Clearly I need some sort of vehicle support.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Online kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #1 - Posted 2011-02-28 16:39:41 »

link is broken
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #2 - Posted 2011-02-28 16:50:49 »

link is broken
Fixed.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2011-02-28 19:07:57 »

I don't know what physics engine could help you, but bullet has some support for 3d vehicles, so you could look at how they solve it.  I think the heart of your problem is that the friction on the wheels doesn't work right.

A hack might be to increase the friction coefficient a lot so it doesn't slide at all.  Then either have higher forces to steer the tank, or artificially reduce friction while a key is held.  If fizzy gives you enough control to specify friction coefficients for multiple directions, just increase the amount of friction that's orthogonal to the wheels which will prevent slipping but still allow it to move forward/back. This is all conjecture though, I've done a game with vehicles before.

Offline dishmoth
« Reply #4 - Posted 2011-02-28 19:37:13 »

You see how strangely it behaves, sliding etc.
Errm, no.  Sorry.  It thought it worked perfectly (and looked nice too). Undecided

I was moving/turning the tank quite smoothly with WASD, and obviously the turret follows (and fires at) the mouse pointer.  The resolution of my laptop isn't great, and I couldn't see the bottom of the window, so if there was anything happening there that I should've noticed, I didn't.

Only thing I can think of:  Is the frame rate fixed at 60/sec?  (That was what the FPS readout was saying, but I've noticed that my machine seems to run at that frame rate even if the application wants to run faster.)  And are you stepping the physics engine at the same rate as the graphics?  I understand that JBox2D(/Fizzy) prefers a fixed update rate, and if it's not getting it then that might explain the odd (machine specific?) behaviour.

If that's any help...

Simon

Offline ra4king

JGO Kernel


Medals: 336
Projects: 2
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2011-02-28 23:51:47 »

I see nothing odd at all. The game runs quite nicely and smoothly on my Windows 7 64-bit with crappy Intel GMA card.

The tank seems to get stuck (WASD doesn't work anymore) when I go beyond borders of the window.

Other than that, the graphics are quite nice!

Keep up the good work!

Offline zammbi

JGO Coder


Medals: 4



« Reply #6 - Posted 2011-03-01 00:24:12 »

Runs great here on my new laptop.

Current project - Rename and Sort
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #7 - Posted 2011-03-07 18:13:05 »

I've made some updates. (Link updated)

I replaced Fizzy with Phys2D.

Phys2D, Fizzy nor Jbox2D provide any vehicle support, and I clearly need that. Seems kind of strange there is no vehicle support for 2D games in Java?

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline lhkbob

JGO Knight


Medals: 32



« Reply #8 - Posted 2011-03-07 18:22:17 »

Most vehicle support is pretty hackish, even in 3D engines.  Try looking at how Bullet does it: http://code.google.com/p/bullet/source/browse/trunk/src/BulletDynamics/Vehicle/btRaycastVehicle.cpp

Mind you, I haven't read this code but if have more general questions about Bullet, both jezek and I have done a lot of porting work on Bullet (I'm working on my own adaptation, I've not contributed to JBullet).

Offline daif

Junior Newbie





« Reply #9 - Posted 2011-03-15 11:30:02 »

Hey there.  I've tried to play it, but it doesn't run on my machine.

Win7 pro 64bit, 4gb ram, Intel Core2Duo 3GHz

Quote
java.lang.VerifyError: class com.tankz.systems.PhysicsSystem overrides final method processEntities.(Lcom/artemis/utils/ImmutableBag;)V
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(Unknown Source)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
   at java.lang.Class.getMethod0(Unknown Source)
   at java.lang.Class.getMethod(Unknown Source)
   at com.sun.javaws.Launcher.executeApplication(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

Same on my notebook (Win 7 Home Premium, 3 GB RAM, Intel CoreDuo 1.3 GHz) btw.
Both have Java 6 (Build 1.6.0_24-b07) installed.

Am I doing anything wrong? I am pretty new to Java, JGO and everything. Smiley

Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 336
Projects: 2
Exp: 5 years


I'm the King!


« Reply #10 - Posted 2011-03-15 21:39:31 »

Quote
java.lang.VerifyError: class com.tankz.systems.PhysicsSystem overrides final method processEntities.(Lcom/artemis/utils/ImmutableBag;)V
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(Unknown Source)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
   at java.lang.Class.getMethod0(Unknown Source)
   at java.lang.Class.getMethod(Unknown Source)
   at com.sun.javaws.Launcher.executeApplication(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Hahahaha, that's what happens when you change a method to final and you don't compile its subclasses Tongue
Wait until he fixes this.

Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #11 - Posted 2011-03-16 00:39:52 »

Fixed.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline daif

Junior Newbie





« Reply #12 - Posted 2011-03-16 17:19:28 »

I like it very much. driving around and shooting feels very smooth and "realistic".

Smiley
Offline appel

JGO Wizard


Medals: 50
Projects: 4


I always win!


« Reply #13 - Posted 2011-03-16 17:54:06 »

I like it very much. driving around and shooting feels very smooth and "realistic".


It's nowhere near the "realism" I'm seeking, and I'm quite shocked that people think it feels good.

1. Shooting from the sides (tower rotated 90° relative to tank base) should not produce a recoil effect on the tank (it should not move sidewise)
2. It should not slide on the sides.
3. Turning isn't accurate, it should rotate depending on front wheels.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline daif

Junior Newbie





« Reply #14 - Posted 2011-03-16 18:39:38 »

I think I get what you mean. It feels a bit like sliding with the back, when you drive in circles.
Maybe your rear wheels should make a turn aswell? Otherwise you have to make bigger steeringcircles, which could make the game less fastpaced. But then everything (shooting, driving) should be more heavier and less agile (like the shootinganimation of the cannons, which i really like).
What do you want to achieve?

Smiley
Offline pitbuller
« Reply #15 - Posted 2011-03-31 22:04:32 »

I like it very much. driving around and shooting feels very smooth and "realistic".


It's nowhere near the "realism" I'm seeking, and I'm quite shocked that people think it feels good.

1. Shooting from the sides (tower rotated 90° relative to tank base) should not produce a recoil effect on the tank (it should not move sidewise)
2. It should not slide on the sides.
3. Turning isn't accurate, it should rotate depending on front wheels.

1. Is pretty easy task to fix. Count recoil by yourself and don't let phys2d do that for you. When creating ammo check it disabled immediatly( enabled(false) ) Then count impact only for you tank normal vector. After that enable ammo. Ugly but effective.

2. This is hard. Maybe you should use big enough friction and if you want some sliding add it by yourself only when needed.

3.  Can't figure any solution.
Offline Gudradain
« Reply #16 - Posted 2011-04-01 01:33:05 »

Strange it not always slide but it do sometimes.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

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

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

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

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

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

Riven (56 views)
2014-07-14 18:02:53
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!