Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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: Delayed rotation on: 2012-09-28 06:49:32
Yeh, I noticed that little bug Smiley. Gonna try and fix it by myself Tongue. Thank you very much again Smiley
2  Game Development / Newbie & Debugging Questions / Re: Delayed rotation on: 2012-09-27 23:04:25
Haha

Well you have this.angle.
You could make another variable this.currentangle

then use something like this:

1  
2  
3  
4  
5  
6  
7  
8  
float diff = this.angle - this.currentangle;
if(diff < 0){ diff += (float)Math.PI * 2; }

if(diff < Math.PI){
    this.currentangle += 0.01f;
}else{
    this.currentangle -= 0.01f;
}


You check the diffrence between the current and the destination angle.
If its close to the right, move right, else move left.

I always mess up + and - so you might need to switch the variables Smiley

Thanks dude! That works veeery nicely! Smiley
3  Game Development / Newbie & Debugging Questions / Re: Delayed rotation on: 2012-09-27 22:56:41
Haha

Well you have this.angle.
You could make another variable this.currentangle

then use something like this:

1  
2  
3  
4  
5  
6  
7  
8  
float diff = this.angle - this.currentangle;
if(diff < 0){ diff += (float)Math.PI * 2; }

if(diff < Math.PI){
    this.currentangle += 0.01f;
}else{
    this.currentangle -= 0.01f;
}


You check the diffrence between the current and the destination angle.
If its close to the right, move right, else move left.

I always mess up + and - so you might need to switch the variables Smiley

Heh okay thx. That's seems easier Smiley
4  Game Development / Newbie & Debugging Questions / Re: Delayed rotation on: 2012-09-27 20:15:24
Ugh, dunno how to implement this....
5  Game Development / Newbie & Debugging Questions / Re: Delayed rotation on: 2012-09-27 18:20:06
Well thanks Smiley, I will take a look at it
6  Game Development / Newbie & Debugging Questions / Delayed rotation on: 2012-09-27 18:06:48
Hi there all

This is my first post and don't care about my spelling, English is not my native
language Smiley.

So I'm creating just a little tank game, everything is fine, tank is moving and cannon turning.

The problem is

1  
2  
3  
4  
5  
6  
7  
   
public void setDirection(float x, float y) { // parametres are mouse x,y
     
   float rx = x - this.getX();
   float ry = y - this.getY();
   this.angle = (float)Math.atan2(ry, rx); // cannon angle
}


This rotates the cannon okay, but, I would like to have some kind of delay to that turning (I mean, now
it's instant.
How is such a thing even possible? Somehow with delta time? I suck at math and physics sooo. Smiley

Well, if someone could help, I would really appreciate that!

Thanks in advance Smiley

edit. I try to explain better...

The cannon is now facing direction x,y
When I move the mouse, the facing direction changes of course to nx,ny.
I want it to be so that cannon slowly rotates to the new facing direction... Smiley
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (79 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (122 views)
2013-05-16 00:53:38

gouessej (114 views)
2013-05-16 00:17:58

theagentd (126 views)
2013-05-15 15:01:13

theagentd (113 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.106 seconds with 21 queries.