-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
155 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod block; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use godot::prelude::*; | ||
use godot::engine::{Node2D, INode2D}; | ||
|
||
#[derive(GodotClass)] | ||
#[class(base = Node2D)] | ||
struct BlockDrawer { | ||
base: Base<Node2D> | ||
} | ||
|
||
#[godot_api] | ||
impl INode2D for BlockDrawer { | ||
fn init(base: Base<Node2D>) -> BlockDrawer { | ||
// godot_print!("BlockDrawer created from Godot Rust"); | ||
Self { base } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,10 @@ | ||
use godot::engine::{ISprite2D, Sprite2D}; | ||
mod fight_items; | ||
mod player; | ||
|
||
use godot::prelude::*; | ||
|
||
struct GdExtension; | ||
|
||
#[gdextension()] | ||
unsafe impl ExtensionLibrary for GdExtension {} | ||
|
||
#[derive(GodotClass)] | ||
#[class(base = Sprite2D)] | ||
struct Player { | ||
base: Base<Sprite2D>, | ||
} | ||
|
||
#[godot_api()] | ||
impl ISprite2D for Player { | ||
fn init(base: Base<Sprite2D>) -> 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use godot::prelude::*; | ||
use godot::engine::{Area2D, IArea2D}; | ||
|
||
#[derive(GodotClass)] | ||
#[class(base = Area2D)] | ||
struct Player { | ||
base: Base<Area2D>, | ||
} | ||
|
||
#[godot_api()] | ||
impl IArea2D for Player { | ||
fn init(base: Base<Area2D>) -> 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters