Sign in to follow this  
darcmagik

[java] Animating Sprites in Java Help

Recommended Posts

darcmagik    255
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

Share this post


Link to post
Share on other sites
stormrunner    720
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

Share this post


Link to post
Share on other sites
darcmagik    255
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

Share this post


Link to post
Share on other sites
wortel    174
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

Share this post


Link to post
Share on other sites
darcmagik    255
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

Share this post


Link to post
Share on other sites
darcmagik    255
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

Share this post


Link to post
Share on other sites
Son of Cain    480
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this