
first of all sorry for not being active for 4 months lol i've recently started working on porting doggo battles to godot and decided to share my progress space for next sprite fullscreen recommended
here's the script for doggo cuz why not extends CharacterBody2D class_name Doggo # doggo type @export var doggo_type := "normal" # player stats @export var speed: int = 60 @export var jump_power = -600.0 @export var attack_power = 700 @export var attack_cooldown := 1.5 # seconds var health: int = 150 @export var max_health: int = 150 @export var attack_damage := 10 #base player stats (set to 0) var coins := 0 var attack_timer := 0.0 var launch_velocity_x := 0.0 #other stats (don't change) var attacked = false @export var launch_strength := 1100.0 var launch_decay := 6.0 const gravity := 1200.0 @onready var sprite := $Sprite2D @onready var hp_bar: TextureRect = $"../Hp_bar" @onready var enemy: CharacterBody2D = $"../Enemy" @onready var hitbox: Area2D = $Hitbox @onready var coin_spawner: Node = $"../CoinSpawner" var is_attacking = false func play_sound(sfx): var sound = get(sfx) if sound is AudioStreamPlayer: sound.play() func _ready() -> void: hitbox.body_entered.connect(check_for_enemy) func _physics_process(delta: float) -> void: check_for_enemy(Enemy) hp_bar.hp_level = health # just in case I do something stupid if health > max_health: health = max_health if attack_timer > 0.0: attack_timer -= delta if not is_on_floor(): velocity.y += gravity * delta if Input.is_action_just_pressed("Jump") and is_on_floor(): velocity.y = jump_power if Input.is_action_just_pressed("Attack") and attack_timer < 0.001: attack() # Left-Right movement if Input.is_action_pressed("Move Left"): launch_velocity_x -= speed $Sprite2D.flip_h = true if Input.is_action_pressed("Move Right"): launch_velocity_x += speed $Sprite2D.flip_h = false launch_velocity_x = lerp(launch_velocity_x, 0.0, launch_decay * delta) velocity.x = launch_velocity_x move_and_slide() func check_for_enemy(_en): if is_attacking and not attacked: for body in hitbox.get_overlapping_bodies(): if body is Enemy: deal_damage() func deal_damage(): attacked = true AudioManager.hit.play() enemy.health -= attack_damage enemy.modulate = Color(1.2, 1.2, 1.2, 1.0) print("Doggo dealt ", attack_damage , " damage!") random_coin_spawn() await get_tree().create_timer(0.2).timeout enemy.modulate = Color(1,1,1,1) func random_coin_spawn(): if randf() < coin_spawner.chance: coin_spawner.spawn_coin() func attack(): attack_timer = attack_cooldown is_attacking = true var facing_dir := -1 if sprite.flip_h else 1 launch_velocity_x = facing_dir * launch_strength AudioManager.bark.play() await get_tree().create_timer(1).timeout is_attacking = false attacked = false