Show Posts
|
|
Pages: [1]
|
|
2
|
Java Game APIs & Engines / Java 2D / Re: Big Problem with the rotate transformation.
|
on: 2008-06-28 10:28:40
|
 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
|
 hello! I'm french, so my english will not be perfect 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); c.drawImage(img, pos_X,pos_Y, pos_X+largeur,pos_Y+hauteur, 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_.
|
|
|
|
|
5
|
Java Game APIs & Engines / Java 2D / Re: Rotation driven/commanded thanks the cursor's position.
|
on: 2007-08-25 23:42:35
|
 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  ! 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...  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
|
 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=630I can?
|
|
|
|
|
8
|
Java Game APIs & Engines / Java 2D / Rotation driven/commanded thanks the cursor's position.
|
on: 2007-08-25 11:19:17
|
 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=95419But, my rotated Objet disapears when the angle is close to 45° ... I don't understand why...  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); |
 please!! help me! PS: oups, I would want to say "thanks to the cursor!": "grâce à la souris" in french.
|
|
|
|
|
10
|
Java Game APIs & Engines / Java 2D / What's the best method for a Tiled-Image?
|
on: 2007-08-24 20:51:40
|
 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...
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|