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  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Slick texture + Phys2d polygon mapping on: 2012-05-16 21:51:00
Thank for Your's help..

Because Im not a professional developer and my game it's just only for me and for fun I did this the simplest way:

1  
poly_set  = nonConvexPoly.getVertices(nonConvexBody.getPosition(), nonConvexBody.getRotation());

this function, I guess is a bit faster than this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
    public float rotateX(float angle, float x, float y)
    {
   return ((float)Math.cos(angle) * x - (float)Math.sin(angle) * y);
    }
   
    public float rotateY(float angle, float x, float y)
    {
     return ((float)Math.sin(angle) * x + (float)Math.cos(angle) * y);
    }



Now a have another problem..

I want to rotate my texture together with my polygon, but this don't work:

1  
2  
       SlickMyGame.my_texture.rotate(nonConvexBody.getRotation());
       g.texture(slick_polygon, SlickMyGame.my_texture,1.0f,1.0f, true);




The texture is still at 90 degrees Sad
It is possible to rotate texture image ?

I load my texture image with this:
1  
SlickMyGame.my_texture = new Image("data/square.png", false, Image.FILTER_NEAREST);
2  Java Game APIs & Engines / Engines, Libraries and Tools / Slick texture + Phys2d polygon mapping on: 2012-05-14 21:46:24
Hello All:)

I have a simple question..

In my game I use Slick for graphic and Phys2d for physic simulation...

In my code part responsible for physic (Phys2d) i have code like this to create my polygon body:

            
1  
2  
3  
4  
5  
6  
7  
             static Vector2f[] nonConvexPoly = {new Vector2f(-60,-70), new Vector2f(20,-100), new Vector2f(10,0), new Vector2f(20,10), new Vector2f(-20,10), new Vector2f(-10,0)};

             polygon = new Polygon(nonConvexPoly); //Phys2d polygon
            nonConvexBody = new Body("poly", polygon, 30.0f);
             nonConvexBody.setPosition(350, 100.0f);
        world.add(nonConvexBody)
           


In my code part responsible for graphic (Slick) I have code like this :

            
1  
2  
3  
4  
5  
6  
7  
            slick_polygon= new Polygon(); // Slick polygon

            for (int i=0;i<nonConvexPoly.length;i++)
            {
               slick_polygon.addPoint(nonConvexPoly[i].getX(), nonConvexPoly[i].getY());  
            }
           


next I render(Slick) this polygon with my texture:
1  
          g.texture(slick_polygon, SlickMyGame.my_texture,1.0f,1.0f, true);


In effect, I have  "nonConvexPoly" shaped Slick texture and independent Phys2d Body :
 


How I can "glue" my Slick texture to Phys2d "nonConvexBody" ? and render this together ?
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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 (81 views)
2013-05-17 21:29:12

alaslipknot (91 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 (187 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.083 seconds with 21 queries.