diff --git a/demo/bin/libSideScrollingShooter.linux.template_debug.x86_64.so b/demo/bin/libSideScrollingShooter.linux.template_debug.x86_64.so index d18d92d..f3421ba 100755 Binary files a/demo/bin/libSideScrollingShooter.linux.template_debug.x86_64.so and b/demo/bin/libSideScrollingShooter.linux.template_debug.x86_64.so differ diff --git a/demo/godot/Scenes/player.tscn b/demo/godot/Scenes/player.tscn index 2f3abaa..da9bb32 100644 --- a/demo/godot/Scenes/player.tscn +++ b/demo/godot/Scenes/player.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=11 format=3 uid="uid://bjbccem28ir8r"] +[gd_scene load_steps=10 format=3 uid="uid://bjbccem28ir8r"] [ext_resource type="Texture2D" uid="uid://bcbjh2amre7ke" path="res://non-godot/Textures/Plane/PlaneUp.png" id="1_2h3i0"] [ext_resource type="PackedScene" uid="uid://do4a4d3u60iy1" path="res://godot/Scenes/Bullets/bullet.tscn" id="1_edjcf"] [ext_resource type="Texture2D" uid="uid://c5kt81t5h4vgn" path="res://non-godot/Textures/Plane/Plane.png" id="3_5g2vf"] [ext_resource type="Texture2D" uid="uid://bff4pkabs2ecf" path="res://non-godot/Textures/Plane/PlaneDown.png" id="3_edjcf"] -[ext_resource type="AudioStream" uid="uid://do4a5aj5a0216" path="res://non-godot/Sound/Shoot.ogg" id="4_m3gyy"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_xtmdc"] particle_flag_disable_z = true @@ -149,6 +148,7 @@ _data = { } [node name="Player" type="Player" groups=["Player"]] +ShotBulletLocation = Vector2(100, 100) ShotBullet = ExtResource("1_edjcf") PlayerUp = ExtResource("1_2h3i0") PlayerNeutral = ExtResource("3_5g2vf") @@ -162,17 +162,6 @@ InputSpeedUp = &"SpeedUp" scale = Vector2(0.15, 0.15) motion_mode = 1 -[node name="Gun" type="Node2D" parent="."] -position = Vector2(1, 1) - -[node name="Marker2D" type="Marker2D" parent="Gun"] -position = Vector2(545.6666, 259) - -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="Gun"] -stream = ExtResource("4_m3gyy") -volume_db = -20.0 -max_polyphony = 2 - [node name="GPUParticles2D2" type="GPUParticles2D" parent="."] z_index = -1 position = Vector2(-544, -153.33333) diff --git a/src/Player.cpp b/src/Player.cpp index 5d1df82..6a0c2cd 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -43,9 +43,12 @@ namespace godot { ClassDB::bind_method(D_METHOD("GetFireRate"), &Player::GetFireRate); ClassDB::bind_method(D_METHOD("SetFireRate", "FireRate"), &Player::SetFireRate); ClassDB::add_property("Player", PropertyInfo(Variant::FLOAT, "ShotFireRate"), "SetFireRate", "GetFireRate"); - ClassDB::bind_method(D_METHOD("GetBullet"), &Player::GetBullet); - ClassDB::bind_method(D_METHOD("SetBullet", "Bullet"), &Player::SetBullet); - ClassDB::add_property("Player", PropertyInfo(Variant::OBJECT, "ShotBullet"), "SetBullet", "GetBullet"); + ClassDB::bind_method(D_METHOD("GetBulletLocation"), &Player::GetBulletLocation); + ClassDB::bind_method(D_METHOD("SetBulletLocation", "BulletLocation"), &Player::SetBulletLocation); + ClassDB::add_property("Player", PropertyInfo(Variant::VECTOR2, "ShotBulletLocation"), "SetBulletLocation", "GetBulletLocation"); + ClassDB::bind_method(D_METHOD("GetBulletTexture"), &Player::GetBulletTexture); + ClassDB::bind_method(D_METHOD("SetBulletTexture", "BulletTexture"), &Player::SetBulletTexture); + ClassDB::add_property("Player", PropertyInfo(Variant::OBJECT, "ShotBulletTexture"), "SetBulletTexture", "GetBulletTexture"); // Textures ClassDB::bind_method(D_METHOD("GetPlayerUp"), &Player::GetPlayerUp); @@ -119,7 +122,8 @@ namespace godot { // Shooting. if (Input::get_singleton()->get_action_raw_strength(Shoot) != 0) { - Node* bullet = Bullet->instantiate(); + Bullet* bullet = memnew(Bullet); + bullet->set_position(BulletLocation + get_position()); get_parent()->add_child(bullet); FireRateTimer = 0; } @@ -146,8 +150,11 @@ namespace godot { float Player::GetFireRate() const { return FireRate; } - Ref Player::GetBullet() const { - return Bullet; + Vector2 Player::GetBulletLocation() const { + return BulletLocation; + } + Ref Player::GetBulletTexture() const { + return BulletTexture; } Ref Player::GetPlayerUp() const { return PlayerUp; @@ -189,8 +196,11 @@ namespace godot { void Player::SetFireRate(const float fireRate) { FireRate = fireRate; } - void Player::SetBullet(const Ref& bullet) { - Bullet = bullet; + void Player::SetBulletLocation(const Vector2 bulletLocation) { + BulletLocation = bulletLocation; + } + void Player::SetBulletTexture(const Ref& bulletTexture) { + BulletTexture = bulletTexture; } void Player::SetPlayerUp(const Ref& playerUp) { PlayerUp = playerUp; diff --git a/src/Player.hpp b/src/Player.hpp index dbd3a5a..e205065 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -8,7 +8,8 @@ #include #include #include -#include + +#include "Bullet.hpp" namespace godot { class Player : public CharacterBody2D { @@ -24,7 +25,8 @@ namespace godot { bool PlayerControl = true; // Killing - Ref Bullet; + Ref BulletTexture; + Vector2 BulletLocation = Vector2(0, 0); double FireRate = 0.04; double FireRateTimer = 0; @@ -60,7 +62,8 @@ namespace godot { int GetSpeed() const; float GetInvulnerabilityTime() const; float GetFireRate() const; - Ref GetBullet() const; + Vector2 GetBulletLocation() const; + Ref GetBulletTexture() const; Ref GetPlayerUp() const; Ref GetPlayerNeutral() const; Ref GetPlayerDown() const; @@ -75,7 +78,8 @@ namespace godot { void SetSpeed(const int speed); void SetInvulnerabilityTime(const float invulnerabilityTime); void SetFireRate(const float fireRate); - void SetBullet(const Ref& bullet); + void SetBulletLocation(const Vector2 bulletLocation); + void SetBulletTexture(const Ref& bulletTexture); void SetPlayerUp(const Ref& playerUp); void SetPlayerNeutral(const Ref& playerNeutral); void SetPlayerDown(const Ref& playerDown); diff --git a/src/RegisterTypes.cpp b/src/RegisterTypes.cpp index ef3d9fd..6da0450 100644 --- a/src/RegisterTypes.cpp +++ b/src/RegisterTypes.cpp @@ -18,7 +18,7 @@ void InitializeModule(ModuleInitializationLevel p_level) { GDREGISTER_CLASS(Player); GDREGISTER_CLASS(Bullet); - GDREGISTER_CLASS(Wave); + //GDREGISTER_CLASS(Wave); GDREGISTER_CLASS(Enemy); } diff --git a/src/gen/doc_data.gen.cpp b/src/gen/doc_data.gen.cpp index 9bb954b..8e7aeb8 100644 --- a/src/gen/doc_data.gen.cpp +++ b/src/gen/doc_data.gen.cpp @@ -2,7 +2,7 @@ #include -static const char *_doc_data_hash = "5307739025143130596"; +static const char *_doc_data_hash = "8574192405191457953"; static const int _doc_data_uncompressed_size = 0; static const int _doc_data_compressed_size = 8; static const unsigned char _doc_data_compressed[] = {