mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 03:15:54 +00:00
Reisen
This commit is contained in:
parent
6fbbe7ee4c
commit
6d49455b3e
9 changed files with 118 additions and 7 deletions
|
|
@ -2,8 +2,13 @@ using Godot;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class Bullet : RigidBody2D
|
||||
public partial class Bullet : Area2D
|
||||
{
|
||||
[Export]
|
||||
public float Speed = 1900f;
|
||||
|
||||
private Vector2 _direction = Vector2.Right;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -13,6 +18,16 @@ public partial class Bullet : RigidBody2D
|
|||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
this.Position += ((float) (Speed * delta) * _direction);
|
||||
}
|
||||
|
||||
private void _on_visible_on_screen_notifier_2d_screen_exited()
|
||||
{
|
||||
Debug.WriteLine("Destroy bullet out of screen");
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public partial class PlayerMovement : CharacterBody2D
|
|||
{
|
||||
if (Input.IsActionJustPressed("shoot"))
|
||||
{
|
||||
Debug.WriteLine("Shoot");
|
||||
Bullet bullet = BulletScene.Instantiate<Bullet>();
|
||||
Owner.AddChild(bullet);
|
||||
bullet.Transform = Muzzle.GlobalTransform;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue