The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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 STATE
FLAPPING = 1
const STATEHIT = 2
const STATE
GROUNDED = 3

func ready():
#$anim
sprite.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 STATE
FLYING
if state extends FlappingState:
return STATEFLAPPING
if state extends HitState:
return STATE
HIT
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

error

in Engine by (15 points)

1 Answer

0 votes
Best answer

Maybe you should replace 'extends' with 'is' ?

by (46 points)
selected by

wow, is works thank >_<

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.