Added delay, finally CPU can breathe...
This commit is contained in:
parent
1bf8a01ac5
commit
01432a529c
|
@ -71,8 +71,8 @@ init_program (void) {
|
|||
/* Initialize rectangle*/
|
||||
|
||||
rectangle = calloc (1, sizeof (SDL_Rect));
|
||||
rectangle->w = 100;
|
||||
rectangle->h = 100;
|
||||
rectangle->w = RECT_SIZE;
|
||||
rectangle->h = RECT_SIZE;
|
||||
|
||||
/* A new variable is created called main_event, which is a SDL_Event type, which itself is a structure
|
||||
* of multiple structures... of events... */
|
||||
|
|
|
@ -67,8 +67,8 @@ main (int argc, char *argv[]) {
|
|||
/* Constantly initialize boolean values for corners, each for loop
|
||||
* iteration they change values */
|
||||
|
||||
bool x_limit = (rectangle->x == 0 || rectangle->x == SCREEN_WIDTH);
|
||||
bool y_limit = (rectangle->y == 0 || rectangle->y == SCREEN_HEIGHT);
|
||||
bool x_limit = (rectangle->x == 0 || rectangle->x == SCREEN_WIDTH - RECT_SIZE);
|
||||
bool y_limit = (rectangle->y == 0 || rectangle->y == SCREEN_HEIGHT - RECT_SIZE);
|
||||
|
||||
/* Normally the rect constantly goes up diagonally, if it reaches a
|
||||
* corner the next position gets multiplied with -1 on its respective
|
||||
|
@ -110,6 +110,8 @@ main (int argc, char *argv[]) {
|
|||
rectangle->x = rectangle->x + (1 * ray.x);
|
||||
rectangle->y = rectangle->y + (1 * ray.y);
|
||||
|
||||
SDL_Delay (3);
|
||||
|
||||
/*while (SDL_PollEvent (main_event)) {
|
||||
switch (main_event->type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#define COLOR_G 0xA5
|
||||
#define COLOR_B 0x00
|
||||
|
||||
#define RECT_SIZE 100
|
||||
|
||||
extern SDL_Window *window;
|
||||
extern SDL_Renderer *main_render;
|
||||
extern SDL_Texture *background;
|
||||
|
|
Loading…
Reference in New Issue