Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault creating and destroying a lot of sprites with animations #4

Open
dalarenal opened this issue Oct 7, 2016 · 0 comments

Comments

@dalarenal
Copy link
Contributor

I'm getting a segmentation fault (core dumped) creating a lot of sprites with animations, even if they are being destroyed after a while.

A code sample:

bullets = []

update do
  bullets.select! do |bullet|
    if bullet.x > window.width
      bullet.destroy
    end
    !bullet.destroyed?
  end

  bullet = load_sprite('bullet.png')
  bullet.x = window.width / 2
  bullet.y = window.height / 2
  bullet.animate_loop(:x, window.width + 100, 1000)
  bullet.animate_loop(:y, Math.rand(window.height), 1000)

  bullets << bullet

  quit if key_pressed? :escape
end

draw do
  bullets.each(&:draw)
end

quit do
  puts 'Closing our rotating square example!'
end

Yoko.loop

It fails a bit randomly. Sometimes, I run it and doesn't fail (maybe after several seconds it does). Then, I stop and run it again and it breaks in a few seconds.

Updating values every step, without using animations, avoid this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant