change debuging
This commit is contained in:
parent
efecc44a52
commit
d3cb22a278
18
src/main.cpp
18
src/main.cpp
@ -5,6 +5,7 @@
|
||||
#include <SDL3_image/SDL_image.h>
|
||||
#include <cmath>
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
@ -37,9 +38,12 @@ int main() {
|
||||
Uint64 lastFrameTime = SDL_GetTicksNS();
|
||||
float deltaTime = 0.0f;
|
||||
|
||||
|
||||
|
||||
while (running) {
|
||||
const Uint64 frameStart = SDL_GetTicksNS();
|
||||
|
||||
|
||||
// Event handling
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
@ -70,6 +74,16 @@ int main() {
|
||||
lastToggle = SDL_GetTicks();
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
if (keystate[SDL_SCANCODE_B] && (SDL_GetTicks() - lastToggle > 200)) {
|
||||
std::clog << "x: " << destroyer.position.x << " y: " << destroyer.position.y << "\n";
|
||||
}
|
||||
if (keystate[SDL_SCANCODE_O] && (SDL_GetTicks() - lastToggle > 200)) {
|
||||
|
||||
destroyer.position.x = 0;
|
||||
destroyer.position.y = 0;
|
||||
}
|
||||
|
||||
// Player movement
|
||||
int moveX = keystate[SDL_SCANCODE_RIGHT] - keystate[SDL_SCANCODE_LEFT];
|
||||
int moveY = keystate[SDL_SCANCODE_DOWN] - keystate[SDL_SCANCODE_UP];
|
||||
@ -114,13 +128,15 @@ int main() {
|
||||
float step = destroyer.speed * deltaTime;
|
||||
destroyer.position.x += (float)moveX * step;
|
||||
destroyer.position.y += (float)moveY * step;
|
||||
std::clog << "step: " << step << "\n";
|
||||
|
||||
if (destroyer.gotoT) {
|
||||
float dx = destroyer.Tposition.x - destroyer.Central_position().x;
|
||||
float dy = destroyer.Tposition.y - destroyer.Central_position().y;
|
||||
|
||||
if(dx != 0 && dy != 0) {
|
||||
destroyer.angle = std::atan2(dy, dx) * 180 / M_PI + 90;
|
||||
}
|
||||
|
||||
std::clog << "angle: " << destroyer.angle
|
||||
<< "\ncalc: " << std::atan2(dy, dx) * 180 / M_PI << "\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user