🎉 Initial Commit
✨ Grid system, player movement etc
			
			
This commit is contained in:
		
							
								
								
									
										26
									
								
								Scripts/Entities/Player.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Scripts/Entities/Player.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| using System; | ||||
| using Godot; | ||||
|  | ||||
| namespace AceFieldNewHorizon.Scripts.Entities; | ||||
|  | ||||
| public partial class Player : CharacterBody2D | ||||
| { | ||||
|     [Export] public float Speed = 400.0f; | ||||
|  | ||||
|     public override void _Process(double delta) | ||||
|     { | ||||
|         // Get direction to mouse and calculate angle | ||||
|         var mousePos = GetGlobalMousePosition(); | ||||
|         var direction = GlobalPosition.DirectionTo(mousePos); | ||||
|         Rotation = direction.Angle() + (float)Math.PI / 2; | ||||
|     } | ||||
|  | ||||
|     public override void _PhysicsProcess(double delta) | ||||
|     { | ||||
|         // Get movement input | ||||
|         var inputDirection = Input.GetVector("move_left", "move_right", "move_up", "move_down"); | ||||
|         Velocity = inputDirection * Speed; | ||||
|  | ||||
|         MoveAndSlide(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										1
									
								
								Scripts/Entities/Player.cs.uid
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Scripts/Entities/Player.cs.uid
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| uid://dgm1o21sv2o1x | ||||
		Reference in New Issue
	
	Block a user