Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 20, 2013 7:28 am

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Tue Sep 04, 2012 6:05 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
Hi Slick Forum!
In order to build a small lightning system I want to edit my tiles. Therefore I want to read the single sprites.

For testing I tried this line in my rend method:
Code:
Sheet.getSprite(int,int).draw(int, int);


The result:
Attachment:
Bildschirmfoto 2012-09-04 um 19.51.33.jpg
Bildschirmfoto 2012-09-04 um 19.51.33.jpg [ 172.13 KiB | Viewed 543 times ]

It seems that the pixel which are normally not visible are now at the top left corner. Even the FPS display moves. (please ignore scaling differences in the images)

This works fine:
Code:
Sheet.renderInUse(int,int,int,int);

The result:
Attachment:
Bildschirmfoto 2012-09-04 um 19.29.33.jpg
Bildschirmfoto 2012-09-04 um 19.29.33.jpg [ 161.49 KiB | Viewed 543 times ]


In which points are they different? It makes no different if I use getSprite or getSubImage. My parameters are okay, because before using sprites I used to do it with "image.draw()" and it worked fine. I wonder because the getSprite function returns "image" and my source is fine as the second example shows.
Is it a bug?
Which causes this behavior?
I hope you can help me.

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Wed Sep 05, 2012 6:58 am 
Offline
Regular

Joined: Sun Oct 30, 2011 4:47 pm
Posts: 184
Location: Mittweida, Saxony, Germany
I don't even see what is "wrong" with the images.

Can you point that out a little better?
Also some code would be nice.

Nitram

_________________
http://illarion.org


Top
 Profile  
 
PostPosted: Thu Sep 06, 2012 8:00 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
I got the problem when you said you wanted more code. I saw that I have startUse() and endUse() around it. Thanks for helping without giving me an answer :wink:
Nevertheless I want to describe the problem: Everything moved what should stay and everything stayed what should have moved caused by
Code:
Sheet.startUse();
and then draw with "Sheet.getSprite().draw()".

Is there a way to use "Sheet.getSprite().draw()" for drawing and get the advantages (~30% faster) of drawing with the use of "renderInUse()"? I would have too much images to generate new sprites and save them all to read them later to draw them (=I could then have used images).

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Thu Sep 06, 2012 8:18 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
Not really sure what the problem is, or how you expect us to help without seeing a bit more code...?!

My guess is that you are using translate/rotate/etc. inside of startUse/endUse, which cannot be done.


Top
 Profile  
 
PostPosted: Fri Sep 07, 2012 2:44 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
No, I it is just this:
Code:
Block.Blocksheet.startUse();
       for (int y=0; y < renderarray[0].length; y++)
            for (int x=0; x < renderarray.length; x++)
                for (int z=0; z < renderarray[0][0].length; z++)
                    if (renderarray[x][y][z].ID() != 0){
                        /*Block.Blocksheet.getSprite(
                            Controller.map.data[x][y][z].spritex,
                            Controller.map.data[x][y][z].spritey
                            ).draw(
                                (int) ((Controller.map.posX + x*Block.width + (y%2) * Block.width/2)*zoom),
                                (int) ((Controller.map.posY + y*Block.height/2 - z*Block.height)*zoom / 2)
                            );*/
                       
                        Block.Blocksheet.renderInUse(
                            (int) ((Controller.map.posX + x*Block.width + (y%2) * Block.width/2)*zoom),
                            (int) ((Controller.map.posY + y*Block.height/2 - z*Block.height)*zoom / 2),
                            Controller.map.data[x][y][z].spritex,
                            Controller.map.data[x][y][z].spritey
                        );
                    }
       Block.Blocksheet.endUse();

My problem is that I want to use the commented lines at the speed of the used lines below.
But I think there is no way to do this.

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Fri Sep 07, 2012 7:23 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
I have seen something like this reported before but I was unable to reproduce it, and the other poster never gave me a self-contained test. draw() and renderInUse() should result in the same rendering positions, and shouldn't affect the FPS counter.

If somebody can provide a self-contained test replicating the bug/issue, I will gladly fix it in Slick.


Top
 Profile  
 
PostPosted: Sun Sep 09, 2012 5:59 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
I extracted the bug and reproduced it.
When you press B you will see what will happen. If you move "getSprite(4, 2)" around, you will see that it is always at the top left corner because it is the most top left item.
Source:
Attachment:
bug.zip [136.88 KiB]
Downloaded 22 times

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Tue Sep 11, 2012 12:05 am 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 270
davedes wrote:
I have seen something like this reported before but I was unable to reproduce it, and the other poster never gave me a self-contained test. draw() and renderInUse() should result in the same rendering positions, and shouldn't affect the FPS counter.

If somebody can provide a self-contained test replicating the bug/issue, I will gladly fix it in Slick.


Hi Dave,

Are you referring to my thread I made? It is located here (with a reply that has a test in it):
viewtopic.php?f=3&t=5422

I guess my reply sorta got lost in the very active forum :) I should of bumped it :)


Top
 Profile  
 
PostPosted: Wed Sep 12, 2012 6:11 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
Thanks; hadn't noticed your test earlier. The bug should now be fixed in dev branch. :)


Top
 Profile  
 
PostPosted: Thu Sep 13, 2012 12:02 am 
Offline
Oldbie

Joined: Thu Mar 15, 2012 12:38 am
Posts: 270
davedes wrote:
Thanks; hadn't noticed your test earlier. The bug should now be fixed in dev branch. :)


Thanks! I'll give it a try this weekend.


Top
 Profile  
 
PostPosted: Thu Sep 13, 2012 7:20 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
I downloaded the source from the developer branch and replaced the lib, src and javadoc folder wit the folders from "/trunk/Slick/" run the game from netbeans but it is still the same as before. :?

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
PostPosted: Thu Sep 13, 2012 8:00 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
You might need to clean/rebuild Eclipse, since it sounds like it's still referencing the old JARs.


Top
 Profile  
 
PostPosted: Fri Sep 14, 2012 8:37 pm 
Offline
User avatar

Joined: Tue Jul 17, 2012 11:27 am
Posts: 67
I did it but it still has the bug. Is there a way to check which version is running?

I also have a question. What would you suggest, if I have many tiles and I change the colors of some tiles dynamically? To prevent it from creating them every time I have to save them but when I save them I have several images and can not use the sprites with their advantages. Is there a way to combine it? Something like to create a new big sprite (which I think isn't possible because it is too much data)?

_________________
Open source isometric engine made with slick: http://wurfelengine.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group