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.

boxengine.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <SDL2/SDL.h>
  4. #include <SDL2/SDL_image.h>
  5. #include "boxengine.h"
  6. #include "render.h"
  7. #include "ui.h"
  8. #include "sprite.h"
  9. /*Ideas
  10. make each module be: spritehandler(working on), renderer(check), audio, data, inputoutput(work with keyboard and custm file format,
  11. such as loadtexture(), or loadmap(), or loadfont(), etcfiles), networking, UI functinality and rendering(check, well eh...). UI rendered last for always on top
  12. //when I figure out the algorithms for this all, I will make it all render to a texture for color and efect manipulation. The custom file format needs to be done first.
  13. Utility next: Tile based editor.
  14. */
  15. int setup(char *title, int width, int height, int dimension, int method, int framing){
  16. //sets up plain old SDL
  17. int status = 0;
  18. window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
  19. screenwidth = width;
  20. screenheight = height;
  21. printf("Title: %s\n", title);
  22. if(method == HARDWARE){
  23. renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
  24. } else{
  25. renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
  26. }
  27. //iffy code for setting up continuing modules. Correct this with error handling later
  28. setuprender(window, renderer);
  29. setupui(window, renderer);
  30. return status;
  31. }
  32. int destroy(){
  33. int status = 0;
  34. //iffy code for destroying modules
  35. destroyrender();
  36. destroyui();
  37. SDL_DestroyWindow(window);
  38. SDL_DestroyRenderer(renderer);
  39. SDL_Quit();
  40. return status;
  41. }