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

demo 08_geometry.cr finish with error #49

Open
unplugandplay opened this issue Feb 21, 2022 · 1 comment
Open

demo 08_geometry.cr finish with error #49

unplugandplay opened this issue Feb 21, 2022 · 1 comment

Comments

@unplugandplay
Copy link

My env:
Crystal 1.3.2 (2022-01-18)

LLVM: 13.0.0
Default target: aarch64-apple-darwin21.1.0

running 08_geometry.cr

I end up with the following error:

In lib/sdl/src/rect.cr:26:20

 26 | def initialize(@x, @y, @w, @h)
                     ^-
Error: instance variable '@x' of SDL::Rect must be Int32, not Float64

I have to change
renderer.fill_rect(width / 4, height / 4, width / 2, height / 2)
to
renderer.fill_rect((width / 4).to_i, (height / 4).to_i, (width / 2).to_i, (height / 2).to_i)
to have it working.

@ysbaddaden
Copy link
Owner

Or replace / (float dividion) with // (integer division).

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

2 participants