diff --git a/small3dlib.h b/small3dlib.h index 4ba85da..4d8a2bb 100644 --- a/small3dlib.h +++ b/small3dlib.h @@ -1887,7 +1887,7 @@ void S3L_drawScene(S3L_Scene scene) #if S3L_SORT != S3L_SORT_NONE // TODO: CHANGE BUBBLE SORT TO SOMETHING FASTER! - for (int16_t i = S3L_sortArrayLength - 1; i >= 0; --i) + for (int16_t i = S3L_sortArrayLength - 2; i >= 0; --i) for (S3L_Index j = 0; j <= i; ++j) { if (S3L_sortArray[j].sortValue < S3L_sortArray[j + 1].sortValue) diff --git a/testSDL.c b/testSDL.c index 0dce773..b0e063e 100644 --- a/testSDL.c +++ b/testSDL.c @@ -207,6 +207,8 @@ int main() draw(); SDL_UpdateTexture(texture,NULL,pixels,S3L_RESOLUTION_X * sizeof(uint32_t)); + int code = 0; + while (SDL_PollEvent(&event)) { switch (event.type) @@ -216,11 +218,19 @@ int main() break; case SDL_KEYDOWN: - keys['a' + event.key.keysym.scancode - SDL_SCANCODE_A] = 1; + code = 'a' + event.key.keysym.scancode - SDL_SCANCODE_A; + + if (code >= 0 && code <= 255) + keys[code] = 1; + break; case SDL_KEYUP: - keys['a' + event.key.keysym.scancode - SDL_SCANCODE_A] = 0; + code = 'a' + event.key.keysym.scancode - SDL_SCANCODE_A; + + if (code >= 0 && code <= 255) + keys[code] = 0; + break; default: