aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/init-multi.c74
-rwxr-xr-xlib/init-multi.h15
-rw-r--r--[-rwxr-xr-x]lib/init.c17
-rw-r--r--[-rwxr-xr-x]lib/init.h2
-rw-r--r--lib/vectorlib.c (renamed from lib/global_objects.c)0
5 files changed, 13 insertions, 95 deletions
diff --git a/lib/init-multi.c b/lib/init-multi.c
deleted file mode 100755
index 734835c..0000000
--- a/lib/init-multi.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <time.h>
-#include <init-multi.h>
-
-#include <SDL2/SDL.h>
-#include <SDL2/SDL_video.h>
-
-int main(int argc, char *argv[])
-{
- if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
- SDL_Log("SDL fails to initialize! %s\n", SDL_GetError());
-
- int startw=600;
- int starth=600;
-
- SDL_Window *window = SDL_CreateWindow(PROJECT_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, startw, starth, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
- if (!window) {
- printf("Failed to create window: %s\n", SDL_GetError());
- }
- SDL_Renderer *renderer = SDL_CreateRenderer(window,-1,SDL_RENDERER_SOFTWARE);
- if (!renderer) {
- printf("Failed to create renderer: %s\n", SDL_GetError());
- }
-
- srand(time(NULL));
- OBJECT_INER obj_storage[obj_n];
-
- STUFFS stuff = {
- startw,
- starth,
- false,
- 0,
- 0,
- (OBJECT){},
- };
-
- init_stuffs(startw,starth,obj_storage,&stuff);
-
-
- for (int i = 0; i < obj_n; i++)
- stuff.obj.objs[i] = &obj_storage[i];
-
- SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
-
- bool quit = false;
- SDL_Event e;
- while (!quit) {
- while (SDL_PollEvent(&e)) {
- if (e.type == SDL_QUIT) {
- quit = true;
- }
- else if(e.type == SDL_MOUSEBUTTONDOWN){
- if(e.button.button==SDL_BUTTON_LEFT){
- stuff.mousedown=true;
- } else if(e.button.button==SDL_BUTTON_RIGHT){
- }
- } else if(e.type==SDL_MOUSEBUTTONUP){
- stuff.mousedown=false;
- }
- stuff.mx=e.button.x;
- stuff.my=e.button.y;
- }
- draw(renderer,window,&stuff);
- SDL_Delay(10);
- }
-
- SDL_DestroyRenderer(renderer);
- SDL_DestroyWindow(window);
- SDL_QuitSubSystem(SDL_INIT_VIDEO);
- SDL_Quit();
-
- return 0;
-}
diff --git a/lib/init-multi.h b/lib/init-multi.h
deleted file mode 100755
index 72bb366..0000000
--- a/lib/init-multi.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef inithell
-#define inithell
-
-#include <stdio.h>
-#include <stdbool.h>
-
-typedef struct{
- int width;
- int height;
- bool mousedown;
- int mx;
- int my;
- OBJECT obj;
-} STUFFS;
-#endif
diff --git a/lib/init.c b/lib/init.c
index 6adb878..5e32a4b 100755..100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -11,8 +11,8 @@ int main(int argc, char *argv[])
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
SDL_Log("SDL fails to initialize! %s\n", SDL_GetError());
- int startw=400;
- int starth=400;
+ int startw=600;
+ int starth=600;
SDL_Window *window = SDL_CreateWindow(PROJECT_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, startw, starth, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
if (!window) {
@@ -23,9 +23,8 @@ int main(int argc, char *argv[])
printf("Failed to create renderer: %s\n", SDL_GetError());
}
-
srand(time(NULL));
- OBJECT obj = init_stuffs(startw,starth);
+ OBJECT_INER obj_storage[obj_n];
STUFFS stuff = {
startw,
@@ -33,9 +32,17 @@ int main(int argc, char *argv[])
false,
0,
0,
- &obj,
+ (OBJECT){},
};
+ init_stuffs(startw,starth,obj_storage,&stuff);
+
+
+ for (int i = 0; i < obj_n; i++)
+ stuff.obj.objs[i] = &obj_storage[i];
+
+ SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
+
bool quit = false;
SDL_Event e;
while (!quit) {
diff --git a/lib/init.h b/lib/init.h
index a4d9736..72bb366 100755..100644
--- a/lib/init.h
+++ b/lib/init.h
@@ -10,6 +10,6 @@ typedef struct{
bool mousedown;
int mx;
int my;
- OBJECT *obj;
+ OBJECT obj;
} STUFFS;
#endif
diff --git a/lib/global_objects.c b/lib/vectorlib.c
index 2e3f2fd..2e3f2fd 100644
--- a/lib/global_objects.c
+++ b/lib/vectorlib.c