C++ 2D Platformer Game Tutorial Part 13 Spritesheets SFML

preview_player
Показать описание
C++ SFML 2D platformer tutorial part 13. How to make games with C++ and SFML. Using spritesheets rather than single sprites to speed up the C++ game development. C++ is the programming language we are using to create our game because of C++'s superior runtime. SFML is the 2D rendering library we use for graphics in our game.

Dynamically linking SFML and C++ Tutorial:
Рекомендации по теме
Комментарии
Автор

When it comes to video games, you want to use PNG images because they have an alpha channel which is used for transparency which you will absolutely want for your sprites. The only times you can use JPGs is for something like a background image or any image that does not need transparency.

NeilRoy
Автор

In the previous video he mentioned using switches but you don't have too. This is my collide function:
void collide() {
if(xpos > 550 || xpos < 0) {
xvel = 0;
}
if(ypos > 550 || ypos < 0) {
onGround = true;
}
if(onGround == true && playerUp == true){
onGround = false;
}
}
And this is how when the sprite hits the desired ypos it will stop, but when you press up it will move up:
if(onGround == true) {
yvel = 0;
}
if(!onGround == false && playerUp == true) {
yvel = -0.25;
}
This is what it looks like altogether:
if(onGround == true) {
yvel = 0;
}
if(!onGround == false && playerUp == true) {
yvel = -0.25;
}
xpos += xvel;
ypos += yvel;
collide();
}
void collide() {
if(xpos > 550 || xpos < 0) {
xvel = 0;
}
if(ypos > 550 || ypos < 0) {
onGround = true;
}
if(onGround == true && playerUp == true){
onGround = false;
}
}




Edit: Hope this helps anyone!

jad
Автор

Where did you take those textures from?

matt