sorry for my bad english
i want to ask why i got error, i am super newbie at this game dev even progammer
i try to make flappy bird tutorial from youtube, and then got error when extends class i dunno why i got error
here code
extends RigidBody2D
onready var state = FlappingState.new(self)
const STATEFLYING = 0
const STATEFLAPPING = 1
const STATEHIT = 2
const STATEGROUNDED = 3
func ready():
#$animsprite.play("flying")
setprocessinput(true)
func physicsprocess(delta):
state.update(delta)
print(linear_velocity)
pass
func _input(event):
state.input(event)
func setstate(newstate):
state.exit()
if new_state == STATE_FLYING:
state = FlyingState.new(self)
elif new_state == STATE_FLAPPING:
state = FlappingState.new(self)
elif new_state == STATE_HIT:
state = HitState.new(self)
elif new_state == STATE_GROUNDED:
state = GroundedState.new(self)
pass
func getstate():
if state extends FlyingState:
return STATEFLYING
if state extends FlappingState:
return STATEFLAPPING
if state extends HitState:
return STATEHIT
if state extends GroundedState:
return STATE_GROUNDED
pass
Flying State ------------------------------------------------
class FlyingState:
var bird
func _init(bird):
self.bird = bird
func update(delta):
pass
func input(event):
pass
func exit():
pass
Flaping State ------------------------------------------------
class FlappingState:
var bird
func _init(bird):
self.bird = bird
bird.set_linear_velocity(Vector2(50, bird.get_linear_velocity().y))
pass
func update(delta):
if rad2deg(bird.get_rotation()) < -30:
bird.set_rotation(deg2rad(-30))
bird.set_angular_velocity(0)
if bird.linear_velocity.y > 0:
bird.set_angular_velocity(1.5)
pass
func input(event):
if Input.is_action_just_pressed("klik_kiri"):
flap()
pass
func flap():
bird.set_linear_velocity(Vector2(bird.get_linear_velocity().x, -150))
bird.set_angular_velocity(-3)
pass
func exit():
pass
Hit State ------------------------------------------------
class HitState:
var bird
func _init(bird):
self.bird = bird
func update(delta):
pass
func input(event):
pass
func exit():
pass
Grounded State ------------------------------------------------
class GroundedState:
var bird
func _init(bird):
self.bird = bird
func update(delta):
pass
func input(event):
pass
func exit():
pass
