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