extends CharacterBody2D const SPEED = 300.0 const JUMP_VELOCITY = -500.0 @export var runMaxSpeed: float = 200.0 @export var runAccelerationTime: float = 0.3 @export var runDeceleration: float = 30 @export var jumpCount: int = 2 var jumps = jumpCount @export var jumpControlTime: float = 0.2 @export var jumpShortHopSpeed: float = 200 @export var jumpLongHopSpeed: float = 300 var jumping: bool = false var jumpTimer: float = 0.0 var facing = true var previous_velocity: Vector2 const GENDERS = ["female", "male"] var hair = [load("res://spritesheets/maincharacter/Hair/hair-1.png"), load("res://spritesheets/maincharacter/Hair/hair-2.png")] var hips = [load("res://spritesheets/maincharacter/Hipses/hips-1.png"), load("res://spritesheets/maincharacter/Hipses/hips-2.png")] var tits = [load("res://spritesheets/maincharacter/Titses/tits-1.png"), load("res://spritesheets/maincharacter/Titses/tits-2.png")] var current_gender="female" var jumping_up = false var jumping_down = false var transforming = false signal gender_changed(new_gender: String) func _ready(): gender_changed.emit(current_gender) func _input(event: InputEvent): if event.is_action_pressed("gend"): cycle_gender() previous_velocity = velocity func _physics_process(delta: float) -> void: # inputs and motion! var pressDirection = Input.get_axis("ui_left", "ui_right") var runAcceleration = runMaxSpeed / runAccelerationTime if pressDirection != 0: # we're trying to walk left or right if velocity.x * pressDirection < runMaxSpeed: velocity.x += pressDirection * runAcceleration * delta if velocity.x * pressDirection > runMaxSpeed: velocity.x -= pressDirection * runDeceleration * delta else: # we're not walking and so we should decelerate if velocity.x > 0: velocity.x -= runDeceleration if velocity.x < 0: velocity.x = 0 if velocity.x < 0: velocity.x += runDeceleration if velocity.x > 0: velocity.x = 0 if is_on_floor(): jumps = jumpCount var jumpAccel = (jumpLongHopSpeed - jumpShortHopSpeed) / jumpControlTime if Input.is_action_pressed("jump") and not jumping and jumps > 0: jumping = true velocity.y = -jumpShortHopSpeed jumps -= 1 if jumping and Input.is_action_pressed("jump") and jumpTimer < jumpControlTime: jumpTimer += delta velocity.y -= jumpAccel * delta if jumping and not Input.is_action_pressed("jump"): jumping = false jumpTimer = 0 # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta if transforming: if not $AnimationPlayer.is_playing(): transforming = false velocity = previous_velocity else: velocity.x = 0 velocity.y = 0 if not transforming: move_and_slide() var oldfacing = facing if velocity.x > 0: facing = true if velocity.x < 0: facing = false if not oldfacing == facing: scale.x = -1 if is_on_floor() and not transforming: if abs(velocity.x) > 0.1: $AnimationPlayer.play("run") else: $AnimationPlayer.play("idle") if velocity.y > 0.1 and not jumping_down: jumping_down = true jumping_up = false $AnimationPlayer.play("jumpDown") if velocity.y < -0.1 and not jumping_up: jumping_up = true jumping_down = false $AnimationPlayer.play("jumpUp") if abs(velocity.y) < 0.1: jumping_up = false jumping_down = false func cycle_gender(): var index = GENDERS.find(current_gender) index = (index + 1) % GENDERS.size() current_gender = GENDERS[index] $hair_layer.texture = hair[index] $hips_layer.texture = hips[index] $tits_layer.texture = tits[index] gender_changed.emit(current_gender) $AnimationPlayer.play("transformation") transforming = true