Re: Ball falls through Screen[SOLVED]
- Posted by petelomax Oct 05, 2022
- 723 views
Icy_Viking said...
irv said...
enum x,y -- will help, but I still prefer dot notation.
Thanks for the tip. I prefer dot notation as well.
Here's an older version of that demo, better than either [] or dot notation imo.
include Euraylib.ew atom width = 800, height = 450 InitWindow(width,height,"Bouncing Ball") atom ball_x = width/2, ball_y = height/2, ball_speed_x = 5.0, ball_speed_y = 4.0, ball_radius = 20 integer paused = 0, frameCounter = 0 SetTargetFPS(60) constant black = #00000000, green = #FF00FF00, red = #FF0000FF while not WindowShouldClose() do if IsKeyPressed(KEY_SPACE) then paused = not paused end if if paused = 0 then ball_x += ball_speed_x ball_y += ball_speed_y if ball_x >= width - ball_radius or ball_x <= ball_radius then ball_speed_x *= -1.0 end if if ball_y >= height - ball_radius or ball_y <= ball_radius then ball_speed_y *= -1.0 end if end if frameCounter += 1 BeginDrawing() ClearBackground(black) DrawCircleV(ball_x,ball_y,ball_radius,red) if paused = 1 and frameCounter / 30 then DrawText("PAUSED",1,20,30,green) end if DrawFPS(1,1) EndDrawing() end while CloseWindow()
The only thing dot notation even slightly makes sense for me is intellisense lookup, but that's a fairly weak argument:
after keying in ball_ you should get the same set of "sub-fields", and showing an intellisense for bal of balance/ball/balloney
rather than them plus all k+l+m sub-fields is something it could do with underscore notation anyway, plus (potentially and
somthing of a minor issue) all in a single intellisense lookup rather than forcing two.