Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
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  Java Game APIs & Engines / Java 2D / Re: Big Problem with the rotate transformation. on: 2008-06-28 10:48:32
 Grin yeeeeeeeeeeeeeeeeaaahh!!! it's a success!!  Roll Eyes  i have searched in a long time :s and it was very simple :s i didn't update the center of my bullet, so when java wanted to rotate my bullet by its center,  it rotate by a fixed point whereas my bullet was moving Smiley

thanks for you help!
2  Java Game APIs & Engines / Java 2D / Re: Big Problem with the rotate transformation. on: 2008-06-28 10:28:40
 Smiley thanks!

I know this technique, and I have tried it: but result is the same. It don't resolve the rotation of the bullet's orthogonal frame :s
But, if it's better at a programing point of view (i can say this in english?), I will re-write my code with it.

So, i believe that my problem come from of a no-update of the cent_X an cent_Y variables (i'm a scatter brain). Despite that this update won't resolve rotation of the orthogonal frame , in according with my calculation, the bullet's bouncing will work.

 I'm going to try and i come back.
3  Java Game APIs & Engines / Java 2D / Big Problem with the rotate transformation. on: 2008-06-27 11:49:58
 Smiley hello!
I'm french, so my english will not be perfect Smiley

I make a game with Java and its API Java2D. With this, I rotate my objects, a bullet _ which must take a direction so as to its head is toward the target_ . I use this way:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
                        c.rotate(rt, cent_X, cent_Y); 
         
         c.drawRect(X_MIN, Y_MIN, X_MAX, Y_MAX); // it's a rectangle for checking
       
         c.drawImage(img,
            //possition/placement de l'image:            
           pos_X,pos_Y,
            pos_X+largeur,pos_Y+hauteur,
           
            //choix de la sous-image:
           f_base,0,
            (saut_pixel+f_base),hauteur,null);
         
         
         c.rotate(-rt, cent_X, cent_Y);


The bullet is rotated in the well direction but, its orthogonal frame is changed too. Thus, when I check the bounce with the screenborders, there is error, "the screenborders of the bullet" have rotated.

In fact, the bullet bounces on the Rectangle(X_MIN,Y_MIN,X_MAX,Y_MAX) that i draw "for checking" during the Graphics2D rotation and not on the true BorderScreen.

I don't know if i was clear, but this problem is very strange.

If you want, I can give a .jar so as to you see my problem.

Edit: the "c" is a Graphics2D used by my Sprite.

re-Edit: it's all the more strange that my Object Tank don't pose problem when I rotate it by the same way. This tank move in four directions only (up, down, right, left), so its rotation's angle takes 0, 90, 180, 270 degres value. And these rotations don't pose problem _  visible problem would be more right_.
4  Java Game APIs & Engines / Java 2D / Re: Rotation driven/commanded thanks the cursor's position. on: 2007-08-26 21:26:14
 Huh hu!... oups, I didn't know that.

To end, I have try my technique with yours correction and it works!! It's very cool, because I thought I have made a mistake in my calculations!  Now, I know I don't have made mistake but I will use the "atan2" method.

So, I can close this topic !!

Merci!  Wink

5  Java Game APIs & Engines / Java 2D / Re: Rotation driven/commanded thanks the cursor's position. on: 2007-08-25 23:42:35
 Grin WAAAAAAAAAAAAWOUUUUUHHH!! Finally, I have tried the "atan2" method and it's fantastic, you don't know how I'm happy!!

Really, Thanks you oNyx! I don't have enough vocabullary in english so as to show my gratitude but in short: "Youpiiiii!!!!".

As for the ^ operator... I'm sorry, I don't understand  " a bitwise XOR function" :s and I would like understand because I would like undestand why my code must not work.

In any case, Thank you for this precision: I will try if my code works with a "adj*adj" and "opp*opp" instead of "adj^2" and "opp^2" even if the method of "atan2" is better than mine. I just want to see if my method could have functioned...

Re-good night!  Thank you Riven and oNyx.
6  Java Game APIs & Engines / Java 2D / Re: Rotation driven/commanded thanks the cursor's position. on: 2007-08-25 23:05:06
 Thanks  Smiley ! it's a very good method which help me. But... the center of the Default Locate ("repère" in french, I'm not sure that it's the good word, sorry) is in the upper-left corner of the screen. I will try to put my "adj" and "opp" in the "atan2" metod.

But is it possible to set the center of the Locate on my tank's position?

I'm going to try the "atan2" method tomorow, it may be the solution that I search...   Undecided I'm so tired, I don't really suceed in thinking this evening, hihi !

re-Thanks and good night!
 
7  Java Game APIs & Engines / Java 2D / Re: What's the best method for a Tiled-Image? on: 2007-08-25 12:26:39
 Cheesy hihi, merci infiniment CommanderKeith!
 In this forum, you seem more friendly than on some French Forum.

I endeavour speak Englisk as well as I could. But, if someone understands French, I can write the French traduction below my English sentences for your own training.

I will use the meth' drawImage() as you advised me, thanks! If you have the time, I have posted a other topic.

For each topic here, I woul like poste a traduction of your solution on this French Forum in order to help the French beginner:
http://www.developpez.net/forums/forumdisplay.php?f=630

I can?
8  Java Game APIs & Engines / Java 2D / Rotation driven/commanded thanks the cursor's position. on: 2007-08-25 11:19:17
 Smiley I don't know I'm allowed to post two topic in the same time... if I'm not, I'm very sorry :s !

I am a new problem, lol!

I try to make a game with tanks. It's a 2D game, and I use a upper view (I don't know if I use the good words, I'm sorry) I have done a target so as to aim at ennemy but the tank's cannon must be rotated toward the target.

I have used my Pythagore and "trigonometrie" knowledge in order to get the angle created by the horizontal axe and the axe formed by the position point of tank and position point of cursor, as is shown on the following page:

http://www.developpez.net/forums/showthread.php?t=95419

But, my rotated Objet disapears when the angle is close to 45° ... I don't understand why...  Huh

Here is the part of my code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
 int adj = cible_X-tank_X;
      int opp = cible_Y-tank_Y;
      double hyp = (adj^2+opp^2)^(1/2);
      double cosi_a = Math.abs(adj/hyp);
      double angl =  Math.acos(cosi_a);
      double pi = Math.PI;
      double angle = 0;
       
      if (adj<0 && opp<0){angle= angl + pi;}
      if (adj>0 && opp<0){angle= -angl;}
      if (adj<0 && opp>0){angle= -(angl + pi);}
      if (adj>=0 && opp>=0){angle= angl;}
         c.setColor(new Color(100,60,80));
         c.rotate(angle,tank_X,tank_Y);
         c.drawRect(tank_X-40,tank_Y-30,80,60);


 Cry please!! help me!

PS: oups, I would want to say "thanks to the cursor!": "grâce à la souris" in french.
9  Java Game APIs & Engines / Java 2D / Re: What's the best method for a Tiled-Image? on: 2007-08-25 10:48:23
 Cheesy WaWoouuuhh!! I was understood!!! lol Smiley I'm very happy: my english may be comprehensible!

Thank you BroumBroum. I don't know if I'm going to use Java Advanced Imaging... I'm a beginner in progra...

We can make Sprites easily with JAI's API?

re- thank you!  I'm very happy  Smiley !!
10  Java Game APIs & Engines / Java 2D / What's the best method for a Tiled-Image? on: 2007-08-24 20:51:40
 Smiley hi! I'm a french guy...  and I have need to be advised.

I know I'm not the best English Speaker of the World, so I beg to be excued for my  low level in english.

In fact, I have gone in a french forum where someone advised me to go here so as to find the solution of my problem.

My prob is the following:

I would make a java-game and I have to make Sprite, I succeeded in implementation of frame animation in my sprites: I use a big Image where I placed the different sub-image which will be used by the sprite so as to animates itself.

But I have found two, even three solution:

-the method: Graphics.drawImage(Image img, int dstx1, int dsty1, int dstx2, int dsty2, int srcx1*, int srcy1, int srcx2*, int srcy2, ImageObserver observer);

-the method: BufferedImage.getSubImage();

-and the method: CropImageFilter.

I would like know what's the most performant method.

I have realized some test, and it seems that BufferedImage add a time of loading (and lot of lines in the code, hihi!! :p ).
But I don't know if this detail is important...

   

 
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.

xsi3rr4x (28 views)
2014-04-15 18:08:23

BurntPizza (25 views)
2014-04-15 03:46:01

UprightPath (40 views)
2014-04-14 17:39:50

UprightPath (22 views)
2014-04-14 17:35:47

Porlus (38 views)
2014-04-14 15:48:38

tom_mai78101 (62 views)
2014-04-10 04:04:31

BurntPizza (121 views)
2014-04-08 23:06:04

tom_mai78101 (221 views)
2014-04-05 13:34:39

trollwarrior1 (188 views)
2014-04-04 12:06:45

CJLetsGame (195 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!