diff --git a/README.md b/README.md index 696967a..27720d3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Zenith -A indie fan game developed in godot engine +A indie fan game about undertale and terraria, developed in godot engine ## Build Guide diff --git a/gdrust/src/fight_items.rs b/gdrust/src/fight_items.rs new file mode 100644 index 0000000..d4a178a --- /dev/null +++ b/gdrust/src/fight_items.rs @@ -0,0 +1 @@ +mod block; \ No newline at end of file diff --git a/gdrust/src/fight_items/block.rs b/gdrust/src/fight_items/block.rs new file mode 100644 index 0000000..bd4435f --- /dev/null +++ b/gdrust/src/fight_items/block.rs @@ -0,0 +1,16 @@ +use godot::prelude::*; +use godot::engine::{Node2D, INode2D}; + +#[derive(GodotClass)] +#[class(base = Node2D)] +struct BlockDrawer { + base: Base +} + +#[godot_api] +impl INode2D for BlockDrawer { + fn init(base: Base) -> BlockDrawer { + // godot_print!("BlockDrawer created from Godot Rust"); + Self { base } + } +} \ No newline at end of file diff --git a/gdrust/src/lib.rs b/gdrust/src/lib.rs index 44cc4ac..391fde6 100644 --- a/gdrust/src/lib.rs +++ b/gdrust/src/lib.rs @@ -1,4 +1,6 @@ -use godot::engine::{ISprite2D, Sprite2D}; +mod fight_items; +mod player; + use godot::prelude::*; struct GdExtension; @@ -6,39 +8,3 @@ struct GdExtension; #[gdextension()] unsafe impl ExtensionLibrary for GdExtension {} -#[derive(GodotClass)] -#[class(base = Sprite2D)] -struct Player { - base: Base, -} - -#[godot_api()] -impl ISprite2D for Player { - fn init(base: Base) -> Player { - godot_print!("Player created from Godot Rust"); - Self { base } - } - - fn process(&mut self, delta: f64) { - let mut vel = Vector2::ZERO; - let input_obj = Input::singleton(); - if input_obj.is_action_pressed("move_left".into()) { - vel.x -= 1.0; - } - if input_obj.is_action_pressed("move_right".into()) { - vel.x += 1.0; - } - if input_obj.is_action_pressed("move_up".into()) { - vel.y -= 1.0; - } - if input_obj.is_action_pressed("move_down".into()) { - vel.y += 1.0; - } - } -} - -#[godot_api] -impl Player { - #[constant] - const SPEED: i32 = 50; -} diff --git a/gdrust/src/player.rs b/gdrust/src/player.rs new file mode 100644 index 0000000..b82f271 --- /dev/null +++ b/gdrust/src/player.rs @@ -0,0 +1,46 @@ +use godot::prelude::*; +use godot::engine::{Area2D, IArea2D}; + +#[derive(GodotClass)] +#[class(base = Area2D)] +struct Player { + base: Base, +} + +#[godot_api()] +impl IArea2D for Player { + fn init(base: Base) -> Player { + godot_print!("Player created from Godot Rust"); + Self { base } + } + + fn physics_process(&mut self, delta: f64) { + let mut vel = Vector2::ZERO; + let input_obj = Input::singleton(); + if input_obj.is_action_pressed("move_left".into()) { + vel.x -= 1.0; + } + if input_obj.is_action_pressed("move_right".into()) { + vel.x += 1.0; + } + if input_obj.is_action_pressed("move_up".into()) { + vel.y -= 1.0; + } + if input_obj.is_action_pressed("move_down".into()) { + vel.y += 1.0; + } + // if vel != Vector2::ZERO { + // godot_error!("fuck you") + // } + let pos = self.base().get_position(); + self.base_mut() + .set_position(pos + vel.normalized() * Self::SPEED as f32 * delta as f32); + // godot_print!("position move") + } +} + +#[godot_api] +impl Player { + #[constant] + const SPEED: i32 = 500; +} diff --git a/project.godot b/project.godot index 8ffb55d..8d05c0a 100644 --- a/project.godot +++ b/project.godot @@ -24,24 +24,24 @@ window/size/resizable=false move_right={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null) ] } move_left={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null) ] } move_up={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null) ] } move_down={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null) -, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null) ] } diff --git a/resources/images/PlayerHeart/Default/000.png b/resources/images/PlayerHeart/Default/000.png new file mode 100644 index 0000000..5601e41 Binary files /dev/null and b/resources/images/PlayerHeart/Default/000.png differ diff --git a/resources/images/PlayerHeart/Default/000.png.import b/resources/images/PlayerHeart/Default/000.png.import new file mode 100644 index 0000000..6a50b0a --- /dev/null +++ b/resources/images/PlayerHeart/Default/000.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c71fsdux0i1r3" +path="res://.godot/imported/000.png-a4b21812678d9682ba51d4cdb5a01175.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/images/PlayerHeart/Default/000.png" +dest_files=["res://.godot/imported/000.png-a4b21812678d9682ba51d4cdb5a01175.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/resources/images/PlayerHeart/Split/000.png b/resources/images/PlayerHeart/Split/000.png new file mode 100644 index 0000000..9a6194a Binary files /dev/null and b/resources/images/PlayerHeart/Split/000.png differ diff --git a/resources/images/PlayerHeart/Split/000.png.import b/resources/images/PlayerHeart/Split/000.png.import new file mode 100644 index 0000000..62ef2d4 --- /dev/null +++ b/resources/images/PlayerHeart/Split/000.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b7yfjvvu14mf" +path="res://.godot/imported/000.png-48f47f0c96b2a076c5508fb2baa6aa87.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/images/PlayerHeart/Split/000.png" +dest_files=["res://.godot/imported/000.png-48f47f0c96b2a076c5508fb2baa6aa87.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/fight.tscn b/scenes/fight.tscn index 9653d59..8bbd2f5 100644 --- a/scenes/fight.tscn +++ b/scenes/fight.tscn @@ -1,9 +1,12 @@ -[gd_scene load_steps=5 format=3 uid="uid://cibwxaqnuodid"] +[gd_scene load_steps=7 format=3 uid="uid://cibwxaqnuodid"] [ext_resource type="Script" path="res://scripts/fight.gd" id="1_fov6f"] [ext_resource type="Texture2D" uid="uid://cqp3l8q7xbxrt" path="res://resources/images/weapons/Zenith.webp" id="3_2spkb"] [ext_resource type="Script" path="res://scripts/Player.gd" id="3_6nc6b"] [ext_resource type="PackedScene" uid="uid://dn2ixin15jtt3" path="res://scenes/weapons/star_wrath.tscn" id="4_8ipx5"] +[ext_resource type="Texture2D" uid="uid://c71fsdux0i1r3" path="res://resources/images/PlayerHeart/Default/000.png" id="5_3ufqu"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_yfrnq"] [node name="Fight" type="Control"] layout_mode = 3 @@ -29,9 +32,19 @@ rotation = 2.35389 scale = Vector2(-3.28571, -3.28571) texture = ExtResource("3_2spkb") +[node name="Star_Wrath" parent="." instance=ExtResource("4_8ipx5")] + [node name="Player" type="Player" parent="."] +position = Vector2(570, 463) +rotation = 1.5708 +scale = Vector2(0.2, 0.2) script = ExtResource("3_6nc6b") -[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] +[node name="HitPoint" type="CollisionShape2D" parent="Player"] +shape = SubResource("CircleShape2D_yfrnq") -[node name="Star_Wrath" parent="." instance=ExtResource("4_8ipx5")] +[node name="Sprite2D" type="Sprite2D" parent="Player"] +scale = Vector2(6.6, 6.6) +texture = ExtResource("5_3ufqu") + +[node name="BlockDrawer" type="BlockDrawer" parent="."]