0

I'm trying to learn how to use Dome and Wren. To do this I've started working on a simple Flappy Bird clone.

The problem I'm having is that I get the error message

Bird does not implement bird_idle

It then points to line 63 in my main class which is shown below:

class Main {
  resources=(value){ _resources = value }
  bird=(value){ _bird = value }
  construct new() {
    _resources = Resources.new()
    _bird = Bird.new(_resources.birdIdle, _resources.birdFlap, _resources.obstacleTile.width * 2, _resources.obstacleTile.height * 4, 10, 4)
  }
  init() {}
  update() {}
  draw(alpha) {
    Canvas.cls()
    Canvas.draw(_bird.bird_idle, _bird.center.x, _bird.center.y) <-- this is line 63
  }
}

var Game = Main.new()

Since I'm new to Wren I don't quite understand what this means seeing as if you look at my bird class below, I should be implementing bird_idle. So what am I doing wrong?

class Bird {
  bird_idle=(value){ _bird_idle = value } <-- Right?
  bird_flap=(value){ _bird_flap = value }
  center=(value){ _center = value }
  gravity=(value){ _gravity = value }
  force=(value){ _force = value }
  velocity=(value){ _velocity = value }
  velocityLimit=(value){ _velocityLimit = value }
  isGameRunning=(value){ _isGameRunning = value }

  construct new(idle, flap, horizontalPosition, verticalPosition, drag, jumpForce) {
    _bird_idle = idle
    _bird_flap = flap
    _center = Vector.new(horizontalPosition + (idle.width * 0.5), verticalPosition + (idle.height*0.5))
    _gravity = drag
    _force = jumpForce
    _velocityLimit = 1000
    _isGameRunning = true
  }

  jump() {
    _velocity = -_force
  }

  isTouchingCeiling() {
    var birdTop = _center.y - (_bird_idle.height * 0.5)
    if(birdTop < 0) {
      return true
    }
    return false
  }
  
  isTouchingGround() {
    var birdBottom = _center.y + (_bird_idle.height * 0.5)
    if(birdBottom > height) {
      return true
    }
    return false
  }
}
OmniOwl
  • 5,477
  • 17
  • 67
  • 116

1 Answers1

0

You forgot to add the getter:

class Bird {
  
  construct new(idle) {
     _bird_idle = idle
  }

  bird_idle=(value){_bird_idle = value }
  bird_idle{_bird_idle} // You need this if you want to access the field _bird_idle.
}

var my_bird = Bird.new("Idle")
my_bird.bird_idle = "Not Idle"
System.print(my_bird.bird_idle) // Output: Not Idle