Ball falls through Screen[SOLVED]
- Posted by Icy_Viking Oct 03, 2022
- 834 views
Hi all,
I recently made the bouncing ball example from Raylib using Greg's Euphoria version of FFI. However, as soon as the program starts, the ball doesn't bounce off the screen, it just falls through.
EDIT: Nvm, I figured it out. I'll be pushing it to the examples section of the fork I made.
This FFI has been great, its not perfect, but it works and has made wrapping libraries easier. Ideally, it would be much better to have ballPos.x instead of ballPos[1], but hey we're making progress!
My Github fork: https://github.com/gAndy50/libffi-euphoria
include raylib.e atom width = 800 atom height = 600 procedure main() InitWindow(width,height,"Bouncing Ball") sequence ballPos = {GetScreenWidth() / 2.0, GetScreenHeight() / 2.0} sequence ballSpeed = {5.0, 4.0} atom ballRadius = 20.0 integer paused = 0 integer framesCount = 0 SetTargetFPS(60) while not WindowShouldClose() do if IsKeyPressed(KEY_SPACE) and paused = 0 then paused = 1 elsif IsKeyPressed(KEY_SPACE) and paused = 1 then paused = 0 end if if paused = 0 then ballPos[1] += ballSpeed[1] --[1] is x ballPos[2] += ballSpeed[2] --[2] is y if ballPos[1] >= GetScreenWidth() - ballRadius or ballPos[1] <= ballRadius then ballSpeed[1] *= -1.0 --Forgot to add - in front of the 1.0 elsif ballPos[2] >= GetScreenHeight() - ballRadius or ballPos[2] <= ballRadius then ballSpeed[2] *= -1.0 else framesCount += 1 end if end if BeginDrawing() ClearBackground(RAYWHITE) DrawCircleV(ballPos,ballRadius,MAROON) DrawFPS(1,1) if paused = 1 then DrawText("Paused",GetScreenWidth() / 2,GetScreenHeight() / 2,50,LIGHTGRAY) end if EndDrawing() end while CloseWindow() end procedure main()