Minor changes
This commit is contained in:
parent
32f6d24433
commit
9496a6b4c9
|
@ -88,9 +88,15 @@ init_program (void) {
|
||||||
|
|
||||||
counter_box.x = COUNTER_BOX_X;
|
counter_box.x = COUNTER_BOX_X;
|
||||||
counter_box.y = COUNTER_BOX_Y;
|
counter_box.y = COUNTER_BOX_Y;
|
||||||
text_font = TTF_OpenFont ("arimo.ttf", COUNTER_TEXT_SIZE);
|
|
||||||
|
text_font = TTF_OpenFont ("arimo.ttf", COUNTER_TEXT_SIZE);
|
||||||
|
|
||||||
|
if (text_font == NULL)
|
||||||
|
fprintf (stderr, "Failed to load counter - arimo.ttf may be missing\n");
|
||||||
|
|
||||||
text_surface = NULL;
|
text_surface = NULL;
|
||||||
text_texture = NULL;
|
text_texture = NULL;
|
||||||
|
|
||||||
text_color = calloc (1, sizeof (SDL_Color));
|
text_color = calloc (1, sizeof (SDL_Color));
|
||||||
text_color->r = 255;
|
text_color->r = 255;
|
||||||
text_color->g = 255;
|
text_color->g = 255;
|
||||||
|
|
29
src/main.c
29
src/main.c
|
@ -29,11 +29,11 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define HEX_POKE 0xFF
|
#define HEX_POKE 0xFF
|
||||||
#define COUNTER_DIGITS 100
|
#define COUNTER_SIZE 100
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[]) {
|
main (int argc, const char *argv[]) {
|
||||||
|
|
||||||
struct pos ray;
|
struct pos ray;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
@ -42,9 +42,14 @@ main (int argc, char *argv[]) {
|
||||||
Uint8 bg_green = HEX_POKE;
|
Uint8 bg_green = HEX_POKE;
|
||||||
Uint8 bg_blue = 0x00;
|
Uint8 bg_blue = 0x00;
|
||||||
|
|
||||||
|
printf ("MMXXIII Ty3r0X\n");
|
||||||
|
|
||||||
if (init_program () != EXIT_SUCCESS)
|
if (init_program () != EXIT_SUCCESS)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
/* Print argv - useless but used to stop
|
||||||
|
* my compiler from yelling */
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++)
|
for (int i = 0; i < argc; i++)
|
||||||
printf ("%s\n", argv[i]);
|
printf ("%s\n", argv[i]);
|
||||||
|
|
||||||
|
@ -56,9 +61,9 @@ main (int argc, char *argv[]) {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
/* Initialize counter array - max 100 digits */
|
/* Initialize counter array */
|
||||||
|
|
||||||
char counter_text[COUNTER_DIGITS];
|
char counter_text[COUNTER_SIZE];
|
||||||
|
|
||||||
/* Constantly initialize boolean values for corners, each for loop
|
/* Constantly initialize boolean values for corners, each for loop
|
||||||
* iteration they change values */
|
* iteration they change values */
|
||||||
|
@ -115,8 +120,7 @@ main (int argc, char *argv[]) {
|
||||||
switch (main_event->type) {
|
switch (main_event->type) {
|
||||||
|
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
printf ("Quit event detected, now exiting. See ya! :)\n");
|
printf ("Quit event detected, now exiting.\n");
|
||||||
printf ("MMXXIII Ty3r0X - The Eye shall forsee...\n");
|
|
||||||
SDL_DestroyRenderer (main_render);
|
SDL_DestroyRenderer (main_render);
|
||||||
SDL_DestroyWindow (window);
|
SDL_DestroyWindow (window);
|
||||||
SDL_Quit ();
|
SDL_Quit ();
|
||||||
|
@ -127,13 +131,17 @@ main (int argc, char *argv[]) {
|
||||||
printf ("Mouse cursor is inside the square at position (%d,%d)\n",
|
printf ("Mouse cursor is inside the square at position (%d,%d)\n",
|
||||||
main_event->motion.x,
|
main_event->motion.x,
|
||||||
main_event->motion.y);
|
main_event->motion.y);
|
||||||
|
|
||||||
ray.x *= -1;
|
ray.x *= -1;
|
||||||
ray.y *= -1;
|
ray.y *= -1;
|
||||||
|
|
||||||
rectangle->x = rand () % (int) (SCREEN_WIDTH - 1 - RECT_SIZE);
|
rectangle->x = rand () % (int) (SCREEN_WIDTH - 1 - RECT_SIZE);
|
||||||
rectangle->y = rand () % (int) (SCREEN_HEIGHT - 1 - RECT_SIZE);
|
rectangle->y = rand () % (int) (SCREEN_HEIGHT - 1 - RECT_SIZE);
|
||||||
bg_red = rand () & HEX_POKE;
|
|
||||||
bg_green = rand () & HEX_POKE;
|
bg_red = rand () & HEX_POKE;
|
||||||
bg_blue = rand () & HEX_POKE;
|
bg_green = rand () & HEX_POKE;
|
||||||
|
bg_blue = rand () & HEX_POKE;
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -141,6 +149,7 @@ main (int argc, char *argv[]) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Constantly increment / decrement rectangle position */
|
/* Constantly increment / decrement rectangle position */
|
||||||
|
|
||||||
rectangle->x = rectangle->x + (1 * ray.x);
|
rectangle->x = rectangle->x + (1 * ray.x);
|
||||||
|
|
Loading…
Reference in New Issue