10 #define TESTING_LUA_BACKEND
12 #include <gtest/gtest.h>
13 #include <game_manager/lua_backend/lua_backend.cpp>
14 #include <main/timer.hpp>
22 std::string hash_file(
const std::string &path) {
23 return test_subject.hash_file(path);
26 std::string hash_string_lua(
const std::string &
string) {
27 return test_subject.hash_string(
string);
30 lua_State *get_lua_state() {
31 return test_subject.L;
37 void SetUp()
override {
43 void TearDown()
override {
51 std::string result = hash_file(
"lua_scripts/test_script_playSound.lua");
52 std::string resulting_integer = result.substr(10, std::string::npos);
53 resulting_integer.erase(resulting_integer.size() - 10);
55 std::stoull(resulting_integer);
56 }
catch (
const std::invalid_argument &e) {
59 }
catch (
const std::out_of_range &e) {
66 std::string result = hash_file(
"lua_scripts/test_script_playMusic.lua");
67 std::string resulting_integer = result.substr(10, std::string::npos);
68 resulting_integer.erase(resulting_integer.size() - 10);
70 std::stoull(resulting_integer);
71 }
catch (
const std::invalid_argument &e) {
74 }
catch (
const std::out_of_range &e) {
81 std::string result = hash_file(
"lua_scripts/test_script_keyHeld.lua");
82 std::string resulting_integer = result.substr(8, std::string::npos);
83 resulting_integer.erase(resulting_integer.size() - 3);
85 std::stoull(resulting_integer);
86 }
catch (
const std::invalid_argument &e) {
89 }
catch (
const std::out_of_range &e) {
96 std::string result = hash_file(
"lua_scripts/test_script_keyPressed.lua");
97 std::string resulting_integer = result.substr(11, std::string::npos);
98 resulting_integer.erase(resulting_integer.size() - 2);
100 std::stoull(resulting_integer);
101 }
catch (
const std::invalid_argument &e) {
104 }
catch (
const std::out_of_range &e) {
111 std::string result = hash_file(
"lua_scripts/test_script_keyReleased.lua");
112 std::string resulting_integer = result.substr(12, std::string::npos);
113 resulting_integer.erase(resulting_integer.size() - 2);
115 std::stoull(resulting_integer);
116 }
catch (
const std::invalid_argument &e) {
119 }
catch (
const std::out_of_range &e) {
126 std::string result = hash_file(
"lua_scripts/test_script_setClickKey.lua");
127 std::string resulting_integer = result.substr(12, std::string::npos);
128 resulting_integer.erase(resulting_integer.size() - 3);
130 std::stoull(resulting_integer);
131 }
catch (
const std::invalid_argument &e) {
134 }
catch (
const std::out_of_range &e) {
141 std::string result = hash_file(
"lua_scripts/test_script_keyAnnotation.lua");
142 std::string resulting_integer = result.substr(10, std::string::npos);
144 std::stoull(resulting_integer);
145 }
catch (
const std::invalid_argument &e) {
148 }
catch (
const std::out_of_range &e) {
155 std::string result = hash_string_lua(
"playSound(\"sound.wav\", 100, 1)");
156 std::string resulting_integer = result.substr(10, std::string::npos);
157 resulting_integer.erase(resulting_integer.size() - 9);
159 std::stoull(resulting_integer);
160 }
catch (
const std::invalid_argument &e) {
163 }
catch (
const std::out_of_range &e) {
170 std::string result = hash_file(
"lua_scripts/test_script_audioAnnotation.lua");
171 std::string resulting_integer = result.substr(12, std::string::npos);
173 std::stoull(resulting_integer);
174 }
catch (
const std::invalid_argument &e) {
177 }
catch (
const std::out_of_range &e) {
184 std::string result = hash_string_lua(
"playMusic(\"music.mp3\", 100, 1)");
185 std::string resulting_integer = result.substr(10, std::string::npos);
186 resulting_integer.erase(resulting_integer.size() - 9);
188 std::stoull(resulting_integer);
189 }
catch (
const std::invalid_argument &e) {
192 }
catch (
const std::out_of_range &e) {
199 std::string result = hash_string_lua(
"keyHeld(\"JUMP\")");
200 std::string resulting_integer = result.substr(8, std::string::npos);
201 resulting_integer.erase(resulting_integer.size() - 1);
203 std::stoull(resulting_integer);
204 }
catch (
const std::invalid_argument &e) {
207 }
catch (
const std::out_of_range &e) {
214 std::string result = hash_string_lua(
"keyPressed(\"JUMP\")");
215 std::string resulting_integer = result.substr(11, std::string::npos);
216 resulting_integer.erase(resulting_integer.size() - 1);
218 std::stoull(resulting_integer);
219 }
catch (
const std::invalid_argument &e) {
222 }
catch (
const std::out_of_range &e) {
229 std::string result = hash_string_lua(
"keyReleased(\"JUMP\")");
230 std::string resulting_integer = result.substr(12, std::string::npos);
231 resulting_integer.erase(resulting_integer.size() - 1);
233 std::stoull(resulting_integer);
234 }
catch (
const std::invalid_argument &e) {
237 }
catch (
const std::out_of_range &e) {
244 std::string result = hash_string_lua(
"setClickKey(\"MOUSE1\")");
245 std::string resulting_integer = result.substr(12, std::string::npos);
246 resulting_integer.erase(resulting_integer.size() - 1);
248 std::stoull(resulting_integer);
249 }
catch (
const std::invalid_argument &e) {
252 }
catch (
const std::out_of_range &e) {
259 ::testing::internal::CaptureStdout();
260 ASSERT_EQ(0, test_subject.run_file(
"lua_scripts/test_script_simple.lua"));
261 ASSERT_EQ(
"4\n", testing::internal::GetCapturedStdout());
265 ::testing::FLAGS_gtest_death_test_style =
"threadsafe";
268 ASSERT_EXIT(test_subject.run_file(
"lua_scripts/test_script_broken.lua"), ::testing::ExitedWithCode(3),
".*");
271 ASSERT_EXIT(test_subject.run_file(
"lua_scripts/test_script_broken.lua"), ::testing::KilledBySignal(SIGABRT),
".*");
278 msg_bus->subscribe(SET_FULLSCREEN, &subscriber1);
281 test_subject.run_script(
"setFullscreenLua(true)");
288 ASSERT_EQ(SET_FULLSCREEN, result->msg_name);
289 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
294 std::string test_string =
"TEST_STRING";
295 size_t expected = ST::hash_string(test_string);
298 test_subject.run_script(
"return hashString(\"" + test_string +
"\")");
299 ASSERT_EQ(expected, lua_tointeger(get_lua_state(), -1));
305 double runtime = 500;
309 test_subject.run_script(
"delay(" + std::to_string(runtime) +
")");
312 ASSERT_NEAR(runtime,
static_cast<uint32_t
>(end_time - start_time), 250);
318 msg_bus->subscribe(SET_VSYNC, &subscriber1);
321 test_subject.run_script(
"setVsyncLua(true)");
327 ASSERT_EQ(SET_VSYNC, result->msg_name);
328 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
335 msg_bus->subscribe(START_LEVEL, &subscriber1);
336 std::string level_name =
"some_level";
339 test_subject.run_script(
"startLevelLua(\"" + level_name +
"\")");
345 ASSERT_EQ(START_LEVEL, result->msg_name);
346 ASSERT_EQ(level_name, *
static_cast<std::string *
>(result->
get_data()));
352 msg_bus->subscribe(LOAD_LEVEL, &subscriber1);
353 std::string level_name =
"some_level";
356 test_subject.run_script(
"loadLevel(\"" + level_name +
"\")");
362 ASSERT_EQ(LOAD_LEVEL, result->msg_name);
363 ASSERT_EQ(level_name, *
static_cast<std::string *
>(result->
get_data()));
369 msg_bus->subscribe(SHOW_MOUSE, &subscriber1);
372 test_subject.run_script(
"showMouseCursor()");
378 ASSERT_EQ(SHOW_MOUSE, result->msg_name);
379 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
385 msg_bus->subscribe(SHOW_MOUSE, &subscriber1);
388 test_subject.run_script(
"hideMouseCursor()");
394 ASSERT_EQ(SHOW_MOUSE, result->msg_name);
395 ASSERT_FALSE(
static_cast<bool>(result->base_data0));
402 msg_bus->subscribe(SHOW_FPS, &subscriber1);
405 test_subject.run_script(
"showFps(true)");
411 ASSERT_EQ(SHOW_FPS, result->msg_name);
412 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
418 msg_bus->subscribe(SHOW_METRICS, &subscriber1);
421 test_subject.run_script(
"showMetrics(true)");
427 ASSERT_EQ(SHOW_METRICS, result->msg_name);
428 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
435 msg_bus->subscribe(END_GAME, &subscriber1);
438 test_subject.run_script(
"endGame()");
444 ASSERT_EQ(END_GAME, result->msg_name);
451 msg_bus->subscribe(SET_FLOOR, &subscriber1);
454 test_subject.run_script(
"setLevelFloor(500)");
460 ASSERT_EQ(SET_FLOOR, result->msg_name);
461 ASSERT_EQ(500,
static_cast<int32_t
>(result->base_data0));
467 msg_bus->subscribe(UNLOAD_LEVEL, &subscriber1);
468 std::string level_name =
"some_level";
471 test_subject.run_script(
"unloadLevel(\"" + level_name +
"\")");
477 ASSERT_EQ(UNLOAD_LEVEL, result->msg_name);
478 ASSERT_EQ(level_name, *
static_cast<std::string *
>(result->
get_data()));
484 msg_bus->subscribe(SET_GRAVITY, &subscriber1);
487 test_subject.run_script(
"setGravity(12)");
493 ASSERT_EQ(SET_GRAVITY, result->msg_name);
494 ASSERT_EQ(12,
static_cast<uint8_t
>(result->base_data0));
499 gGame_managerLua->gravity = 11;
502 test_subject.run_script(
"return getGravity()");
504 gGame_managerLua->gravity = 0;
507 ASSERT_EQ(11, lua_tointeger(get_lua_state(), -1));
514 msg_bus->subscribe(PAUSE_PHYSICS, &subscriber1);
517 test_subject.run_script(
"pausePhysics()");
523 ASSERT_EQ(PAUSE_PHYSICS, result->msg_name);
530 msg_bus->subscribe(UNPAUSE_PHYSICS, &subscriber1);
533 test_subject.run_script(
"unpausePhysics()");
539 ASSERT_EQ(UNPAUSE_PHYSICS, result->msg_name);
546 msg_bus->subscribe(PLAY_SOUND, &subscriber1);
547 std::string test_string =
"some_sound.wav";
548 uint16_t expected = ST::hash_string(test_string);
551 test_subject.run_script(
"playSound(\"" + test_string +
"\", 100, 3)");
556 ASSERT_EQ(PLAY_SOUND, result->msg_name);
559 auto data = result->base_data0;
561 ASSERT_EQ(expected, (data & 0x0000ffff));
562 ASSERT_EQ(100, (data >> 16) & 0x000000ff);
563 ASSERT_EQ(3, (data >> 24) & 0x000000ff);
569 msg_bus->subscribe(PLAY_MUSIC, &subscriber1);
570 std::string test_string =
"some_music.mp3";
571 uint16_t expected = ST::hash_string(test_string);
574 test_subject.run_script(
"playMusic(\"" + test_string +
"\", 128, 2)");
579 ASSERT_EQ(PLAY_MUSIC, result->msg_name);
581 auto data = result->base_data0;
583 ASSERT_EQ(expected, (data & 0x0000ffff));
584 ASSERT_EQ(128, (data >> 16) & 0x000000ff);
585 ASSERT_EQ(2, (data >> 24) & 0x000000ff);
591 msg_bus->subscribe(STOP_MUSIC, &subscriber1);
594 test_subject.run_script(
"stopMusic()");
600 ASSERT_EQ(STOP_MUSIC, result->msg_name);
607 msg_bus->subscribe(SET_AUDIO_ENABLED, &subscriber1);
610 test_subject.run_script(
"setAudioEnabledLua(true)");
616 ASSERT_EQ(SET_AUDIO_ENABLED, result->msg_name);
617 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
623 msg_bus->subscribe(STOP_ALL_SOUNDS, &subscriber1);
626 test_subject.run_script(
"stopAllSounds()");
632 ASSERT_EQ(STOP_ALL_SOUNDS, result->msg_name);
639 msg_bus->subscribe(SET_MUSIC_VOLUME, &subscriber1);
642 test_subject.run_script(
"setMusicVolume(50)");
648 ASSERT_EQ(SET_MUSIC_VOLUME, result->msg_name);
649 ASSERT_EQ(50,
static_cast<uint8_t
>(result->base_data0));
655 msg_bus->subscribe(SET_SOUNDS_VOLUME, &subscriber1);
658 test_subject.run_script(
"setSoundsVolume(50)");
664 ASSERT_EQ(SET_SOUNDS_VOLUME, result->msg_name);
665 ASSERT_EQ(50,
static_cast<uint8_t
>(result->base_data0));
671 msg_bus->subscribe(LOAD_ASSET, &subscriber1);
674 test_subject.run_script(
"loadAsset(\"path/to/asset.webp\")");
680 ASSERT_EQ(LOAD_ASSET, result->msg_name);
681 ASSERT_EQ(
"path/to/asset.webp", *
static_cast<std::string *
>(result->
get_data()));
687 msg_bus->subscribe(UNLOAD_ASSET, &subscriber1);
690 test_subject.run_script(
"unloadAsset(\"path/to/asset.webp\")");
696 ASSERT_EQ(UNLOAD_ASSET, result->msg_name);
697 ASSERT_EQ(
"path/to/asset.webp", *
static_cast<std::string *
>(result->
get_data()));
703 msg_bus->subscribe(SET_DARKNESS, &subscriber1);
706 test_subject.run_script(
"setDarkness(250)");
712 ASSERT_EQ(SET_DARKNESS, result->msg_name);
713 ASSERT_EQ(250,
static_cast<uint8_t
>(result->base_data0));
719 msg_bus->subscribe(ENABLE_LIGHTING, &subscriber1);
722 test_subject.run_script(
"enableLighting(false)");
728 ASSERT_EQ(ENABLE_LIGHTING, result->msg_name);
729 ASSERT_FALSE(
static_cast<bool>(result->base_data0));
733 game_mngr->fullscreen_status =
false;
734 test_subject.run_script(
"return getFullscreenStatus()");
737 ASSERT_FALSE(lua_toboolean(get_lua_state(), -1));
742 ::testing::internal::CaptureStdout();
745 test_subject.run_script(
"use(\"test_script_simple.lua\")");
746 ASSERT_EQ(
"4\n", testing::internal::GetCapturedStdout());
750 test_subject.run_script(
"setBackground(\"some_bg.webp\")");
751 ASSERT_EQ(2, game_mngr->get_level_calls);
755 test_subject.run_script(
"setBackgroundColor(255, 255, 255, 255)");
756 ASSERT_EQ(1, game_mngr->get_level_calls);
760 game_mngr->vsync_flag =
true;
761 test_subject.run_script(
"return getVsyncState()");
764 ASSERT_TRUE(lua_toboolean(get_lua_state(), -1));
771 msg_bus->subscribe(SET_WINDOW_BRIGHTNESS, &subscriber1);
774 test_subject.run_script(
"setBrightness(250)");
780 ASSERT_EQ(SET_WINDOW_BRIGHTNESS, result->msg_name);
781 ASSERT_EQ(250, *
static_cast<float *
>(result->
get_data()));
785 test_subject.run_script(
"setOverlay(\"some_bg.webp\", 3)");
786 ASSERT_EQ(2, game_mngr->get_level_calls);
787 ASSERT_EQ(3, game_mngr->get_level()->overlay_sprite_num);
788 ASSERT_EQ(ST::hash_string(
"some_bg.webp"), game_mngr->get_level()->overlay);
792 game_mngr->music_volume_level = 123;
793 test_subject.run_script(
"return getMusicVolume()");
796 ASSERT_EQ(123, lua_tointeger(get_lua_state(), -1));
800 game_mngr->sounds_volume_level = 123;
801 test_subject.run_script(
"return getSoundsVolume()");
804 ASSERT_EQ(123, lua_tointeger(get_lua_state(), -1));
808 test_subject.run_script(
"return isAudioEnabled()");
811 ASSERT_TRUE(lua_toboolean(get_lua_state(), -1));
815 test_subject.run_script(
"centerCamera(5)");
816 test_subject.run_script(
"centreCamera(2)");
819 ASSERT_EQ(2, game_mngr->center_camera_on_entity_calls);
823 test_subject.run_script(
"setLevelSize(5000, 5000)");
826 ASSERT_EQ(2, game_mngr->get_level_calls);
827 ASSERT_EQ(5000, game_mngr->get_level()->camera.limitX2);
828 ASSERT_EQ(5000, game_mngr->get_level()->camera.limitY2);
832 test_subject.run_script(
"return getMouseX()");
835 ASSERT_EQ(100, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
840 test_subject.run_script(
"return getMouseY()");
843 ASSERT_EQ(200, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
847 test_subject.run_script(
"return leftTrigger()");
850 ASSERT_EQ(100, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
854 test_subject.run_script(
"return rightTrigger()");
857 ASSERT_EQ(200, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
861 test_subject.run_script(
"return rightStickHorizontal()");
864 ASSERT_EQ(400, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
868 test_subject.run_script(
"return leftStickHorizontal()");
871 ASSERT_EQ(100, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
875 test_subject.run_script(
"return leftStickVertical()");
878 ASSERT_EQ(200, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
882 test_subject.run_script(
"return rightStickVertical()");
885 ASSERT_EQ(300, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
890 msg_bus->subscribe(CONTROLLER_RUMBLE, &subscriber1);
891 test_subject.run_script(
"return controllerRumble(0.7, 1000)");
897 ASSERT_EQ(CONTROLLER_RUMBLE, result->msg_name);
900 float strength = *
reinterpret_cast<float *
>(&result->base_data0);
901 uint16_t duration = result->base_data1;
903 ASSERT_EQ(0.7f, strength);
904 ASSERT_EQ(1000, duration);
908 TEST_F(
lua_backend_test, test_call_function_setLeftStickHorizontalThreshold) {
910 msg_bus->subscribe(SET_LEFT_JOYSTICK_HORIZONTAL_THRESHOLD, &subscriber1);
911 test_subject.run_script(
"setLeftStickHorizontalThreshold(1000)");
917 ASSERT_EQ(SET_LEFT_JOYSTICK_HORIZONTAL_THRESHOLD, result->msg_name);
920 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
922 ASSERT_EQ(1000, threshold);
925 TEST_F(
lua_backend_test, test_call_function_setLeftStickVerticalThreshold) {
927 msg_bus->subscribe(SET_LEFT_JOYSTICK_VERTICAL_THRESHOLD, &subscriber1);
928 test_subject.run_script(
"setLeftStickVerticalThreshold(1000)");
934 ASSERT_EQ(SET_LEFT_JOYSTICK_VERTICAL_THRESHOLD, result->msg_name);
937 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
939 ASSERT_EQ(1000, threshold);
942 TEST_F(
lua_backend_test, test_call_function_setRightStickHorizontalThreshold) {
944 msg_bus->subscribe(SET_RIGHT_JOYSTICK_HORIZONTAL_THRESHOLD, &subscriber1);
945 test_subject.run_script(
"setRightStickHorizontalThreshold(1000)");
951 ASSERT_EQ(SET_RIGHT_JOYSTICK_HORIZONTAL_THRESHOLD, result->msg_name);
954 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
956 ASSERT_EQ(1000, threshold);
959 TEST_F(
lua_backend_test, test_call_function_setRightStickVerticalThreshold) {
961 msg_bus->subscribe(SET_RIGHT_JOYSTICK_VERTICAL_THRESHOLD, &subscriber1);
962 test_subject.run_script(
"setRightStickVerticalThreshold(1000)");
968 ASSERT_EQ(SET_RIGHT_JOYSTICK_VERTICAL_THRESHOLD, result->msg_name);
971 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
973 ASSERT_EQ(1000, threshold);
978 msg_bus->subscribe(SET_LEFT_TRIGGER_THRESHOLD, &subscriber1);
979 test_subject.run_script(
"setLeftTriggerThreshold(1000)");
985 ASSERT_EQ(SET_LEFT_TRIGGER_THRESHOLD, result->msg_name);
988 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
990 ASSERT_EQ(1000, threshold);
995 msg_bus->subscribe(SET_RIGHT_TRIGGER_THRESHOLD, &subscriber1);
996 test_subject.run_script(
"setRightTriggerThreshold(1000)");
1001 ASSERT_TRUE(result);
1002 ASSERT_EQ(SET_RIGHT_TRIGGER_THRESHOLD, result->msg_name);
1005 uint16_t threshold =
static_cast<int16_t
>(result->base_data0);
1007 ASSERT_EQ(1000, threshold);
1011 test_subject.run_script(
"return keyHeld(\"SOME_KEY\")");
1014 ASSERT_TRUE(lua_toboolean(get_lua_state(), lua_gettop(get_lua_state())));
1018 test_subject.run_script(
"return keyPressed(\"SOME_KEY\")");
1021 ASSERT_TRUE(lua_toboolean(get_lua_state(), lua_gettop(get_lua_state())));
1025 test_subject.run_script(
"return keyReleased(\"SOME_KEY\")");
1028 ASSERT_TRUE(lua_toboolean(get_lua_state(), lua_gettop(get_lua_state())));
1033 test_subject.run_script(
"createLight(500, 600, 100, 50, 400)");
1036 ASSERT_EQ(1, game_mngr->get_level_calls);
1037 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1038 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1039 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1040 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1041 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1042 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1047 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1050 test_subject.run_script(
"setLightOriginX(0, 1000)");
1053 ASSERT_EQ(2, game_mngr->get_level_calls);
1054 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1055 ASSERT_EQ(1000, game_mngr->get_level()->lights.at(0).origin_x);
1056 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1057 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1058 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1059 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1064 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1067 test_subject.run_script(
"setLightOriginY(0, 1000)");
1070 ASSERT_EQ(2, game_mngr->get_level_calls);
1071 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1072 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1073 ASSERT_EQ(1000, game_mngr->get_level()->lights.at(0).origin_y);
1074 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1075 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1076 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1081 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1084 test_subject.run_script(
"return getLightOriginX(0)");
1087 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1090 ASSERT_EQ(2, game_mngr->get_level_calls);
1091 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1092 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1093 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1094 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1095 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1096 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1101 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1104 test_subject.run_script(
"return getLightOriginY(0)");
1107 ASSERT_EQ(600, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1110 ASSERT_EQ(2, game_mngr->get_level_calls);
1111 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1112 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1113 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1114 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1115 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1116 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1121 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1124 test_subject.run_script(
"setLightIntensity(0, 1000)");
1127 ASSERT_EQ(2, game_mngr->get_level_calls);
1128 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1129 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1130 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1131 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1132 ASSERT_EQ(1000, game_mngr->get_level()->lights.at(0).intensity);
1133 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1138 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1141 test_subject.run_script(
"return getLightIntensity(0)");
1144 ASSERT_EQ(50, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1147 ASSERT_EQ(2, game_mngr->get_level_calls);
1148 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1149 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1150 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1151 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1152 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1153 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1158 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1161 test_subject.run_script(
"return getLightRadius(0)");
1164 ASSERT_EQ(100, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1167 ASSERT_EQ(2, game_mngr->get_level_calls);
1168 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1169 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1170 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1171 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1172 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1173 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1178 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1181 test_subject.run_script(
"return setLightRadius(0, 300)");
1184 ASSERT_EQ(2, game_mngr->get_level_calls);
1185 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1186 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1187 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1188 ASSERT_EQ(300, game_mngr->get_level()->lights.at(0).radius);
1189 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1190 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1195 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1198 test_subject.run_script(
"return getLightBrightness(0)");
1201 ASSERT_EQ(400, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1204 ASSERT_EQ(2, game_mngr->get_level_calls);
1205 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1206 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1207 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1208 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1209 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1210 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1215 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1218 test_subject.run_script(
"return setLightBrightness(0, 300)");
1221 ASSERT_EQ(2, game_mngr->get_level_calls);
1222 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1223 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1224 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1225 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1226 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1227 ASSERT_EQ(300, game_mngr->get_level()->lights.at(0).brightness);
1232 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1235 test_subject.run_script(
"return isLightStatic(0)");
1238 ASSERT_FALSE(lua_toboolean(get_lua_state(), lua_gettop(get_lua_state())));
1241 ASSERT_EQ(2, game_mngr->get_level_calls);
1242 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1243 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1244 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1245 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1246 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1247 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1252 game_mngr->get_level()->lights.emplace_back(500, 600, 100, 50, 400);
1255 test_subject.run_script(
"return setLightStatic(0, true)");
1258 ASSERT_EQ(2, game_mngr->get_level_calls);
1259 ASSERT_EQ(1, game_mngr->get_level()->lights.size());
1260 ASSERT_EQ(500, game_mngr->get_level()->lights.at(0).origin_x);
1261 ASSERT_EQ(600, game_mngr->get_level()->lights.at(0).origin_y);
1262 ASSERT_EQ(100, game_mngr->get_level()->lights.at(0).radius);
1263 ASSERT_EQ(50, game_mngr->get_level()->lights.at(0).intensity);
1264 ASSERT_EQ(400, game_mngr->get_level()->lights.at(0).brightness);
1265 ASSERT_TRUE(game_mngr->get_level()->lights.at(0).is_static);
1269 test_subject.run_script(R
"(createTextObject(500, 600, "SOME_TEXT", "SOME_FONT.ttf", 40))");
1271 ASSERT_EQ(1, game_mngr->get_level_calls);
1272 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1273 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1274 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1275 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1276 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1277 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1279 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1280 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1281 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1282 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1288 game_mngr->get_level()->text_objects.emplace_back(
ST::text(500, 600, {255, 255, 255, 255},
1289 "SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1292 test_subject.run_script(
"setTextObjectColor(0, 100, 110, 120, 130)");
1295 ASSERT_EQ(2, game_mngr->get_level_calls);
1296 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1297 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1298 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1299 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1300 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1301 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1303 ASSERT_EQ(100, game_mngr->get_level()->text_objects.at(0).color.r);
1304 ASSERT_EQ(110, game_mngr->get_level()->text_objects.at(0).color.g);
1305 ASSERT_EQ(120, game_mngr->get_level()->text_objects.at(0).color.b);
1306 ASSERT_EQ(130, game_mngr->get_level()->text_objects.at(0).color.a);
1311 game_mngr->get_level()->text_objects.emplace_back(
ST::text(500, 600, {255, 255, 255, 255},
1312 "SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1314 test_subject.run_script(
"setTextObjectText(0, \"NEW_TEXT\")");
1317 ASSERT_EQ(2, game_mngr->get_level_calls);
1318 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1319 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1320 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1321 ASSERT_EQ(
"NEW_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1322 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1323 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1325 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1326 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1327 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1328 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1333 game_mngr->get_level()->text_objects.emplace_back(
ST::text(500, 600, {255, 255, 255, 255},
1334 "SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1336 test_subject.run_script(
"setTextObjectFont(0, \"NEW_FONT.ttf 40\")");
1339 ASSERT_EQ(2, game_mngr->get_level_calls);
1340 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1341 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1342 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1343 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1344 ASSERT_EQ(ST::hash_string(
"NEW_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1345 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1347 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1348 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1349 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1350 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1355 game_mngr->get_level()->text_objects.emplace_back(
1356 ST::text(500, 600, {255, 255, 255, 255},
"SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1358 test_subject.run_script(
"setTextObjectX(0, 123)");
1361 ASSERT_EQ(2, game_mngr->get_level_calls);
1362 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1363 ASSERT_EQ(123, game_mngr->get_level()->text_objects.at(0).x);
1364 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1365 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1366 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1367 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1369 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1370 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1371 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1372 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1377 game_mngr->get_level()->text_objects.emplace_back(
ST::text(500, 600, {255, 255, 255, 255},
1378 "SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1380 test_subject.run_script(
"setTextObjectY(0, 123)");
1383 ASSERT_EQ(2, game_mngr->get_level_calls);
1384 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1385 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1386 ASSERT_EQ(123, game_mngr->get_level()->text_objects.at(0).y);
1387 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1388 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1389 ASSERT_TRUE(game_mngr->get_level()->text_objects.at(0).is_visible);
1391 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1392 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1393 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1394 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1399 game_mngr->get_level()->text_objects.emplace_back(
ST::text(500, 600, {255, 255, 255, 255},
1400 "SOME_TEXT", ST::hash_string(
"SOME_FONT.ttf 40")));
1402 test_subject.run_script(
"setTextObjectVisible(0, false)");
1405 ASSERT_EQ(2, game_mngr->get_level_calls);
1406 ASSERT_EQ(1, game_mngr->get_level()->text_objects.size());
1407 ASSERT_EQ(500, game_mngr->get_level()->text_objects.at(0).x);
1408 ASSERT_EQ(600, game_mngr->get_level()->text_objects.at(0).y);
1409 ASSERT_EQ(
"SOME_TEXT", game_mngr->get_level()->text_objects.at(0).text_string);
1410 ASSERT_EQ(ST::hash_string(
"SOME_FONT.ttf 40"), game_mngr->get_level()->text_objects.at(0).font);
1411 ASSERT_FALSE(game_mngr->get_level()->text_objects.at(0).is_visible);
1413 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.r);
1414 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.g);
1415 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.b);
1416 ASSERT_EQ(255, game_mngr->get_level()->text_objects.at(0).color.a);
1420 test_subject.run_script(
"createEntity(0)");
1423 ASSERT_EQ(1, game_mngr->get_level_calls);
1424 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1425 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1426 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1427 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1428 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1429 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1430 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1431 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1432 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1433 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1434 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1435 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1436 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1437 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1438 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1439 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1440 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1441 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1442 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1443 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1444 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1449 game_mngr->get_level()->entities.emplace_back();
1452 test_subject.run_script(
"setEntityActive(0, false)");
1455 ASSERT_EQ(2, game_mngr->get_level_calls);
1456 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1457 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1458 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1459 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1460 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1461 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1462 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1463 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1464 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1465 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1466 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1467 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1468 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1469 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1470 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1471 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1472 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1473 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1474 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1475 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1476 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_active());
1481 game_mngr->get_level()->entities.emplace_back();
1484 test_subject.run_script(
"setEntityX(0, 500)");
1487 ASSERT_EQ(2, game_mngr->get_level_calls);
1488 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1489 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).x);
1490 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1491 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1492 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1493 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1494 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1495 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1496 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1497 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1498 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1499 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1500 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1501 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1502 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1503 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1504 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1505 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1506 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1507 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1508 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1513 game_mngr->get_level()->entities.emplace_back();
1516 test_subject.run_script(
"setEntityY(0, 500)");
1519 ASSERT_EQ(2, game_mngr->get_level_calls);
1520 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1521 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1522 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).y);
1523 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1524 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1525 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1526 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1527 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1528 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1529 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1530 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1531 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1532 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1533 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1534 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1535 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1536 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1537 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1538 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1539 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1540 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1545 game_mngr->get_level()->entities.emplace_back();
1546 game_mngr->get_level()->entities.at(0).x = 500;
1549 test_subject.run_script(
"return getEntityX(0)");
1552 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1555 ASSERT_EQ(3, game_mngr->get_level_calls);
1556 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1557 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).x);
1558 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1559 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1560 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1561 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1562 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1563 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1564 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1565 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1566 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1567 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1568 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1569 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1570 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1571 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1572 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1573 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1574 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1575 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1576 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1581 game_mngr->get_level()->entities.emplace_back();
1582 game_mngr->get_level()->entities.at(0).y = 500;
1585 test_subject.run_script(
"return getEntityY(0)");
1588 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1591 ASSERT_EQ(3, game_mngr->get_level_calls);
1592 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1593 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1594 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).y);
1595 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1596 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1597 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1598 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1599 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1600 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1601 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1602 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1603 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1604 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1605 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1606 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1607 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1608 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1609 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1610 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1611 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1612 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1617 game_mngr->get_level()->entities.emplace_back();
1620 test_subject.run_script(
"setEntityStatic(0, true)");
1623 ASSERT_EQ(2, game_mngr->get_level_calls);
1624 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1625 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1626 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1627 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1628 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_static());
1629 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1630 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1631 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1632 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1633 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1634 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1635 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1636 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1637 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1638 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1639 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1640 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1641 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1642 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1643 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1644 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1649 game_mngr->get_level()->entities.emplace_back();
1652 test_subject.run_script(
"setEntityVelocityX(0, 120)");
1655 ASSERT_EQ(2, game_mngr->get_level_calls);
1656 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1657 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1658 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1659 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1660 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1661 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1662 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1663 ASSERT_EQ(120, game_mngr->get_level()->entities.at(0).velocity_x);
1664 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1665 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1666 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1667 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1668 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1669 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1670 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1671 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1672 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1673 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1674 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1675 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1676 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1681 game_mngr->get_level()->entities.emplace_back();
1684 test_subject.run_script(
"setEntityVelocityY(0, 120)");
1687 ASSERT_EQ(2, game_mngr->get_level_calls);
1688 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1689 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1690 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1691 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1692 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1693 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1694 ASSERT_EQ(120, game_mngr->get_level()->entities.at(0).velocity_y);
1695 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1696 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1697 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1698 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1699 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1700 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1701 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1702 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1703 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1704 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1705 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1706 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1707 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1708 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1713 game_mngr->get_level()->entities.emplace_back();
1714 game_mngr->get_level()->entities.at(0).velocity_x = 120;
1717 test_subject.run_script(
"return getEntityVelocityX(0)");
1720 ASSERT_EQ(120, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1723 ASSERT_EQ(3, game_mngr->get_level_calls);
1724 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1725 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1726 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1727 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1728 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1729 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1730 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1731 ASSERT_EQ(120, game_mngr->get_level()->entities.at(0).velocity_x);
1732 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1733 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1734 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1735 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1736 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1737 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1738 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1739 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1740 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1741 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1742 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1743 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1744 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1749 game_mngr->get_level()->entities.emplace_back();
1750 game_mngr->get_level()->entities.at(0).velocity_y = 120;
1753 test_subject.run_script(
"return getEntityVelocityY(0)");
1756 ASSERT_EQ(120, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1759 ASSERT_EQ(3, game_mngr->get_level_calls);
1760 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1761 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1762 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1763 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1764 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1765 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1766 ASSERT_EQ(120, game_mngr->get_level()->entities.at(0).velocity_y);
1767 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1768 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1769 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1770 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1771 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1772 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1773 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1774 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1775 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1776 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1777 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1778 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1779 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1780 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1785 game_mngr->get_level()->entities.emplace_back();
1788 test_subject.run_script(
"setEntityTextureScale(0, 2, 2)");
1791 ASSERT_EQ(2, game_mngr->get_level_calls);
1792 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1793 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1794 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1795 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1796 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1797 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1798 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1799 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1800 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1801 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1802 ASSERT_EQ(2, game_mngr->get_level()->entities.at(0).tex_scale_x);
1803 ASSERT_EQ(2, game_mngr->get_level()->entities.at(0).tex_scale_y);
1804 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1805 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1806 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1807 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1808 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1809 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1810 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1811 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1812 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1817 game_mngr->get_level()->entities.emplace_back();
1820 test_subject.run_script(
"setEntityTexture(0, \"new_texture.webp\")");
1823 ASSERT_EQ(2, game_mngr->get_level_calls);
1824 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1825 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1826 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1827 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1828 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1829 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1830 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1831 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1832 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1833 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1834 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1835 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1836 ASSERT_EQ(ST::hash_string(
"new_texture.webp"), game_mngr->get_level()->entities.at(0).texture);
1837 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1838 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1839 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1840 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1841 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1842 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1843 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1844 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1849 game_mngr->get_level()->entities.emplace_back();
1852 test_subject.run_script(
"setEntityTexW(0, 500)");
1855 ASSERT_EQ(2, game_mngr->get_level_calls);
1856 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1857 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1858 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1859 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1860 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1861 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1862 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1863 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1864 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1865 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).tex_w);
1866 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1867 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1868 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1869 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1870 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1871 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1872 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1873 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1874 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1875 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1876 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1881 game_mngr->get_level()->entities.emplace_back();
1884 test_subject.run_script(
"setEntityTexH(0, 500)");
1887 ASSERT_EQ(2, game_mngr->get_level_calls);
1888 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1889 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1890 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1891 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1892 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1893 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1894 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1895 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1896 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).tex_h);
1897 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1898 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1899 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1900 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1901 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1902 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1903 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1904 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1905 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1906 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1907 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1908 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1913 game_mngr->get_level()->entities.emplace_back();
1914 game_mngr->get_level()->entities.at(0).tex_w = 500;
1917 test_subject.run_script(
"return getEntityTexW(0)");
1920 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1923 ASSERT_EQ(3, game_mngr->get_level_calls);
1924 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1925 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1926 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1927 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1928 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1929 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1930 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1931 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1932 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
1933 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).tex_w);
1934 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1935 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1936 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1937 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1938 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1939 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1940 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1941 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1942 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1943 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1944 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1949 game_mngr->get_level()->entities.emplace_back();
1950 game_mngr->get_level()->entities.at(0).tex_h = 500;
1953 test_subject.run_script(
"return getEntityTexH(0)");
1956 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
1959 ASSERT_EQ(3, game_mngr->get_level_calls);
1960 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1961 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1962 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1963 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
1964 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1965 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1966 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1967 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
1968 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).tex_h);
1969 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
1970 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
1971 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
1972 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
1973 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
1974 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
1975 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
1976 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
1977 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
1978 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
1979 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
1980 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
1985 game_mngr->get_level()->entities.emplace_back();
1988 test_subject.run_script(
"setEntityVisible(0, false)");
1991 ASSERT_EQ(2, game_mngr->get_level_calls);
1992 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
1993 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
1994 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
1995 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_visible());
1996 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
1997 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
1998 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
1999 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2000 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2001 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2002 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2003 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2004 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2005 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2006 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2007 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2008 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2009 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2010 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2011 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2012 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2017 game_mngr->get_level()->entities.emplace_back();
2020 test_subject.run_script(
"setEntityCollisionBox(0, 0, 0, 500, 500)");
2023 ASSERT_EQ(2, game_mngr->get_level_calls);
2024 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2025 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2026 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2027 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2028 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2029 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2030 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2031 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2032 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2033 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2034 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2035 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2036 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2037 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2038 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2039 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2040 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).get_col_x());
2041 ASSERT_EQ(-500, game_mngr->get_level()->entities.at(0).get_col_y());
2042 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2043 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2044 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2049 game_mngr->get_level()->entities.emplace_back();
2050 game_mngr->get_level()->entities.emplace_back();
2051 game_mngr->get_level()->entities.at(0).x = 500;
2052 game_mngr->get_level()->entities.at(0).y = 500;
2053 game_mngr->get_level()->entities.at(1).x = 500;
2054 game_mngr->get_level()->entities.at(1).y = 500;
2055 game_mngr->get_level()->entities.at(0).set_collision_box(0, 0, 500, 500);
2056 game_mngr->get_level()->entities.at(1).set_collision_box(0, 0, 500, 500);
2059 test_subject.run_script(
"return entityCollides(0, 1)");
2062 ASSERT_TRUE(lua_toboolean(get_lua_state(), lua_gettop(get_lua_state())));
2064 ASSERT_EQ(2, game_mngr->get_level()->entities.size());
2067 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).x);
2068 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).y);
2069 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2070 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2071 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2072 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2073 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2074 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2075 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2076 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2077 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2078 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2079 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2080 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2081 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2082 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).get_col_x());
2083 ASSERT_EQ(-500, game_mngr->get_level()->entities.at(0).get_col_y());
2084 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2085 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2086 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2089 ASSERT_EQ(500, game_mngr->get_level()->entities.at(1).x);
2090 ASSERT_EQ(500, game_mngr->get_level()->entities.at(1).y);
2091 ASSERT_TRUE(game_mngr->get_level()->entities.at(1).is_visible());
2092 ASSERT_FALSE(game_mngr->get_level()->entities.at(1).is_static());
2093 ASSERT_FALSE(game_mngr->get_level()->entities.at(1).is_affected_by_physics());
2094 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).velocity_y);
2095 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).velocity_x);
2096 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).tex_h);
2097 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).tex_w);
2098 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2099 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2100 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(1).texture);
2101 ASSERT_EQ(1, game_mngr->get_level()->entities.at(1).sprite_num);
2102 ASSERT_EQ(1, game_mngr->get_level()->entities.at(1).animation_num);
2103 ASSERT_EQ(1, game_mngr->get_level()->entities.at(1).animation);
2104 ASSERT_EQ(500, game_mngr->get_level()->entities.at(1).get_col_x());
2105 ASSERT_EQ(-500, game_mngr->get_level()->entities.at(1).get_col_y());
2106 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).get_col_x_offset());
2107 ASSERT_EQ(0, game_mngr->get_level()->entities.at(1).get_col_y_offset());
2108 ASSERT_TRUE(game_mngr->get_level()->entities.at(1).is_active());
2113 game_mngr->get_level()->entities.emplace_back();
2116 test_subject.run_script(
"setEntityAffectedByPhysics(0, true)");
2119 ASSERT_EQ(4, game_mngr->get_level_calls);
2120 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2121 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2122 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2123 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2124 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2125 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2126 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2127 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2128 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2129 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2130 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2131 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2132 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2133 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2134 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2135 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2136 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2137 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2138 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2139 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2140 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2145 game_mngr->get_level()->entities.emplace_back();
2146 game_mngr->get_level()->entities.at(0).set_collision_box(0, 0, 500, 500);
2149 test_subject.run_script(
"return getEntityColX(0)");
2152 ASSERT_EQ(500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
2155 ASSERT_EQ(3, game_mngr->get_level_calls);
2156 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2157 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2158 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2159 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2160 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2161 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2162 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2163 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2164 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2165 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2166 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2167 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2168 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2169 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2170 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2171 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2172 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).get_col_x());
2173 ASSERT_EQ(-500, game_mngr->get_level()->entities.at(0).get_col_y());
2174 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2175 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2176 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2181 game_mngr->get_level()->entities.emplace_back();
2182 game_mngr->get_level()->entities.at(0).set_collision_box(0, 0, 500, 500);
2185 test_subject.run_script(
"return getEntityColY(0)");
2188 ASSERT_EQ(-500, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
2191 ASSERT_EQ(3, game_mngr->get_level_calls);
2192 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2193 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2194 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2195 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2196 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2197 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2198 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2199 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2200 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2201 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2202 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2203 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2204 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2205 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2206 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2207 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2208 ASSERT_EQ(500, game_mngr->get_level()->entities.at(0).get_col_x());
2209 ASSERT_EQ(-500, game_mngr->get_level()->entities.at(0).get_col_y());
2210 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2211 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2212 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2217 game_mngr->get_level()->entities.emplace_back();
2218 game_mngr->get_level()->entities.at(0).set_collision_box(6, 0, 0, 0);
2221 test_subject.run_script(
"return getEntityColXOffset(0)");
2224 ASSERT_EQ(6, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
2227 ASSERT_EQ(3, game_mngr->get_level_calls);
2228 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2229 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2230 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2231 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2232 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2233 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2234 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2235 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2236 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2237 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2238 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2239 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2240 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2241 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2242 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2243 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2244 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2245 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2246 ASSERT_EQ(6, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2247 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2248 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2253 game_mngr->get_level()->entities.emplace_back();
2254 game_mngr->get_level()->entities.at(0).set_collision_box(0, 6, 0, 0);
2257 test_subject.run_script(
"return getEntityColYOffset(0)");
2260 ASSERT_EQ(6, lua_tointeger(get_lua_state(), lua_gettop(get_lua_state())));
2263 ASSERT_EQ(3, game_mngr->get_level_calls);
2264 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2265 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2266 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2267 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2268 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2269 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2270 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2271 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2272 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2273 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2274 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2275 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2276 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2277 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2278 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2279 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2280 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2281 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2282 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2283 ASSERT_EQ(6, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2284 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2289 game_mngr->get_level()->entities.emplace_back();
2292 test_subject.run_script(
"setEntityAnimation(0, 3)");
2295 ASSERT_EQ(2, game_mngr->get_level_calls);
2296 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2297 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2298 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2299 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2300 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2301 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2302 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2303 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2304 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2305 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2306 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2307 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2308 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2309 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2310 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2311 ASSERT_EQ(3, game_mngr->get_level()->entities.at(0).animation);
2312 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2313 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2314 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2315 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2316 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2321 game_mngr->get_level()->entities.emplace_back();
2324 test_subject.run_script(
"setEntityAnimationNum(0, 3)");
2327 ASSERT_EQ(2, game_mngr->get_level_calls);
2328 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2329 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2330 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2331 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2332 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2333 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2334 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2335 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2336 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2337 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2338 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2339 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2340 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2341 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).sprite_num);
2342 ASSERT_EQ(3, game_mngr->get_level()->entities.at(0).animation_num);
2343 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2344 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2345 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2346 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2347 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2348 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2353 game_mngr->get_level()->entities.emplace_back();
2356 test_subject.run_script(
"setEntitySpriteNum(0, 3)");
2359 ASSERT_EQ(2, game_mngr->get_level_calls);
2360 ASSERT_EQ(1, game_mngr->get_level()->entities.size());
2361 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).x);
2362 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).y);
2363 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_visible());
2364 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_static());
2365 ASSERT_FALSE(game_mngr->get_level()->entities.at(0).is_affected_by_physics());
2366 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_y);
2367 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).velocity_x);
2368 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_h);
2369 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).tex_w);
2370 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_x);
2371 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).tex_scale_y);
2372 ASSERT_EQ(65535, game_mngr->get_level()->entities.at(0).texture);
2373 ASSERT_EQ(3, game_mngr->get_level()->entities.at(0).sprite_num);
2374 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation_num);
2375 ASSERT_EQ(1, game_mngr->get_level()->entities.at(0).animation);
2376 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x());
2377 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y());
2378 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_x_offset());
2379 ASSERT_EQ(0, game_mngr->get_level()->entities.at(0).get_col_y_offset());
2380 ASSERT_TRUE(game_mngr->get_level()->entities.at(0).is_active());
2386 msg_bus->subscribe(SET_INTERNAL_RESOLUTION, &subscriber1);
2389 test_subject.run_script(
"setInternalResolution(3840, 2160)");
2395 ASSERT_TRUE(result);
2396 ASSERT_EQ(SET_INTERNAL_RESOLUTION, result->msg_name);
2397 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
2398 auto data = result->base_data0;
2399 ASSERT_EQ(data & 0x0000ffffU, 3840);
2400 ASSERT_EQ((data >> 16U) & 0x0000ffffU, 2160);
2406 msg_bus->subscribe(SET_WINDOW_RESOLUTION, &subscriber1);
2409 test_subject.run_script(
"setWindowResolution(3840, 2160)");
2415 ASSERT_TRUE(result);
2416 ASSERT_EQ(SET_WINDOW_RESOLUTION, result->msg_name);
2417 ASSERT_TRUE(
static_cast<bool>(result->base_data0));
2418 auto data = result->base_data0;
2419 ASSERT_EQ(data & 0x0000ffffU, 3840);
2420 ASSERT_EQ((data >> 16U) & 0x0000ffffU, 2160);
2425 test_subject.run_script(
"return getInternalResolution()");
2428 ASSERT_EQ(1080, lua_tointeger(get_lua_state(), -1));
2429 ASSERT_EQ(1920, lua_tointeger(get_lua_state(), -2));
2434 test_subject.run_script(
"return getWindowResolution()");
2437 ASSERT_EQ(1440, lua_tointeger(get_lua_state(), -1));
2438 ASSERT_EQ(2560, lua_tointeger(get_lua_state(), -2));
2441 int main(
int argc,
char **argv) {
2442 ::testing::InitGoogleTest(&argc, argv);
2443 return RUN_ALL_TESTS();
This class is responsible for managing all levels and the lua backend, it is the heart of the engine.
Tests fixture for the lua_backend.
This class handles all interaction with lua.
int initialize(message_bus *msg_bus, game_manager *game_mngr)
The central messaging system of the engine. All subsystem make extensive use of it.
A message object passed around in the message bus. Holds anything created with make_data<>().
This class handles a small queue for messages.
message * get_next_message()
A timer used for keeping track of time in the main loop.
double time_since_start() const
This struct represents text objects in the game.