summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2018-07-12 11:51:00 +0300
committerOxore <oxore@protonmail.com>2018-07-12 11:51:00 +0300
commitd3fddd7d28f314a6738f2a0ba4d9f58024b01984 (patch)
tree7345455bdc6f051289ffa9854fcad2001a55a223 /src/main.c
parent9a9711945c2add826e5887aabe2330bee9042b4b (diff)
Introduce testing with munit, refactor
Split unicode routines from text. Testing: add munit submodule, move translation units with main functions to separate folder, make corresponding changes in Makefile. Make simple test for unicode handling routine. Remove _vimrc_local. test.c: optimize includes. Add test run to .travis.yml.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index bf9014a..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <SFML/System/Clock.h>
-#include <SFML/Window/Keyboard.h>
-#include <SFML/Graphics/RenderWindow.h>
-#include <SFML/Graphics/Font.h>
-
-#include "common.h"
-#include "idlist.h"
-#include "vector.h"
-#include "text.h"
-#include "field.h"
-#include "painter.h"
-#include "engine.h"
-#include "tet_conf.h"
-
-sfRenderWindow *window;
-struct idlist *texts;
-
-struct field fld, nxt;
-struct game game = {
- .started = 0,
- .paused = 0,
- .scoreCurrent = 0,
- .level = 1,
- .moveLatency = L00LATENCY,
- .lines = 0
-};
-
-static void handleWindowEvents() {
- sfEvent event;
- while (sfRenderWindow_pollEvent(window, &event))
- if (event.type == sfEvtClosed)
- sfRenderWindow_close(window);
-}
-
-static void register_text(void *obj)
-{
- struct text *text = obj;
- text->id = painter_register_text(text);
-}
-
-int main()
-{
- srand(time(NULL));
- game.gameTick = sfClock_create();
- game.putTick = sfClock_create();
- game.mTick = sfClock_create();
- game.repPushDown = sfClock_create();
- game.repKeyLeft = sfClock_create();
- game.repKeyRight = sfClock_create();
- painter_load_font("dat/arial.ttf");
-
- sfVideoMode mode = (sfVideoMode){450, 570, 32};
- window = sfRenderWindow_create(mode, windowName_conf, sfResize | sfClose, NULL);
- if (!window)
- exit(EXIT_FAILURE);
- sfRenderWindow_setFramerateLimit(window, 60);
- painter_set_window(window);
-
- fld.pos = FLD_POS;
- fld.size = (struct vector2ui){.x = FLD_SIZE_X, .y = FLD_SIZE_Y};
- fld.bound = (struct vector2ui){.x = FLD_BOUND_X, .y = FLD_BOUND_Y};
- fld.shape_cnt = 2;
- field_init(&fld);
- fld.shape[0].attr |= SHP_ATTR_GHOST;
-
- nxt.pos = NXT_POS;
- nxt.size = NXT_SIZE;
- nxt.bound = NXT_SIZE;
- nxt.shape_cnt = 3;
- nxt.attr |= FLD_ATTR_HIDE_EMPTY_CELLS | FLD_ATTR_INVISIBLE;
- field_init(&nxt);
- nxt.shape[0].y = 4;
- nxt.shape[1].y = 1;
- nxt.shape[2].y = -2;
-
- fld.id = painter_register_field(&fld);
- nxt.id = painter_register_field(&nxt);
- field_fill_random(&fld);
- painter_update_field(fld.id, &fld);
- painter_update_field(nxt.id, &nxt);
-
- texts = load_texts("dat/texts.yaml");
-
- list_foreach(texts, register_text);
-
- transition_init();
- while (sfRenderWindow_isOpen(window)) {
- handleWindowEvents();
- main_loop();
- }
-
- list_foreach(texts, text_destroy);
- list_destroy(texts);
-
- painter_destroy_drawables();
- field_deinit(&fld);
- field_deinit(&nxt);
-
- if (window) {
- sfRenderWindow_destroy(window);
- window = 0;
- }
- painter_destroy_font();
- sfClock_destroy(game.gameTick);
- sfClock_destroy(game.putTick);
- sfClock_destroy(game.mTick);
- sfClock_destroy(game.repPushDown);
- sfClock_destroy(game.repKeyLeft);
- sfClock_destroy(game.repKeyRight);
- return EXIT_SUCCESS;
-}