Java Game Programming #13 - Animations

preview_player
Показать описание

In this video we look at adding an animation class into our game and being able to have a walking animation for our player. If you have any questions then be sure to leave a comment or contact me on twitter; realtutsgml. If you learned something then be sure to leave a like, comment, and favorite.

Have fun learning!

Рекомендации по теме
Комментарии
Автор

really thank you very much for everything bro, no one explains things like you, please do never get tired of teaching us java development, greetings from Spain of a autodidact teenager that is starting in the scene now xD

AlexMarbellero
Автор

I know this was uploaded 4 years ago, but can you please link your eclipse theme? It's so good!

Thanks.

EDIT: Sorry I forgot to mention that I absolutely LOVE your videos!

devonsteyn
Автор

Great video! Thank you so much for the Java tutorials, they helped a ton! The only suggustion I would make, though, is to explain what each method does a little bit more in depth, since some of us (like me) are really new to java. Again, great job!

davidharmeyer
Автор

Can you put a link in the description for the sprite sheets?
I'm having an hard time trying to find some sprites to test the code. Thanks ;)

bejmnito
Автор

Hi, thanks for the tutorials.
this code :

for(int i = 0; i < frames; i++){
if(count == i)
currentImg = images[i];
}

can be replaced by this ?

if(count < frames)
currentImg = images[count];

miraknroll
Автор

I've never seen the ... for the params before. cool. Is BufferedImage the only class that uses that (...), or can that be used elsewhere?

jasonzimmerman
Автор

GUYS: If you want to increase your FPS, this is an easy solution.
This is the render method of your Block class.
What it does is only render if the block is inside the screen, otherwise it isn't rendered. this increases FPS by a lot because there is no reason to render things outside the screen... Hope this helps!

public void render(Graphics g) {
// Cull blocks outside the screen to increase FPS
if ((this.x > -Camera.getX() + Game.WIDTH) || (this.x < -Camera.getX() - 32) || (this.y > -Camera.getY() + Game.HEIGHT) || (this.y < -Camera.getY() - 32)) {
;
} else {
if (type == EnumBlockID.DIRT) {
g.drawImage(tex.block[0], (int) x, (int) y, null);
}
if (type == EnumBlockID.GRASS) {
g.drawImage(tex.block[1], (int) x, (int) y, null);
}
}

}

criticaldiamonds
Автор

Surprise surprise surprise! In a move that is reminiscent of the level of ongoing support of all the rest of these tutorial videos, the google+ account is going the way of the dodo!
Want a copy of that image file that this thing shows about 30 seconds in? GOOD LUCK! YOU'RE ON YOUR OWN!!!
Me? Well, since they can't be bothered to make the image files available, I'm not going to be bothered to pull my hair out trying to follow this orphaned video.

cpuwrite
Автор

for me only 1 frame is working, why arent the others getting animated
?
can some post the source code for animation and player class?

rahulcool
Автор

My problem is that the character animation does not seem to work:
when i press run, it only switches to the last frame of my animation, and stays there. It's as if it didn't even cicle through the 6 frames I drew for it....

gergelykonya
Автор

How can i make animation start from first frame for example when i use attack() method? Now it starts from most recent frame, so when i use attack() it starts from end then first and 2nd :/

dawidsarnecki
Автор

My animation plays once and won't repeat until I stop walking and start again.Then again, it only plays once. Basically it's not looping until movement resets. What gives?

Chrono
Автор

4:36 why don't you use a simple module? That is:

Index = (Index+1) % speed;
If (index == 0) { nextFrame(); }

5:32 why don't you simply write the following?:

currentImg = images[count];
Count = (Count+1) % frames;

Great video in any case!!! 😊😊😊👍💯

gogoat
Автор

You can just assign args to images, it's already an array of the same type.
Alternatively, you can use System.arraycopy rather than manually copying every element into the new array.

renbinden
Автор

after writing "currentImg = images[i];" you should make a "break;" :D

daniellionel
Автор

Why is there always empty comment on top of everyone ?

huseinomerovic
Автор

are you gonna continue that minecraft series?

Danidre
Автор

i get serious lag if i have a lot of blocks anyway to fix that

morganb
Автор

couldn't you just instead of importing the flipped images from the sprite sheet but just when they move to the left have it scale to the X to a negative number? I am not sure if that would work though so don't quote me on that

Funske
Автор

Can somebody comment me the codes for the player animation left?
Please!

schnitzy