Mercurial > games > semicongine
comparison examples/E10_pong.nim @ 166:5b0e27e448cb
add: support for showing/hiding cursur, X11 fullscreen (win32 still missing)
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 30 Apr 2023 01:02:33 +0700 |
parents | 0644308904da |
children | 84fd522fdf3f |
comparison
equal
deleted
inserted
replaced
165:0644308904da | 166:5b0e27e448cb |
---|---|
65 winsize = myengine.getWindow().size | 65 winsize = myengine.getWindow().size |
66 height = float32(winsize[1]) / float32(winsize[0]) | 66 height = float32(winsize[1]) / float32(winsize[0]) |
67 width = 1'f | 67 width = 1'f |
68 currentTime = cpuTime() | 68 currentTime = cpuTime() |
69 showSystemCursor = true | 69 showSystemCursor = true |
70 while myengine.updateInputs() == Running and not myengine.keyWasPressed(Escape): | 70 fullscreen = false |
71 while myengine.updateInputs() == Running and not myengine.keyIsDown(Escape): | |
71 if myengine.keyWasPressed(C): | 72 if myengine.keyWasPressed(C): |
72 if showSystemCursor: | 73 if showSystemCursor: |
73 myengine.hideSystemCursor() | 74 myengine.hideSystemCursor() |
74 else: | 75 else: |
75 myengine.showSystemCursor() | 76 myengine.showSystemCursor() |
76 showSystemCursor = not showSystemCursor | 77 showSystemCursor = not showSystemCursor |
78 if myengine.keyWasPressed(F): | |
79 fullscreen = not fullscreen | |
80 myengine.fullscreen(fullscreen) | |
77 | 81 |
78 let dt: float32 = cpuTime() - currentTime | 82 let dt: float32 = cpuTime() - currentTime |
79 currentTime = cpuTime() | 83 currentTime = cpuTime() |
80 if myengine.windowWasResized(): | 84 if myengine.windowWasResized(): |
81 winsize = myengine.getWindow().size | 85 winsize = myengine.getWindow().size |
95 | 99 |
96 ball.transform = ball.transform * translate3d(ballVelocity[0] * dt, ballVelocity[1] * dt, 0'f32) | 100 ball.transform = ball.transform * translate3d(ballVelocity[0] * dt, ballVelocity[1] * dt, 0'f32) |
97 | 101 |
98 # loose | 102 # loose |
99 if ball.transform.col(3).x - ballSize/2 <= 0: | 103 if ball.transform.col(3).x - ballSize/2 <= 0: |
100 break | 104 ball.transform = scale3d(ballSize, ballSize, 1'f) * translate3d(30'f, 30'f, 0'f) |
105 ballVelocity = newVec2f(1, 1).normalized * ballSpeed | |
101 | 106 |
102 # bar | 107 # bar |
103 if ball.transform.col(3).x - ballSize/2 <= barWidth: | 108 if ball.transform.col(3).x - ballSize/2 <= barWidth: |
104 let | 109 let |
105 barTop = player.transform.col(3).y - barSize/2 | 110 barTop = player.transform.col(3).y - barSize/2 |