arreglos d'estil
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
#include <SDL3/SDL.h>
|
||||
#include "dot.h"
|
||||
#include "defines.h"
|
||||
#include "dbgtxt.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <SDL3/SDL_error.h> // Para SDL_GetError
|
||||
#include <SDL3/SDL_events.h> // Para SDL_EventType, SDL_PollEvent, SDL_Event
|
||||
#include <SDL3/SDL_init.h> // Para SDL_Init, SDL_Quit, SDL_INIT_VIDEO
|
||||
#include <SDL3/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5
|
||||
#include <SDL3/SDL_rect.h> // Para SDL_FPoint
|
||||
#include <SDL3/SDL_render.h> // Para SDL_SetRenderDrawColor, SDL_CreateRend...
|
||||
#include <SDL3/SDL_stdinc.h> // Para Uint64
|
||||
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
|
||||
#include <SDL3/SDL_video.h> // Para SDL_CreateWindow, SDL_DestroyWindow
|
||||
#include <stdlib.h> // Para rand, srand
|
||||
#include <time.h> // Para time
|
||||
#include <iostream> // Para basic_ostream, char_traits, operator<<
|
||||
#include <string> // Para operator+, string, to_string
|
||||
#include "dbgtxt.h" // Para dbg_init, dbg_print
|
||||
#include "defines.h" // Para WIDTH, MAX_DOTS, Color, HEIGHT, ZOOM
|
||||
#include "dot.h" // Para DotData, ini, modVel, update
|
||||
|
||||
// Ventana y renderizador
|
||||
SDL_Window *window = nullptr;
|
||||
@@ -27,10 +37,10 @@ Uint64 ticks = 0;
|
||||
// Actualiza el texto a mostrar en pantalla
|
||||
void setText()
|
||||
{
|
||||
const std::string text2 = test[scenario] == 1 ? " PIXEL" : " PIXELES";
|
||||
text = std::to_string(test[scenario]) + text2;
|
||||
const int size = text.size() * 8;
|
||||
text_pos = WIDTH / 2 - size / 2;
|
||||
const std::string TEXT2 = test[scenario] == 1 ? " PIXEL" : " PIXELES";
|
||||
text = std::to_string(test[scenario]) + TEXT2;
|
||||
const int SIZE = text.size() * 8;
|
||||
text_pos = WIDTH / 2 - SIZE / 2;
|
||||
text_init_time = SDL_GetTicks();
|
||||
show_text = true;
|
||||
}
|
||||
@@ -40,12 +50,12 @@ void initDots()
|
||||
{
|
||||
for (int i = 0; i < test[scenario]; ++i)
|
||||
{
|
||||
const int sign = ((rand() % 2) * 2) - 1;
|
||||
const float x = (rand() % (WIDTH / 2)) + (WIDTH / 4);
|
||||
const float vx = (((rand() % 20) + 10) * 0.1f) * sign;
|
||||
const float vy = ((rand() % 60) - 30) * 0.1f;
|
||||
const Color color = {(rand() % 192) + 32, (rand() % 192) + 32, (rand() % 192) + 32};
|
||||
dots[i] = Dot::ini(x, vx, vy, color);
|
||||
const int SIGN = ((rand() % 2) * 2) - 1;
|
||||
const float X = (rand() % (WIDTH / 2)) + (WIDTH / 4);
|
||||
const float VX = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
const float VY = ((rand() % 60) - 30) * 0.1f;
|
||||
const Color COLOR = {(rand() % 192) + 32, (rand() % 192) + 32, (rand() % 192) + 32};
|
||||
dots[i] = Dot::ini(X, VX, VY, COLOR);
|
||||
}
|
||||
setText();
|
||||
}
|
||||
@@ -55,10 +65,10 @@ void pushUpDots()
|
||||
{
|
||||
for (int i = 0; i < test[scenario]; ++i)
|
||||
{
|
||||
const int sign = ((rand() % 2) * 2) - 1;
|
||||
const float vx = (((rand() % 20) + 10) * 0.1f) * sign;
|
||||
const float vy = ((rand() % 40) * 0.1f) + 5;
|
||||
Dot::modVel(dots[i], vx, -vy);
|
||||
const int SIGN = ((rand() % 2) * 2) - 1;
|
||||
const float VX = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
const float VY = ((rand() % 40) * 0.1f) + 5;
|
||||
Dot::modVel(dots[i], VX, -VY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user