Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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]
 

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 (17 views)
2014-07-24 01:59:36

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

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

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

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

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

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

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

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

Riven (50 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!