Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Sprite sheet help needed
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zuber




PostPosted: Fri May 02, 2008 11:31 pm   Post subject: Sprite sheet help needed

For the various games I'm currently trying to code I'm in need of a whole bunch of sprites. Finding the sprites is not the problem, but the idea of making a hundred separate pictures seems tedious and rather inefficient. Essentially what I'm looking to do is this: (for a sprite sheet with 100 sprites each 25 by 25 pixels)

code:

Image spriteSheet = new Image("SpriteSheet.gif");

Image[]sprite = new Image [100];
int z=0;
final int PICX=25;
final int PICY=25;

for (int x=0;x<10;x++)
          for (int y=0;y<10;y++)
{
sprite[z]= new Image (spriteSheet,x*25,y*25,PICX,PICY); //The idea here being that I want to create a new picture off the spritesheet of size PICX by PICY starting at coordinates x*25,y*25
z++;
}


I've been looking but can't for the life of me find the java code (for an applet btw) that will allow me to do this. Any suggestions?
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: