Merge branch 'master' into serk
This commit is contained in:
commit
96d80e1c4b
4 changed files with 106 additions and 32 deletions
|
@ -1,10 +1,9 @@
|
|||
#include "character.hpp"
|
||||
|
||||
Character::Character(){
|
||||
sf::Texture texture;
|
||||
ASSERT(texture.loadFromFile(spriteFile));
|
||||
height = texture.getSize().y;
|
||||
width = texture.getSize().x;
|
||||
height = texture.getSize().y/5;
|
||||
width = texture.getSize().x/5;
|
||||
next = timestamp = indexX = indexY = 0;
|
||||
setTexture(texture);
|
||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||
|
@ -16,28 +15,13 @@ void Character::update(float deltaTime){
|
|||
timestamp += deltaTime;
|
||||
if (timestamp >= frameTime){
|
||||
timestamp = 0;
|
||||
if (actualState == previousState){
|
||||
if (actualState == PlayerState::idle){
|
||||
indexX = (indexX+1)%numFrames;
|
||||
}
|
||||
else if (actualState == PlayerState::attacking){
|
||||
if (indexX == width){
|
||||
indexX = 0;
|
||||
actualState = PlayerState::idle;
|
||||
}
|
||||
}
|
||||
|
||||
if (actualState == PlayerState::attacking and indexX >= 3){
|
||||
actualState = PlayerState::idle;
|
||||
indexX = 0;
|
||||
}
|
||||
else {
|
||||
indexX = 0;
|
||||
if (actualState == PlayerState::idle){
|
||||
indexY = 1;
|
||||
actualState = PlayerState::attacking;
|
||||
}
|
||||
|
||||
else if (actualState == PlayerState::attacking){
|
||||
indexY = 0;
|
||||
actualState = PlayerState::idle;
|
||||
}
|
||||
indexX = (indexX+1)%4;
|
||||
}
|
||||
|
||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||
|
@ -48,5 +32,13 @@ void Character::update(float deltaTime){
|
|||
void Character::setState(PlayerState::playerState state){
|
||||
previousState = actualState;
|
||||
actualState = state;
|
||||
if (state == PlayerState::idle){
|
||||
indexX = 0;
|
||||
indexY = 0;
|
||||
}
|
||||
else{
|
||||
indexX = 0;
|
||||
indexY = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
class Character : public sf::Sprite{
|
||||
private:
|
||||
//CONSTS
|
||||
//CONFIG
|
||||
const double frameTime = 0.2;
|
||||
const int numFrames = 4;
|
||||
const std::string spriteFile = "";
|
||||
//CONSTS
|
||||
const std::string spriteFile = "./Resources/spreadsheet.png";
|
||||
//END CONFIG
|
||||
|
||||
sf::Texture texture;
|
||||
int indexX, indexY, width, height;
|
||||
int posX, posY;
|
||||
PlayerState::playerState actualState, previousState;
|
||||
|
|
|
@ -53,13 +53,25 @@ SOURCES = ../VaporWaveWars/main.cpp \
|
|||
../VaporWaveWars/mygame.cpp \
|
||||
../VaporWaveWars/button.cpp \
|
||||
../VaporWaveWars/character.cpp \
|
||||
../VaporWaveWars/compas.cpp
|
||||
../VaporWaveWars/compas.cpp \
|
||||
../VaporWaveWars/scene.cpp \
|
||||
../VaporWaveWars/menu.cpp \
|
||||
../VaporWaveWars/combat.cpp \
|
||||
../VaporWaveWars/player.cpp \
|
||||
../VaporWaveWars/iaenemy.cpp \
|
||||
../VaporWaveWars/actor.cpp
|
||||
OBJECTS = main.o \
|
||||
game.o \
|
||||
mygame.o \
|
||||
button.o \
|
||||
character.o \
|
||||
compas.o
|
||||
compas.o \
|
||||
scene.o \
|
||||
menu.o \
|
||||
combat.o \
|
||||
player.o \
|
||||
iaenemy.o \
|
||||
actor.o
|
||||
DIST = ../../../Qt/5.7/gcc_64/mkspecs/features/spec_pre.prf \
|
||||
../../../Qt/5.7/gcc_64/mkspecs/common/unix.conf \
|
||||
../../../Qt/5.7/gcc_64/mkspecs/common/linux.conf \
|
||||
|
@ -208,12 +220,24 @@ DIST = ../../../Qt/5.7/gcc_64/mkspecs/features/spec_pre.prf \
|
|||
commons.hpp \
|
||||
button.hpp \
|
||||
character.hpp \
|
||||
compas.hpp ../VaporWaveWars/main.cpp \
|
||||
compas.hpp \
|
||||
scene.hpp \
|
||||
menu.hpp \
|
||||
combat.hpp \
|
||||
player.hpp \
|
||||
iaenemy.hpp \
|
||||
actor.hpp ../VaporWaveWars/main.cpp \
|
||||
../VaporWaveWars/game.cpp \
|
||||
../VaporWaveWars/mygame.cpp \
|
||||
../VaporWaveWars/button.cpp \
|
||||
../VaporWaveWars/character.cpp \
|
||||
../VaporWaveWars/compas.cpp
|
||||
../VaporWaveWars/compas.cpp \
|
||||
../VaporWaveWars/scene.cpp \
|
||||
../VaporWaveWars/menu.cpp \
|
||||
../VaporWaveWars/combat.cpp \
|
||||
../VaporWaveWars/player.cpp \
|
||||
../VaporWaveWars/iaenemy.cpp \
|
||||
../VaporWaveWars/actor.cpp
|
||||
QMAKE_TARGET = VaporWaveWars
|
||||
DESTDIR =
|
||||
TARGET = VaporWaveWars
|
||||
|
@ -560,7 +584,14 @@ compiler_clean:
|
|||
main.o: ../VaporWaveWars/main.cpp ../VaporWaveWars/mygame.hpp \
|
||||
../VaporWaveWars/game.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/compas.hpp
|
||||
../VaporWaveWars/menu.hpp \
|
||||
../VaporWaveWars/scene.hpp \
|
||||
../VaporWaveWars/button.hpp \
|
||||
../VaporWaveWars/combat.hpp \
|
||||
../VaporWaveWars/compas.hpp \
|
||||
../VaporWaveWars/player.hpp \
|
||||
../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/iaenemy.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../VaporWaveWars/main.cpp
|
||||
|
||||
game.o: ../VaporWaveWars/game.cpp ../VaporWaveWars/game.hpp \
|
||||
|
@ -570,7 +601,14 @@ game.o: ../VaporWaveWars/game.cpp ../VaporWaveWars/game.hpp \
|
|||
mygame.o: ../VaporWaveWars/mygame.cpp ../VaporWaveWars/mygame.hpp \
|
||||
../VaporWaveWars/game.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/compas.hpp
|
||||
../VaporWaveWars/menu.hpp \
|
||||
../VaporWaveWars/scene.hpp \
|
||||
../VaporWaveWars/button.hpp \
|
||||
../VaporWaveWars/combat.hpp \
|
||||
../VaporWaveWars/compas.hpp \
|
||||
../VaporWaveWars/player.hpp \
|
||||
../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/iaenemy.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mygame.o ../VaporWaveWars/mygame.cpp
|
||||
|
||||
button.o: ../VaporWaveWars/button.cpp ../VaporWaveWars/button.hpp \
|
||||
|
@ -585,6 +623,49 @@ compas.o: ../VaporWaveWars/compas.cpp ../VaporWaveWars/compas.hpp \
|
|||
../VaporWaveWars/commons.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o compas.o ../VaporWaveWars/compas.cpp
|
||||
|
||||
scene.o: ../VaporWaveWars/scene.cpp ../VaporWaveWars/scene.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/game.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o scene.o ../VaporWaveWars/scene.cpp
|
||||
|
||||
menu.o: ../VaporWaveWars/menu.cpp ../VaporWaveWars/menu.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/scene.hpp \
|
||||
../VaporWaveWars/game.hpp \
|
||||
../VaporWaveWars/button.hpp \
|
||||
../VaporWaveWars/mygame.hpp \
|
||||
../VaporWaveWars/combat.hpp \
|
||||
../VaporWaveWars/compas.hpp \
|
||||
../VaporWaveWars/player.hpp \
|
||||
../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/iaenemy.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o menu.o ../VaporWaveWars/menu.cpp
|
||||
|
||||
combat.o: ../VaporWaveWars/combat.cpp ../VaporWaveWars/combat.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/compas.hpp \
|
||||
../VaporWaveWars/scene.hpp \
|
||||
../VaporWaveWars/game.hpp \
|
||||
../VaporWaveWars/player.hpp \
|
||||
../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/iaenemy.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o combat.o ../VaporWaveWars/combat.cpp
|
||||
|
||||
player.o: ../VaporWaveWars/player.cpp ../VaporWaveWars/player.hpp \
|
||||
../VaporWaveWars/commons.hpp \
|
||||
../VaporWaveWars/compas.hpp \
|
||||
../VaporWaveWars/actor.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o player.o ../VaporWaveWars/player.cpp
|
||||
|
||||
iaenemy.o: ../VaporWaveWars/iaenemy.cpp ../VaporWaveWars/iaenemy.hpp \
|
||||
../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/commons.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o iaenemy.o ../VaporWaveWars/iaenemy.cpp
|
||||
|
||||
actor.o: ../VaporWaveWars/actor.cpp ../VaporWaveWars/actor.hpp \
|
||||
../VaporWaveWars/commons.hpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o actor.o ../VaporWaveWars/actor.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install: FORCE
|
||||
|
|
Binary file not shown.
Reference in a new issue