diff --git a/c/glfw/README.md b/c/glfw/README.md index 14be455..9052ab2 100644 --- a/c/glfw/README.md +++ b/c/glfw/README.md @@ -8,6 +8,8 @@ Dependencies: this is now a Git submodule of this repo. * `clang`, `gcc`, or any decent C compiler that's C11 compatible. * You need to have GLFW and its headers installed. + * On Ubuntu Linux: `sudo apt install libglfw3 libglfw3-dev` + * On macOS: `brew install glfw` ## Compile with SCons (cross platform) You can use SCons to compile the library if you have it installed: diff --git a/c/glfw/SConstruct b/c/glfw/SConstruct index 58c7c49..d2a5337 100644 --- a/c/glfw/SConstruct +++ b/c/glfw/SConstruct @@ -40,27 +40,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if True or env["use_llvm"]: # TODO: GCC doesn't work for some reason. - env["CC"] = "clang" - env["CXX"] = "clang++" - -# Check our platform specifics -if env["platform"] == "macos": +# Check our platform specifics. +if platform == "macos": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) - -elif env["platform"] == "linuxbsd": +elif platform == "linuxbsd": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) - -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -73,6 +68,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + # Make sure our library includes the Godot headers. env.Append(CPPPATH=[".", godot_headers_path]) diff --git a/c/glfw/project/project.godot b/c/glfw/project/project.godot index 5424e31..26ba227 100644 --- a/c/glfw/project/project.godot +++ b/c/glfw/project/project.godot @@ -27,3 +27,5 @@ multithread/thread_rid_pool_prealloc=60 [rendering] quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false diff --git a/c/instance_binding/SConstruct b/c/instance_binding/SConstruct index 28a38b4..3092848 100644 --- a/c/instance_binding/SConstruct +++ b/c/instance_binding/SConstruct @@ -40,27 +40,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if env["use_llvm"]: - env["CC"] = "clang" - env["CXX"] = "clang++" - -# Check our platform specifics -if env["platform"] == "macos": +# Check our platform specifics. +if platform == "macos": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) - -elif env["platform"] == "linuxbsd": +elif platform == "linuxbsd": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) - -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -73,6 +68,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + # Make sure our library includes the Godot headers. env.Append(CPPPATH=[".", godot_headers_path]) diff --git a/c/instance_binding/project/project.godot b/c/instance_binding/project/project.godot index 70f2993..9f800ea 100644 --- a/c/instance_binding/project/project.godot +++ b/c/instance_binding/project/project.godot @@ -31,3 +31,5 @@ multithread/thread_rid_pool_prealloc=60 [rendering] quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false diff --git a/c/simple/SConstruct b/c/simple/SConstruct index f340689..0af6db4 100644 --- a/c/simple/SConstruct +++ b/c/simple/SConstruct @@ -40,27 +40,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if env["use_llvm"]: - env["CC"] = "clang" - env["CXX"] = "clang++" - -# Check our platform specifics -if env["platform"] == "macos": +# Check our platform specifics. +if platform == "macos": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) - -elif env["platform"] == "linuxbsd": +elif platform == "linuxbsd": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) - -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -73,6 +68,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + # Make sure our library includes the Godot headers. env.Append(CPPPATH=[".", godot_headers_path]) diff --git a/c/simple/project/project.godot b/c/simple/project/project.godot index b6fd4a4..c95887a 100644 --- a/c/simple/project/project.godot +++ b/c/simple/project/project.godot @@ -10,7 +10,6 @@ config_version=4 _global_script_classes=[ ] _global_script_class_icons={ - } [application] @@ -27,3 +26,9 @@ singletons=[ ] [memory] multithread/thread_rid_pool_prealloc=60 + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false diff --git a/cpp/dodge_the_creeps/SConstruct b/cpp/dodge_the_creeps/SConstruct index 51432e0..c8b8d51 100644 --- a/cpp/dodge_the_creeps/SConstruct +++ b/cpp/dodge_the_creeps/SConstruct @@ -3,12 +3,13 @@ import os opts = Variables([], ARGUMENTS) -# Gets the standard flags CC, CCX, etc. -env = DefaultEnvironment() - +# Define the relative path to the Godot headers. godot_headers_path = "godot-cpp/godot-headers" godot_bindings_path = "godot-cpp" +# Gets the standard flags CC, CCX, etc. +env = DefaultEnvironment() + # Define our options. Use future-proofed names for platforms. platform_array = ["", "windows", "linuxbsd", "macos", "x11", "linux", "osx"] opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"])) @@ -38,28 +39,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if env["platform"] == "osx" and not env["use_llvm"]: - env["use_llvm"] = "yes" - -if env["use_llvm"] == "yes": - env["CC"] = "clang" - env["CXX"] = "clang++" - -# put stuff that is the same for all first, saves duplication -if env["platform"] == "osx": +# Check our platform specifics. +if platform == "osx": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) -elif env["platform"] == "linux": +elif platform == "linux": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -72,6 +67,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + SConscript("godot-cpp/SConstruct") @@ -92,11 +91,7 @@ env.Append( env.Append( LIBS=[ - env.File( - os.path.join( - "godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (env["platform"], env["target"], env["LIBSUFFIX"]) - ) - ) + env.File(os.path.join("godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (platform, env["target"], env["LIBSUFFIX"]))) ] ) @@ -105,7 +100,5 @@ env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary( - target=env["target_path"] + "/" + env["platform"] + "/" + env["target_name"], source=sources -) +library = env.SharedLibrary(target=env["target_path"] + "/" + platform + "/" + env["target_name"], source=sources) Default(library) diff --git a/cpp/dodge_the_creeps/src/hud.cpp b/cpp/dodge_the_creeps/src/hud.cpp index 60e7c64..95b8693 100644 --- a/cpp/dodge_the_creeps/src/hud.cpp +++ b/cpp/dodge_the_creeps/src/hud.cpp @@ -23,7 +23,7 @@ void HUD::show_game_over() { _start_message_timer->start(); } -void HUD::update_score(int p_score) { +void HUD::update_score(const int p_score) { _score_label->set_text(godot::Variant(p_score)); } @@ -51,5 +51,5 @@ void HUD::_register_methods() { godot::register_method("_on_StartButton_pressed", &HUD::_on_StartButton_pressed); godot::register_method("_on_StartMessageTimer_timeout", &HUD::_on_StartMessageTimer_timeout); godot::register_method("_on_GetReadyMessageTimer_timeout", &HUD::_on_GetReadyMessageTimer_timeout); - godot::register_signal("start_game"); + godot::register_signal("start_game", godot::Dictionary()); } diff --git a/cpp/dodge_the_creeps/src/hud.hpp b/cpp/dodge_the_creeps/src/hud.hpp index 8852bf6..2dfd2bb 100644 --- a/cpp/dodge_the_creeps/src/hud.hpp +++ b/cpp/dodge_the_creeps/src/hud.hpp @@ -22,7 +22,7 @@ public: void _ready(); void show_get_ready(); void show_game_over(); - void update_score(int score); + void update_score(const int score); void _on_StartButton_pressed(); void _on_StartMessageTimer_timeout(); void _on_GetReadyMessageTimer_timeout(); diff --git a/cpp/dodge_the_creeps/src/main.cpp b/cpp/dodge_the_creeps/src/main.cpp index 7650393..d1b28d0 100644 --- a/cpp/dodge_the_creeps/src/main.cpp +++ b/cpp/dodge_the_creeps/src/main.cpp @@ -38,20 +38,20 @@ void Main::new_game() { void Main::_on_MobTimer_timeout() { // Choose a random location on Path2D. - _mob_spawn_location->set_offset(_random->randi()); + _mob_spawn_location->set_offset((real_t)_random->randi()); // Create a Mob instance and add it to the scene. godot::Node *mob = mob_scene->instance(); add_child(mob); // Set the mob's direction perpendicular to the path direction. - real_t direction = _mob_spawn_location->get_rotation() + Math_PI / 2; + real_t direction = _mob_spawn_location->get_rotation() + (real_t)Math_PI / 2; // Set the mob's position to a random location. mob->set("position", _mob_spawn_location->get_position()); // Add some randomness to the direction. - direction += _random->randf_range(-Math_PI / 4, Math_PI / 4); + direction += _random->randf_range((real_t)-Math_PI / 4, (real_t)Math_PI / 4); mob->set("rotation", direction); // Choose the velocity for the mob. diff --git a/cpp/dodge_the_creeps/src/mob.cpp b/cpp/dodge_the_creeps/src/mob.cpp index 7740243..e1c834d 100644 --- a/cpp/dodge_the_creeps/src/mob.cpp +++ b/cpp/dodge_the_creeps/src/mob.cpp @@ -16,12 +16,7 @@ void Mob::_on_VisibilityNotifier2D_screen_exited() { queue_free(); } -void Mob::_on_start_game() { - queue_free(); -} - void Mob::_register_methods() { godot::register_method("_ready", &Mob::_ready); godot::register_method("_on_VisibilityNotifier2D_screen_exited", &Mob::_on_VisibilityNotifier2D_screen_exited); - godot::register_method("_on_start_game", &Mob::_on_start_game); } diff --git a/cpp/dodge_the_creeps/src/mob.hpp b/cpp/dodge_the_creeps/src/mob.hpp index efc8823..5fde461 100644 --- a/cpp/dodge_the_creeps/src/mob.hpp +++ b/cpp/dodge_the_creeps/src/mob.hpp @@ -11,13 +11,9 @@ class Mob : public godot::RigidBody2D { godot::AnimatedSprite *_animated_sprite; public: - int min_speed = 150; - int max_speed = 250; - void _init() {} void _ready(); void _on_VisibilityNotifier2D_screen_exited(); - void _on_start_game(); static void _register_methods(); }; diff --git a/cpp/dodge_the_creeps/src/player.cpp b/cpp/dodge_the_creeps/src/player.cpp index 0b66a6a..fb6ab0c 100644 --- a/cpp/dodge_the_creeps/src/player.cpp +++ b/cpp/dodge_the_creeps/src/player.cpp @@ -9,7 +9,7 @@ void Player::_ready() { hide(); } -void Player::_process(double p_delta) { +void Player::_process(const double p_delta) { godot::Input *input = godot::Input::get_singleton(); godot::Vector2 velocity(0, 0); @@ -24,7 +24,7 @@ void Player::_process(double p_delta) { } godot::Vector2 position = get_position(); - position += velocity * p_delta; + position += velocity * (real_t)p_delta; position.x = godot::Math::clamp(position.x, (real_t)0.0, _screen_size.x); position.y = godot::Math::clamp(position.y, (real_t)0.0, _screen_size.y); set_position(position); @@ -39,7 +39,7 @@ void Player::_process(double p_delta) { } } -void Player::start(godot::Vector2 p_position) { +void Player::start(const godot::Vector2 p_position) { set_position(p_position); show(); _collision_shape->set_disabled(false); @@ -57,6 +57,6 @@ void Player::_register_methods() { godot::register_method("_process", &Player::_process); godot::register_method("start", &Player::start); godot::register_method("_on_Player_body_entered", &Player::_on_Player_body_entered); - godot::register_property("speed", &Player::speed, 400); - godot::register_signal("hit"); + godot::register_property("speed", &Player::speed, (real_t)400.0); + godot::register_signal("hit", godot::Dictionary()); } diff --git a/cpp/dodge_the_creeps/src/player.hpp b/cpp/dodge_the_creeps/src/player.hpp index 75c52ca..5baf68c 100644 --- a/cpp/dodge_the_creeps/src/player.hpp +++ b/cpp/dodge_the_creeps/src/player.hpp @@ -14,12 +14,12 @@ class Player : public godot::Area2D { godot::Vector2 _screen_size; // Size of the game window. public: - int speed = 400; // How fast the player will move (pixels/sec). + real_t speed = 400; // How fast the player will move (pixels/sec). void _init() {} void _ready(); - void _process(double p_delta); - void start(godot::Vector2 p_position); + void _process(const double p_delta); + void start(const godot::Vector2 p_position); void _on_Player_body_entered(godot::Node2D *_body); static void _register_methods(); diff --git a/cpp/pong/SConstruct b/cpp/pong/SConstruct index 71ac6e7..be2e6c5 100644 --- a/cpp/pong/SConstruct +++ b/cpp/pong/SConstruct @@ -3,12 +3,13 @@ import os opts = Variables([], ARGUMENTS) -# Gets the standard flags CC, CCX, etc. -env = DefaultEnvironment() - +# Define the relative path to the Godot headers. godot_headers_path = "godot-cpp/godot-headers" godot_bindings_path = "godot-cpp" +# Gets the standard flags CC, CCX, etc. +env = DefaultEnvironment() + # Define our options. Use future-proofed names for platforms. platform_array = ["", "windows", "linuxbsd", "macos", "x11", "linux", "osx"] opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"])) @@ -38,28 +39,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if env["platform"] == "osx" and not env["use_llvm"]: - env["use_llvm"] = "yes" - -if env["use_llvm"] == "yes": - env["CC"] = "clang" - env["CXX"] = "clang++" - -# put stuff that is the same for all first, saves duplication -if env["platform"] == "osx": +# Check our platform specifics. +if platform == "osx": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) -elif env["platform"] == "linux": +elif platform == "linux": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -72,6 +67,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + SConscript("godot-cpp/SConstruct") @@ -92,11 +91,7 @@ env.Append( env.Append( LIBS=[ - env.File( - os.path.join( - "godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (env["platform"], env["target"], env["LIBSUFFIX"]) - ) - ) + env.File(os.path.join("godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (platform, env["target"], env["LIBSUFFIX"]))) ] ) @@ -105,7 +100,5 @@ env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary( - target=env["target_path"] + "/" + env["platform"] + "/" + env["target_name"], source=sources -) +library = env.SharedLibrary(target=env["target_path"] + "/" + platform + "/" + env["target_name"], source=sources) Default(library) diff --git a/cpp/pong/src/ball.cpp b/cpp/pong/src/ball.cpp index 1a9ee36..21f3860 100644 --- a/cpp/pong/src/ball.cpp +++ b/cpp/pong/src/ball.cpp @@ -4,10 +4,10 @@ void Ball::_ready() { _initial_pos = get_position(); } -void Ball::_process(double p_delta) { - _speed += p_delta * 2; +void Ball::_process(const double p_delta) { + _speed += (real_t)p_delta * 2; godot::Vector2 position = get_position(); - position += _speed * p_delta * direction; + position += _speed * (real_t)p_delta * direction; set_position(position); } diff --git a/cpp/pong/src/ball.hpp b/cpp/pong/src/ball.hpp index c60a585..03ceefa 100644 --- a/cpp/pong/src/ball.hpp +++ b/cpp/pong/src/ball.hpp @@ -7,7 +7,7 @@ class Ball : public godot::Area2D { GODOT_CLASS(Ball, godot::Area2D) - const int DEFAULT_SPEED = 100; + const real_t DEFAULT_SPEED = 100; real_t _speed = DEFAULT_SPEED; godot::Vector2 _initial_pos; @@ -16,7 +16,7 @@ public: void _init() {} void _ready(); - void _process(double p_delta); + void _process(const double p_delta); void reset(); static void _register_methods(); diff --git a/cpp/pong/src/ceiling_floor.cpp b/cpp/pong/src/ceiling_floor.cpp index f7712ff..d99802a 100644 --- a/cpp/pong/src/ceiling_floor.cpp +++ b/cpp/pong/src/ceiling_floor.cpp @@ -2,7 +2,7 @@ void CeilingFloor::_on_area_entered(Ball *p_ball) { if (p_ball->get_name() == "Ball") { - p_ball->direction = (p_ball->direction + godot::Vector2(0, bounce_direction)).normalized(); + p_ball->direction = (p_ball->direction + godot::Vector2(0, (real_t)bounce_direction)).normalized(); } } diff --git a/cpp/pong/src/paddle.cpp b/cpp/pong/src/paddle.cpp index fdaed7c..72297f4 100644 --- a/cpp/pong/src/paddle.cpp +++ b/cpp/pong/src/paddle.cpp @@ -15,12 +15,12 @@ void Paddle::_ready() { } } -void Paddle::_process(double delta) { +void Paddle::_process(const double delta) { godot::Input *input = godot::Input::get_singleton(); // Move up and down based on input. real_t keyboard_input = input->get_action_strength(_down) - input->get_action_strength(_up); godot::Vector2 position = get_position(); - position.y = godot::Math::clamp(position.y + keyboard_input * MOVE_SPEED * delta, 16.0, _screen_size_y - 16.0); + position.y = (real_t)godot::Math::clamp(position.y + keyboard_input * MOVE_SPEED * delta, 16.0, _screen_size_y - 16.0); set_position(position); } @@ -29,7 +29,7 @@ void Paddle::_on_area_entered(Ball *p_ball) { godot::Ref random = godot::RandomNumberGenerator::_new(); random->randomize(); // Assign new direction. - p_ball->direction = godot::Vector2(_ball_dir, random->randf() * 2 - 1).normalized(); + p_ball->direction = godot::Vector2((real_t)_ball_dir, random->randf() * 2 - 1).normalized(); } } diff --git a/cpp/pong/src/paddle.hpp b/cpp/pong/src/paddle.hpp index 678d67a..efd2670 100644 --- a/cpp/pong/src/paddle.hpp +++ b/cpp/pong/src/paddle.hpp @@ -20,7 +20,7 @@ class Paddle : public godot::Area2D { public: void _init() {} void _ready(); - void _process(double p_delta); + void _process(const double p_delta); void _on_area_entered(Ball *p_area); static void _register_methods(); diff --git a/cpp/simple/SConstruct b/cpp/simple/SConstruct index c66b85a..62c0cb6 100644 --- a/cpp/simple/SConstruct +++ b/cpp/simple/SConstruct @@ -3,12 +3,13 @@ import os opts = Variables([], ARGUMENTS) -# Gets the standard flags CC, CCX, etc. -env = DefaultEnvironment() - +# Define the relative path to the Godot headers. godot_headers_path = "godot-cpp/godot-headers" godot_bindings_path = "godot-cpp" +# Gets the standard flags CC, CCX, etc. +env = DefaultEnvironment() + # Define our options. Use future-proofed names for platforms. platform_array = ["", "windows", "linuxbsd", "macos", "x11", "linux", "osx"] opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"])) @@ -38,28 +39,22 @@ if env["platform"] == "": platform = env["platform"] -# Process other arguments. -if env["platform"] == "osx" and not env["use_llvm"]: - env["use_llvm"] = "yes" - -if env["use_llvm"] == "yes": - env["CC"] = "clang" - env["CXX"] = "clang++" - -# put stuff that is the same for all first, saves duplication -if env["platform"] == "osx": +# Check our platform specifics. +if platform == "osx": + if not env["use_llvm"]: + env["use_llvm"] = "yes" if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) else: env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64", "-std=c++14"]) env.Append(LINKFLAGS=["-arch", "x86_64"]) -elif env["platform"] == "linux": +elif platform == "linux": if env["target"] in ("debug", "d"): env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"]) else: env.Append(CCFLAGS=["-fPIC", "-g", "-O3"]) -elif env["platform"] == "windows": +elif platform == "windows": # This makes sure to keep the session environment variables # on Windows, so that you can run scons in a VS 2017 prompt # and it will find all the required tools. @@ -72,6 +67,10 @@ elif env["platform"] == "windows": else: env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"]) +if env["use_llvm"] == "yes": + env["CC"] = "clang" + env["CXX"] = "clang++" + SConscript("godot-cpp/SConstruct") @@ -92,11 +91,7 @@ env.Append( env.Append( LIBS=[ - env.File( - os.path.join( - "godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (env["platform"], env["target"], env["LIBSUFFIX"]) - ) - ) + env.File(os.path.join("godot-cpp/bin", "libgodot-cpp.%s.%s.64%s" % (platform, env["target"], env["LIBSUFFIX"]))) ] ) @@ -105,7 +100,5 @@ env.Append(LIBPATH=[godot_bindings_path + "/bin/"]) sources = [] add_sources(sources, "src") -library = env.SharedLibrary( - target=env["target_path"] + "/" + env["platform"] + "/" + env["target_name"], source=sources -) +library = env.SharedLibrary(target=env["target_path"] + "/" + platform + "/" + env["target_name"], source=sources) Default(library) diff --git a/cpp/simple/src/Simple.cpp b/cpp/simple/src/Simple.cpp index b99adbf..2b726d5 100644 --- a/cpp/simple/src/Simple.cpp +++ b/cpp/simple/src/Simple.cpp @@ -24,12 +24,12 @@ void SimpleSprite::_init() { godot::Godot::print("A SimpleSprite was initialized in GDNative!"); } -void SimpleSprite::_process(double p_delta) { +void SimpleSprite::_process(const double p_delta) { godot::Input *input = godot::Input::get_singleton(); godot::Vector2 input_dir(0, 0); input_dir.x = input->get_action_strength("ui_right") - input->get_action_strength("ui_left"); input_dir.y = input->get_action_strength("ui_down") - input->get_action_strength("ui_up"); - set_position(get_position() + input_dir.normalized() * p_delta * 300); + set_position(get_position() + input_dir.normalized() * (real_t)p_delta * 300); } diff --git a/cpp/simple/src/Simple.hpp b/cpp/simple/src/Simple.hpp index baf86b9..6fd6f1e 100644 --- a/cpp/simple/src/Simple.hpp +++ b/cpp/simple/src/Simple.hpp @@ -27,7 +27,7 @@ public: void _init(); - void _process(double p_delta); + void _process(const double p_delta); }; #endif // SIMPLE_H