-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx4.exw
61 lines (44 loc) · 1.01 KB
/
Ex4.exw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
without warning
include std/machine.e
include std/convert.e
include flags.e
include Euraylib.ew
atom w = 800, h = 600
InitWindow(w,h,"Move Ball")
atom ball_x = w / 2
atom ball_y = h / 2
SetTargetFPS(60)
atom g = bytes_to_int({0,0,0,0})
atom r = bytes_to_int({255,0,0,255})
while not WindowShouldClose() do
if IsKeyDown(KEY_RIGHT) then
ball_x += 2.0
if ball_x > (w-30) then
ball_x = w-30
end if
elsif IsKeyDown(KEY_LEFT) then
ball_x -= 2.0
if ball_x < 0 then
ball_x = 0
end if
elsif IsKeyDown(KEY_UP) then
ball_y -= 2.0
if ball_y < 0 then
ball_y = 0
end if
elsif IsKeyDown(KEY_DOWN) then
ball_y += 2.0
if ball_y > (h-30) then
ball_y = h-30
end if
end if
BeginDrawing()
ClearBackground(g)
DrawText("Use arrow keys to move ball.",1,1,30,r)
DrawText(to_string({"X:",ball_x}),1,30,20,r)
DrawText(to_string({"Y:",ball_y}),1,60,20,r)
DrawCircleV(ball_x,ball_y,30,r)
EndDrawing()
end while
CloseWindow()
52.45