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"
|
#include "character.hpp"
|
||||||
|
|
||||||
Character::Character(){
|
Character::Character(){
|
||||||
sf::Texture texture;
|
|
||||||
ASSERT(texture.loadFromFile(spriteFile));
|
ASSERT(texture.loadFromFile(spriteFile));
|
||||||
height = texture.getSize().y;
|
height = texture.getSize().y/5;
|
||||||
width = texture.getSize().x;
|
width = texture.getSize().x/5;
|
||||||
next = timestamp = indexX = indexY = 0;
|
next = timestamp = indexX = indexY = 0;
|
||||||
setTexture(texture);
|
setTexture(texture);
|
||||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
||||||
|
@ -16,28 +15,13 @@ void Character::update(float deltaTime){
|
||||||
timestamp += deltaTime;
|
timestamp += deltaTime;
|
||||||
if (timestamp >= frameTime){
|
if (timestamp >= frameTime){
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
if (actualState == previousState){
|
|
||||||
if (actualState == PlayerState::idle){
|
if (actualState == PlayerState::attacking and indexX >= 3){
|
||||||
indexX = (indexX+1)%numFrames;
|
|
||||||
}
|
|
||||||
else if (actualState == PlayerState::attacking){
|
|
||||||
if (indexX == width){
|
|
||||||
indexX = 0;
|
|
||||||
actualState = PlayerState::idle;
|
actualState = PlayerState::idle;
|
||||||
}
|
indexX = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
indexX = 0;
|
indexX = (indexX+1)%4;
|
||||||
if (actualState == PlayerState::idle){
|
|
||||||
indexY = 1;
|
|
||||||
actualState = PlayerState::attacking;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (actualState == PlayerState::attacking){
|
|
||||||
indexY = 0;
|
|
||||||
actualState = PlayerState::idle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::IntRect rect = sf::IntRect(indexX*width, indexY*height, width, height);
|
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){
|
void Character::setState(PlayerState::playerState state){
|
||||||
previousState = actualState;
|
previousState = actualState;
|
||||||
actualState = state;
|
actualState = state;
|
||||||
|
if (state == PlayerState::idle){
|
||||||
|
indexX = 0;
|
||||||
|
indexY = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
indexX = 0;
|
||||||
|
indexY = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
|
|
||||||
class Character : public sf::Sprite{
|
class Character : public sf::Sprite{
|
||||||
private:
|
private:
|
||||||
//CONSTS
|
//CONFIG
|
||||||
const double frameTime = 0.2;
|
const double frameTime = 0.2;
|
||||||
const int numFrames = 4;
|
const int numFrames = 4;
|
||||||
const std::string spriteFile = "";
|
const std::string spriteFile = "./Resources/spreadsheet.png";
|
||||||
//CONSTS
|
//END CONFIG
|
||||||
|
|
||||||
|
sf::Texture texture;
|
||||||
int indexX, indexY, width, height;
|
int indexX, indexY, width, height;
|
||||||
int posX, posY;
|
int posX, posY;
|
||||||
PlayerState::playerState actualState, previousState;
|
PlayerState::playerState actualState, previousState;
|
||||||
|
|
|
@ -53,13 +53,25 @@ SOURCES = ../VaporWaveWars/main.cpp \
|
||||||
../VaporWaveWars/mygame.cpp \
|
../VaporWaveWars/mygame.cpp \
|
||||||
../VaporWaveWars/button.cpp \
|
../VaporWaveWars/button.cpp \
|
||||||
../VaporWaveWars/character.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 \
|
OBJECTS = main.o \
|
||||||
game.o \
|
game.o \
|
||||||
mygame.o \
|
mygame.o \
|
||||||
button.o \
|
button.o \
|
||||||
character.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 \
|
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/unix.conf \
|
||||||
../../../Qt/5.7/gcc_64/mkspecs/common/linux.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 \
|
commons.hpp \
|
||||||
button.hpp \
|
button.hpp \
|
||||||
character.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/game.cpp \
|
||||||
../VaporWaveWars/mygame.cpp \
|
../VaporWaveWars/mygame.cpp \
|
||||||
../VaporWaveWars/button.cpp \
|
../VaporWaveWars/button.cpp \
|
||||||
../VaporWaveWars/character.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
|
QMAKE_TARGET = VaporWaveWars
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
TARGET = VaporWaveWars
|
TARGET = VaporWaveWars
|
||||||
|
@ -560,7 +584,14 @@ compiler_clean:
|
||||||
main.o: ../VaporWaveWars/main.cpp ../VaporWaveWars/mygame.hpp \
|
main.o: ../VaporWaveWars/main.cpp ../VaporWaveWars/mygame.hpp \
|
||||||
../VaporWaveWars/game.hpp \
|
../VaporWaveWars/game.hpp \
|
||||||
../VaporWaveWars/commons.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
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../VaporWaveWars/main.cpp
|
||||||
|
|
||||||
game.o: ../VaporWaveWars/game.cpp ../VaporWaveWars/game.hpp \
|
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 \
|
mygame.o: ../VaporWaveWars/mygame.cpp ../VaporWaveWars/mygame.hpp \
|
||||||
../VaporWaveWars/game.hpp \
|
../VaporWaveWars/game.hpp \
|
||||||
../VaporWaveWars/commons.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
|
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mygame.o ../VaporWaveWars/mygame.cpp
|
||||||
|
|
||||||
button.o: ../VaporWaveWars/button.cpp ../VaporWaveWars/button.hpp \
|
button.o: ../VaporWaveWars/button.cpp ../VaporWaveWars/button.hpp \
|
||||||
|
@ -585,6 +623,49 @@ compas.o: ../VaporWaveWars/compas.cpp ../VaporWaveWars/compas.hpp \
|
||||||
../VaporWaveWars/commons.hpp
|
../VaporWaveWars/commons.hpp
|
||||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o compas.o ../VaporWaveWars/compas.cpp
|
$(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
|
||||||
|
|
||||||
install: FORCE
|
install: FORCE
|
||||||
|
|
Binary file not shown.
Reference in a new issue