summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-05-08 19:29:52 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-05-08 19:29:52 +1000
commitf844536c0a3a4ba397f586897482dcb0f7550f5b (patch)
treeafd1eca6a69c01ceea5483baccf64ab666a4403b /src/main.c
parentc1d5bf8ab7648418fa7120ea4868205f3cf7e857 (diff)
started graphical application, plus other stuff
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..dd7f306
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,68 @@
+#include"include.h"
+
+
+#define SCALE 2
+
+#define CHR_WIDTH 5
+#define CHR_HEIGHT 8
+
+#define WIDTH_SPACE 1
+
+#define MIN_WIDTH (40 * CHR_WIDTH)
+#define MIN_HEIGHT (24 * CHR_HEIGHT)
+
+int main(){
+ // INITIALIZATION
+ SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
+ SDL_Window* window = SDL_CreateWindow(
+ "Apple C",
+ SDL_WINDOWPOS_CENTERED,
+ SDL_WINDOWPOS_CENTERED,
+ MIN_WIDTH * SCALE,
+ MIN_HEIGHT * SCALE,
+ SDL_WINDOW_SHOWN
+ );
+ SDL_Renderer* render = SDL_CreateRenderer(window, -1, 0);
+ SDL_Surface* font_surface = SDL_LoadBMP("font.bmp");
+ SDL_Texture* font_texture = SDL_CreateTextureFromSurface(render, font_surface);
+ SDL_FreeSurface(font_surface);
+
+ SDL_Rect character = {
+ .x = 0,
+ .y = 0,
+ .w = CHR_WIDTH,
+ .h = CHR_HEIGHT
+ };
+
+ SDL_Rect draw_character = {
+ .x = 0,
+ .y = 0,
+ .w = CHR_WIDTH * SCALE,
+ .h = CHR_HEIGHT * SCALE
+ };
+
+ SDL_SetRenderDrawColor (render, 0, 0, 0, 255);
+ SDL_RenderClear (render);
+
+ for(int i = 0; i < 500; i++){
+
+ SDL_RenderCopy (render, font_texture, &character, &draw_character);
+ SDL_RenderPresent (render);
+
+
+ character.x = (i % 0x10) * CHR_WIDTH;
+ draw_character.x += draw_character.w;
+ if(i % 2 == 1) draw_character.y += draw_character.h;
+ if(draw_character.x > MIN_WIDTH*SCALE) draw_character.x -= MIN_WIDTH*SCALE;
+ if(draw_character.y > MIN_HEIGHT*SCALE) draw_character.y -= MIN_HEIGHT*SCALE;
+ SDL_Delay(40);
+ }
+
+
+
+ // Just delay before it dies
+ //SDL_Delay(5000);
+
+ SDL_Quit();
+ return 0;
+} \ No newline at end of file