Slick Forums

Discuss the Slick 2D Library
It is currently Wed Dec 11, 2019 5:10 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu Nov 22, 2007 8:19 am 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
I have a 512x512 sprite sheet which I divide in tiles of 16x16, so it's 32x32 tiles. How does it come SpriteSheet.getHorizontalCount() returns 32 and SpriteSheet.getVerticalCount() returns 33?

Is that related to http://slick.javaunlimited.net/viewtopic.php?t=419&highlight=spritesheet?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 8:57 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Yeah, there was a whole clunky issue around it. Are you using source from SVN, I think it's be reworked.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 9:25 am 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
I'm using build #184, but I can always make a JAR from the SVN.

EDIT: I made a JAR out of the SVN, but the problem doesn't seem resolved.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 24, 2007 11:32 pm 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
Kev, do you plan to fix this bug? I've tried to do so but the problem seems to come from the Image class, which I'm not comfortable with. I checked the SpriteSheet class and everything seems fine.

Maybe you should move this thread to Bug/RFE section.

Alexin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 25, 2007 4:45 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
I'm not coding at all right now, still a bit on the ill side. I'll get it as soon as I'm back on the computer for real periods.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 10:52 am 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
You got the test case for this one. Is there any tile spacing involved cause it looks like it should work ok.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 2:07 pm 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
kevglass wrote:
You got the test case for this one.

What do you mean?

I don't specify any tile spacing; it should be 0 by default.
Yeah, it's weird. I look at the code, execute it mentally and get the desired result, but when I run the application...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 3:17 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Test case = i.e. the images and bit of code you're using to load the SpriteSheet.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 5:24 pm 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
This is the tileset.
Code:
public void init(GameContainer container, StateBasedGame game) throws SlickException {
        sheet = new SpriteSheet("res/Yoshi16x16.png", 16, 16, Color.magenta);
        tileLayer = new TileLayer(sheet.getVerticalCount(), sheet.getHorizontalCount(), 16);

        Log.info("Rows: " + sheet.getVerticalCount() + "\tColumns: " + sheet.getHorizontalCount());
        for (int row = 0; row < tileLayer.getHeight(); row++)
            for (int column = 0; column < tileLayer.getWidth(); column++)
                tileLayer.getData().setTile(new Tile(sheet.getSprite(column, row), 16), column, row);

        camera = new Camera(0.0f, 0.0f);
        scene.setLayer(tileLayer);
        scene.setCamera(camera);
    }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 6:57 pm 
Offline
Site Admin
User avatar

Joined: Thu Jan 01, 1970 12:00 am
Posts: 3143
Fixed in SVN. Dumb bracketing error.

Kev


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 8:59 pm 
Offline
Regular

Joined: Mon May 28, 2007 8:47 am
Posts: 106
Location: Coimbra, Portugal
Thanks Kev!


Top
 Profile  
 
PostPosted: Sun Jan 22, 2012 11:51 am 
Offline

Joined: Sun Jan 22, 2012 11:38 am
Posts: 1
Are you really sure it's fixed? I just tried drawing animanition and realized that SpriteSheet sees one extra row which is not actually there.
Code:
SpriteSheet ss=  new SpriteSheet("images/green_up.png"
               ,Config.AVATAR_WIDTH
               ,Config.AVATAR_HEIGHT,1);
        avatar = new Animation(ss
           ,50);
        avatar.start();
       
        System.out.println("ss.getHorizontalCount() " + ss.getHorizontalCount());
        System.out.println("ss.getVerticalCount() " + ss.getVerticalCount());
        System.out.println("frames number:" + avatar.getFrameCount());

When using a 7 frames image (one row,7 cols,1 pix separation) the output is
Code:
ss.getHorizontalCount() 7
ss.getVerticalCount() 2
frames number:14


I was using slick.jar from 2010.06.26 and last nightly build (2012.1.21). Neither worked.


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

All times are UTC


Who is online

Users browsing this forum: No registered users 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:  
cron
Powered by phpBB® Forum Software © phpBB Group