[update] Implemented player's moving calculation.

This commit is contained in:
2019-10-09 00:00:00 +00:00
parent 1e6ebe97ce
commit 7f2ada6982
3 changed files with 47 additions and 14 deletions

View File

@@ -37,6 +37,8 @@ int main(string[] args) {
const msecs = sfMusic_getPlayingOffset(music).microseconds * 1e-6f;
const beat = msecs/60f * bpm;
context.actor.Accelarate(GetAccelarationInput());
context.OperateScheduledControllers(beat);
context.actor.Update();
context.posteffect.Update();
@@ -53,6 +55,23 @@ int main(string[] args) {
return 0;
}
vec2 GetAccelarationInput() {
auto result = vec2(0, 0);
if (sfKeyboard_isKeyPressed(sfKeyLeft)) {
result.x -= 1;
}
if (sfKeyboard_isKeyPressed(sfKeyRight)) {
result.x += 1;
}
if (sfKeyboard_isKeyPressed(sfKeyUp)) {
result.y += 1;
}
if (sfKeyboard_isKeyPressed(sfKeyDown)) {
result.y -= 1;
}
return result;
}
sfWindow* Initialize() {
DerelictSFML2System.load();
DerelictSFML2Window.load();