Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Animating Sprites in Java Help


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 darcmagik   Members   -  Reputation: 103

Like
0Likes
Like

Posted 10 November 2005 - 02:12 PM

Hey guys I need some help with a project from school were building a game engine to make side scrolling 2D games in java. well I'm working on figuring out how to animate Sprites from a Sprites page. I am using a buffered image to hold the sprites page and I was thinking about just pulling the individual sprites from the page and rendering them to the screen. Well the problem I'm having is how can I just draw a specific region of the Sprites Page to the screen. I got the sprites width and height but I cant figure out how to just draw a section from even just the top left corner to the width and height of the first sprite. Can anybody help me here???? I'm kinda new to java so please dont go to off into the wild blue yonder of java know how. LOL DarcMagik
Darcmagik

Of all the things I''ve lost I miss my mind the most.

Sponsor:

#2 JohnnyCasil   Members   -  Reputation: 373

Like
0Likes
Like

Posted 10 November 2005 - 02:22 PM

BufferedImage.getSubImage()

Take a look at this method of buffered image. It will allow you to grab a sub image out of a larger BufferedImage. The exact parameters you have to pass here really depends on how your sprite page is laid out.

#3 stormrunner   Members   -  Reputation: 720

Like
0Likes
Like

Posted 10 November 2005 - 02:29 PM

Quote:
Original post by darcmagik
Well the problem I'm having is how can I just draw a specific region of the Sprites Page to the screen.

Assuming - as you said - that you sprite sheet is stored in a BufferedImage, you can simply use the getSubimage method to return the image at the specified x and y coordinates. Then you'd draw the image to your screen (or backbuffer) as normal.

<edit :: I'm slow ;P

#4 darcmagik   Members   -  Reputation: 103

Like
0Likes
Like

Posted 10 November 2005 - 02:36 PM

Thats cool I appreciate the help. Just one more question though. Anybody wanna give me a hint as to how to actually animate it. At least being able to go from the begining of a row of sprites to the end of a row in the Sprite Page??? Also can anybody give me a link to some info about how I can store those tiles in an array? So that I can just loop through them. If this sounds like a stupid question, i'm sorry but my brain isnt working real well tonight.

DarcMagik
Darcmagik

Of all the things I''ve lost I miss my mind the most.

#5 darcmagik   Members   -  Reputation: 103

Like
0Likes
Like

Posted 11 November 2005 - 03:46 AM

Ok does anybody have a link to any tutorials on how to make side scrolling games? I need some help with the logic for it. As I am fairly new to java.

Darcmagik
Darcmagik

Of all the things I''ve lost I miss my mind the most.

#6 wortel   Members   -  Reputation: 174

Like
0Likes
Like

Posted 11 November 2005 - 07:37 AM

Hey man, first of all don't be ashamed to ask stupid questions. All of us were noobs at one time or another and we're here to help.

animation is not too tough, i had a counter to count the loops and id % it with the number of frames i were working thru (could be modded again if one image is on more frame).

As for physics etc., only help i have is a game called stickduel I wrote. I left it somewhere on the net, google for it, if you can't find me email me. I'l email it to you.

my email is 14584808 at sun dot ca dot za.

It's a platform based 2 player animated combat game, pretty fun.

HTH dude

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 11 November 2005 - 10:58 AM

You should look into threads.

#8 darcmagik   Members   -  Reputation: 103

Like
0Likes
Like

Posted 13 November 2005 - 07:44 AM

Hey Guys its me again. Does anybody have a link to a tutorial on making a side scroller. The part I'm interested in is the animation of sprites, and also loading in a map and displaying it to the screen. I've been working on a Sprites class trying to make somthing that I can add to an engine were building in school, but I think I'm going about this the wrong way and just want to see a tutorial to maybe point me in the right direction. Any help would be appreciated.

DarcMagik
Darcmagik

Of all the things I''ve lost I miss my mind the most.

#9 darcmagik   Members   -  Reputation: 103

Like
0Likes
Like

Posted 13 November 2005 - 03:47 PM

Ok folks I have done a LOT of research into 2D side scrolling and I can find some great information into how to load the map into a 2 Dimensional array and display it and then just move the graphics and display more. But there are a couple things I'm a little foggy on. How do you create thses maps? and more importantly how to you load in all of the images? do you just create an array of sprites to hold all the tiles? is there a way to load in a map that was already created? I read somthing about PCX (I hope I got that name right) maps and that you need a map reader and when I try to find one the sights are all gone and it doesnt exist any more.

So what I am looking for from somebody is either how do I bring in pre done map files and display them or how do I take a bunch of tiles in and display those. If I can figure that out I think figuring out how to do the character animation wont be that difficult.

Please, Please, PLEASE help me,

DarcMagik
Darcmagik

Of all the things I''ve lost I miss my mind the most.

#10 Son of Cain   Members   -  Reputation: 480

Like
0Likes
Like

Posted 14 November 2005 - 12:37 AM

David Brackeen's book is impressive. There's a side scroller you can play at this link, through web start. All the book's code is available at the website as well.

I *REALLY* recommend you to buy this book.

Son Of Cain
a.k.a javabeats at yahoo.ca




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS