First game engine I made
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

render.c 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <SDL2/SDL.h>
  4. #include <SDL2/SDL_image.h>
  5. #include "render.h"
  6. void setuprender(SDL_Window* win, SDL_Renderer* ren){
  7. printf("Set up renderer.\n");
  8. window = win;//THESE TWO ARE CORRECT. THE RENDERER AND WINDOW EQUAL THE ABBREVIATED VERSIONS
  9. renderer = ren;
  10. //IMG_Init(IMG_INIT_PNG);
  11. }
  12. void destroyrender(){
  13. printf("Destroyed renderer.\n");
  14. SDL_FreeSurface(loadingsurface);
  15. SDL_DestroyTexture(loadingtexture);
  16. }
  17. //void drawsprite(int xpos, int ypos, int width, int height, float rotation, int midpointx, int midpointy){
  18. //SDL_RenderCopyEx(renderer, grass, NULL, &startup_rect);
  19. //}
  20. void drawbackground(){
  21. }
  22. void drawdebug(){
  23. }
  24. void drawopeningscene(){
  25. static float iii = 0.0f;
  26. static int finalend = 0;
  27. if(finalend == 1024){
  28. return;
  29. }
  30. static int reverse = 0;
  31. //SDL_RenderClear(renderer);
  32. //SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
  33. //SDL_Surface* loadedSurface = IMG_Load( path.c_str() );
  34. int i;
  35. int ii;
  36. for(i = 0; i < 255; i++){
  37. //printf("draw: %d", i);
  38. for(ii = 0; ii < 255; ii++){
  39. SDL_RenderDrawPoint(renderer, iii + i, iii + ii);
  40. SDL_SetRenderDrawColor(renderer, 10, 56, 255, 255);
  41. //SDL_RenderDrawLine(renderer, 0, 0, iii + i, iii);
  42. SDL_SetRenderDrawColor(renderer, 100, 0, 55, 255);
  43. //SDL_RenderDrawLine(renderer, 0, 0, iii, iii + ii);
  44. SDL_SetRenderDrawColor(renderer, 120, iii, ii, 255);
  45. //printf("kookokokok.");
  46. }
  47. SDL_SetRenderDrawColor(renderer, 20, 200, 58, 20);//set all to 0 for black refresh
  48. }
  49. //SDL_RenderPresent(renderer);
  50. if(iii == 255){
  51. reverse = 1;
  52. }
  53. if(iii == 0){
  54. reverse = 0;
  55. }
  56. if(reverse == 0){
  57. iii+= 0.5f;
  58. } else {
  59. iii-= 0.5f;
  60. }
  61. //printf("%f\n", iii);
  62. finalend++;
  63. }
  64. void pushscreen(){
  65. SDL_RenderPresent(renderer);
  66. SDL_RenderClear(renderer);
  67. }